Correct Mathjax source in RStudio and RMarkdown

孤人 提交于 2019-12-22 18:20:36

问题


I create a R Markdown file in RStudio , then I click on the Knit HTML button on the top of the screen to create and save an HTML page which I want to use elsewhere, say store it on my server.

The problem with the HTML file, is that it contains

<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

which is not valid anymore, and when I edit the HTML and change the source to the following it works.

https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML

Any way I don't have to edit every time the HTML, but have the correct source from RStudio?


回答1:


This was changed in the rmarkdown package just about a month ago (see this commit). You just need to install the latest version of the rmarkdown package:

> devtools::install_github("rstudio/rmarkdown")

(of course, you'll also need to install.packages("devtools") if you don't have devtools.)

Incidentally, even without this step, you can tell rmarkdown where you want to get MathJax from. This is useful if you want to point to a different CDN.

output:
  html_document:
    mathjax: https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML

Finally, you can eliminate your MathJax CDN dependency entirely by using mathjax: local to use a built-in copy of MathJax in rmarkdown (note that you'll also need to set self_contained: no to do this).



来源:https://stackoverflow.com/questions/25892993/correct-mathjax-source-in-rstudio-and-rmarkdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!