自定义rstudio.markdownToHTML()后出现MathJax脚本问题 [英] MathJax script issue after customizing rstudio.markdownToHTML()

查看:107
本文介绍了自定义rstudio.markdownToHTML()后出现MathJax脚本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用knitr软件包中的knit2html(),我可以生成包含乳胶方程式和R代码的html页面.但是在我的系统上,使用RStudio的"knit html"按钮时不会呈现方程式.

With knit2html() from the knitr package, I can generate html pages that contain latex equations and R code. But on my system equations are not rendered when using RStudio's "knit html" button.

这是因为我修改了编织html"按钮的工作方式.为了在我的html页面上包含目录,我遵循了自定义Markdown渲染.并在项目目录的根目录创建了一个.Rprofile文件,该文件将覆盖默认的markdown渲染选项.我的.Rprofile仅包含一个替换rstudio.markdownToHTML()函数的函数,

It is because I have modified the way the "knit html" button works. To include a table of content on my html pages, I followed the Rstudio advice on Customize Markdown Rendering. And created an .Rprofile file at the root of the project directory that overrides default markdown rendering options. My .Rprofile only contains a function that replaces the rstudio.markdownToHTML() function as such:

options(rstudio.markdownToHTML = 
  function(inputFile, outputFile) {      
    require(markdown)
    htmlOptions <- markdownHTMLOptions(defaults=TRUE)
    htmlOptions <- c(htmlOptions, "toc")
    markdownToHTML(inputFile, outputFile, options = htmlOptions) 
  }
) 

有了这个.Rprofile,我很高兴能在我的所有.RmD文档上自动生成一个目录表. 但是方程式不再呈现!方程式显示为纯文本.

With this .Rprofile, I'm happy to have an automatic table of content generated on all my .RmD documents. But equations are not rendered any more! Equations appear as plain text.

  • 如果删除.Rprofile,请重新加载R,然后在R Studio中单击编织HTML"按钮.方程可以正确显示,但是我没有目录.
  • 如果我运行:

  • If I delete .Rprofile, reload R and click the "knit HTML" button in R Studio. Equations are rendered correctly but I don't have a table of content.
  • If I run :

knit2html("file.Rmd", "file.html", options = c(markdownHTMLOptions(defaults=TRUE), "toc")))

knit2html("file.Rmd", "file.html", options = c(markdownHTMLOptions(defaults=TRUE), "toc")))

方程正确显示,我也有一个目录.

Equations are rendered correctly and I have a table of content too.

您能帮我修复rstudio.markdownToHTML()以便它呈现方程式吗?

Can you help me fix rstudio.markdownToHTML() so that it renders equations?

编辑2014年4月3日:如果在网络浏览器中打开html页面,则方程式可见.它们不会在RStudio预览HTML窗格中呈现.这可能是Rstudio查看器不再考虑mathjax脚本的问题?

Edit 03 April 2014: Equations are visible if I open the html page in a web browser. They are not rendered in RStudio preview HTML pane. This might be an issue with the mathjax script not taken into account anymore by the Rstudio viewer?

推荐答案

Dason建议我将其发布为答案.

Dason suggested me to post this as an answer.

如果在Web浏览器中打开html页面,则方程式可见.

Equations are visible if I open the html page in a web browser.

方程式未在RStudio预览HTML窗格中呈现. Rstudio查看器可能有问题吗?

Equations are not rendered in RStudio preview HTML pane. This might be an issue with the Rstudio viewer?

这篇关于自定义rstudio.markdownToHTML()后出现MathJax脚本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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