I would like to insert Latex equations and Shiny apps in an R Markdown document. However, with the following lines the Latex equations are not displayed correctly:
---
title: "Untitled"
date: "Saturday, August 02, 2014"
output: html_document
runtime: shiny
---
Test
* test 1 : $x$
* test 2 : \(x\)
Both Latex equations in the markdown document appear as \(x\) in the HTML document (if I suppress the line "runtime: shiny", they are displayed correctly in the HTML document). Would this possibly be a bug, or is there any incompatibility between Shiny and Latex? I am using RStudio 0.98.981.
There are two possible solutions. The first one is to click the button Open in Browser to open the page in your web browser, and the math expression will render correctly. The problem in the RStudio window is that the HTTPS link to MathJax is used by default (documentation here), and you can replace it with a normal http link, e.g.
---
title: "Untitled"
date: "Saturday, August 02, 2014"
output:
html_document:
mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
runtime: shiny
---
Test
* test 1 : $x$
* test 2 : \(x\)
Or to make it even more portable, use
mathjax: "//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
But please note the "protocol-less" //...
link may not work in certain cases (read more).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With