Problems with in_header, \usepackage{cancel} for Rmarkdown. Cancel package not working/recognized

I have followed the instructions here among other places.

In other words, in_header: followed by -\usepackage{cancel} includes the latter in the preamble, thus presumably loads the package when creating the tex document.

When reviewing the tex doc, I see that it is in fact added. However, I ran into 2 problems:

  1. Originally, for whatever reason, it doesn't find my cancel.sty file even though it's installed. Consequently, I had to add a .sty from CTAN to the same directory as the rmd file so it could knit. I also updated my tex to 2021.

  2. Even after doing this, when I try to use commands from the package in my rmd file, they don't work nor display under the chunk like the other latex code (i.e. if I do $$ \cancel{2} $$ it doesn't work).

Any thoughts on why this is happening?

I haven't experimented with other packages to see if this problem is package dependent nor am I familiar with the behavior of Rmarkdown within RStudio. In other words, what happens when packages are added to the preamble using the process above vs already in the template I'm using.

For example, I obviously need certain math packages (amsmath) to write out my equations and those packages are already in the default template (\usepackage{amsmath}). I'm using an APA 6th edition template.

Therefore, when I'm writing equations in my Rmarkdown file within RStudio , they pop up in the display which signifies to me packages are loaded and all things are well.