I'm using RStudio (current version) on a Windows 10. The math rendering works but when I add additional aspects to make the document more clean, I run into the problem of going from pdf to html and vice-versa. For instance, the following is knit to pdf with LaTex "code": enter image description here

Now, the following is the same input but knit to html: enter image description here

You can't really tell, but the R Markdown link (highlighted in the html) works for the pdf as well. The only difference is that the html does not display the theorem. The only way to mimic it, is to use html code but its not the same. Is there a way to make the html display the LaTex input just like the pdf? If not, then how does one deal with the issue of going from html to LaTex and vice-versa?


It should be showing previewed TeX in all cases here is TeX in Sweave rendered to PDF Also in-line preview in editor and Knit to both HTML and PDF.

enter image description here

I suggest that you need to query with the editor application forum what TeX settings or support packages you require. see https://support.rstudio.com/hc/en-us

In answering another question about how to manipulate highlighting of TeX in Rstudio Chunks (such as within your example of a Theorem) I found that it is possible to show the theorem as html in the knit preview viewer and thus in the Browser HTML but it is not done as a real time (In-line) preview since parts of the chunk need to be processed as a full document through Pandoc to resolve cross-references etc. This concurs with what is mentioned by the manual.

I guess it should be possible to send all that code I used to describe 1 character to mathjax and display in a mini html preview but in this case it helps to send the whole input on random occasions for the characters to be resolved for checking thus not slowing the machine down whilst each character of the block is compiled. For snippets of plain TeX it could run the same as other blocks of tex preview but in the code chunk they are rarely plain tex since they are as here being modified.

enter image description here

  • My problem is not with the rendering of Tex. The Tex work in both cases. What doesn't work is the Theorem. My question is why doesn't it? I read an RStudio manual and it says it won't display \begin{theorem} as it does when knitted to pdf but it doesn't say why. – Tomás Palamás Apr 1 '19 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.