-1

I am putting together my first ioslides presentation in R Studio and discovered that inline equations are not rendered properly in the browser. When I hit Run Presentation everything is displayed as it should (i.e. the inline equations are rendered) in the R Studio Viewer. But when I want to open the presentation in the browser, the inline equations are not rendered anymore.

I found this question, which told me that it has something to do with Mathjax. As a total beginner I understand it is used to render any Latex style equations.

I tried the Mathjax links provided in the question and also the newer one indicated in the comments, but no luck, the inline equations are still displayed like this:

\(e=mc^2)\

instead of the rendered equation.

Here is my simplified presentation:

---
output:
  ioslides_presentation:
    mathjax: "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
runtime: shiny
---

## Inline Math does not work

It strange that this does not work. $e=mc^2$.
But this does:
$$e=mc^2$$
How about this \(e=mc^2\)?

Can anyone explain what is happening under the hood and how to have the inline equations properly rendered? Am I using the wrong link?

Patrick Glettig
  • 541
  • 1
  • 6
  • 12

1 Answers1

0

Somehow Mathjax in the YAML header did not seem to work. I found a workaround by adding it as a Script component into the beginning of the presentation.

Script Component to add:

<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

Note that in the header, I still had to add mathjax:. Everything comes together in a small working example:

---
output:
  ioslides_presentation:
    mathjax:
runtime: shiny
---

<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

## Inline Math

Inline with dollar signs works: $e=mc^2$.
Patrick Glettig
  • 541
  • 1
  • 6
  • 12