2

I've got an R Markdown document that I can successfully render with knitr on R Studio 1.1.423 and R version 3.4.3 under Linux. It has a bunch of LaTeX equations that render without issue. I use the knit button on R Studio to accomplish this task.

I've got the exact same versions of R Studio/R on Windows 10 and I can't get the LaTeX equations to render at all. Instead of the equation I get (=) where the equation ought to be on the rendered HTML webpage. This happens on both the R Studio preview pane, and if I open the generated HTML file in Chrome same issue. Oddly enough the equations do showup in the R Studio source pane when I hover the mouse over them on Windows 10.

[Edit] I've got the latest versions of knitr and rmarkdown installed in R. I've got Tex Live on both Linux and Windows 10. The equation that won't render on Windows is \( $Yummy = \frac{Effective Mass}{Avacados Constant} \).

stackinator
  • 5,429
  • 8
  • 43
  • 84
  • 1
    MathJax is a JavaScript library for displaying Latex equations in browsers. I'm not sure if lack of MathJax is the cause of your issue, but [here are instructions](http://docs.mathjax.org/en/latest/installation.html) for installing it, in case you need to. – eipi10 Mar 17 '18 at 22:31
  • 1
    Do you have a version of LaTeX installed? Pandoc doesn't convert markdown to PDF, it converts to LaTeX source, and the LaTeX processor converts the result to images. – user2554330 Mar 17 '18 at 22:35
  • I've got Tex Live on both the Linux and Windows machines. I remember reading somewhere it's better to have MikTex on Windows machines but that probably doesn't matter in this case. – stackinator Mar 17 '18 at 23:13
  • 1
    Why don't you provide a [minimal reproducible example](https://stackoverflow.com/a/5963610/6574038) of your code? – jay.sf Mar 18 '18 at 05:32
  • What does `$Yummy` represent? You should rather use `\( \$Yummy ... \)` or `$ \$Yummy ... $`. – Werner Mar 21 '18 at 05:28

1 Answers1

2

I ended up removing the spaces in the equation transforming it from this:

\( $Yummy = \frac{Effective Mass}{Avacados Constant} \)

into this:

\($Yummy = \frac{Effective Mass}{Avacados Constant}\)

Now it properly renders in Windows 10. Strangely enough both examples render fine on Linux, and I can also get the centered version - with spaces - to render properly in Windows 10. It's just the inline version that breaks. This does work:

\[ $Yummy = \frac{Effective Mass}{Avacados Constant} \]

stackinator
  • 5,429
  • 8
  • 43
  • 84