在RStudio和RMarkdown中正确的Mathjax源 [英] Correct Mathjax source in RStudio and RMarkdown

查看:300
本文介绍了在RStudio和RMarkdown中正确的Mathjax源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在RStudio中创建一个R Markdown文件,然后单击屏幕顶部的Knit HTML按钮以创建并保存要在其他地方使用的HTML页面,例如将其存储在服务器上.

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.

HTML文件的问题在于它包含

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>

这不再有效,当我编辑HTML并将源代码更改为以下代码时,它将起作用.

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

任何方式都不必每次都编辑HTML,但可以从RStudio获得正确的源代码吗?

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

推荐答案

大约一个月前,在rmarkdown软件包中对此进行了更改(请参见

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")

(当然,如果您没有devtools,也需要install.packages("devtools").)

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

顺便说一句,即使没有此步骤,您也可以告诉rmarkdown您要从何处获取MathJax.如果要指向其他CDN,这将很有用.

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

最后,可以通过使用mathjax: local在rmarkdown中使用MathJax的内置副本来完全消除MathJax CDN依赖性(请注意,您还需要设置self_contained: no来执行此操作).

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).

这篇关于在RStudio和RMarkdown中正确的Mathjax源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆