Problems in LaTeX symbols while creating HTML documents by R Mardown


#1

Hi all,

I always use R Markdown to create project reports, assignments, etc for my college homework. I prefer the HTML documents. It was very well, but for a little over two weeks, I have noticed a problem. Whenever I use some latex codes in my report and compile it in a HTML file, it does not get displayed correctly all the time. If I am connected to Internet, it works fine. But if not, it gets displayed just as the original latex codes. The PDF output obviously works perfectly even now.

Consider a Rmd file with following contents.

---
title: "An example of the problem"
output: html_document
---

The following is a latex code: $\alpha \beta \gamma$

The following is a screenshot of the output document. The left one is when ONLINE, and right one while OFFLINE.

(Sorry, i am not allowed to upload two pictures in one post)

Is there any workaround for this?

Thanks


#2

From my understanding, LaTex only works with the PDF output in RMarkdown. That you'll need to use HTML code when you want to tweak an HTML document as it is not run through the LaTex engine at all.


#3

I'm afraid that I'll have to disagree. I am using it over a year, and it was never a problem. And even if you are right, in that case I should have get original latex code always, irrespective of the status of connectivity, isn't it?


#4

I'm sorry I misread your question. I have been testing a couple of different things and I'm still looking for a solution. When I've run your code with an internet connection everything works exactly how you've stated. Without an internet connection, it will render in the RStudio preview window but will not open in a web browser. I'll let you know if I find anything about how HTML documents load without an internet connection.


#5

It looks like it's something to do with MathJAX, an HTML converter for LaTex equations. Unless you have a local version installed, it will only work when online. Read about it here:

https://rmarkdown.rstudio.com/html_document_format.html#mathjax_equations


#6

If my understanding is correct (which is questionable), rending latex code as symbols requires the use of the MathJax. If you don't have an internet connection, you won't connect to the API and the symbols won't render.

I don't know if including self_contained: true in the YAML will resolve this (but I'm not optimistic)


#7

Thanks, I haven't noticed this before.