[Tex/LaTex] “Math Processing Error” when processing LaTeX using knitr in R

knitrmarkdownmathjaxr

I've never had any problem with my Latex appearing properly when using knitr before, but recently when I compile my document, I get this error:

mathjax

I'm not sure why this is happening. The error output I'm getting on the bottom of my HTML document says:

Loading Web-Font TeX/Math/Italic  
File failed to load: http://127.0.0.1:XXXXX/html_preview/mathjax/fonts/HTML-CSS/TeX/png/imagedata.js
Loading [MathJax]/jax/output/HTML-CSS/imageFonts.js

If anyone has any ideas or has seen anything like this happening when compiling LaTex when using knitr in R and has any recommendations on how to go about solving this issue, I'd be grateful. Thanks in advance.

Best Answer

I was getting this error too and it appeared to be because I had saved the .Rmd file in a different directory to R's default one.

i.e, my default R directory is

getwd()
"C:/Users/Dave/Documents"

When I create and run a .Rmd file from the default directory the maths symbols render fine.

However, if I create and save a .Rmd file in a different directory I get the same errors as you. I don't know why this is the case, but saving my .Rmd file in the default location solved the issue.