简体   繁体   English

knitr :: spin不会生成MathJax脚本

[英]MathJax scripts not being generated by knitr::spin

I'm generating an html report from a knitr::spin marked up document 我正在从标记了文件knitr::spin生成html报告

1) It works doing the following 1)它可以执行以下操作

> spin("document.R")

Process the resulting .md file in Rstudio by clicking the "Preview HTML" button, and then the "view the webpage with the system web browser" button. 通过单击“预览HTML”按钮,然后单击“使用系统Web浏览器查看网页”按钮,在Rstudio中处理生成的.md文件。

2) However, the html file that is generated by spin('document.R') directly does not display LaTeX equations. 2)但是,由spin('document.R')生成的html文件直接不显示LaTeX方程。

This is because (1) generates the MathJax scripts tags, but (2) does not. 这是因为(1)生成MathJax脚本标签,而(2)不会。

Any ideas why not? 任何想法为什么不呢?

R 2.15.1> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] markdown_0.5.4 knitr_1.2     

loaded via a namespace (and not attached):
[1] digest_0.6.3   evaluate_0.4.3 formatR_0.7    stringr_0.6.2  tools_2.15.1 

knitr::spin() calls markdown::markdownToHTML() , which does include MathJax when math expressions are present. knitr::spin()调用markdown::markdownToHTML() ,当存在数学表达式时,它确实包括MathJax。 I cannot reproduce the problem with a minimal example: 我无法通过一个最小的例子重现该问题:

#' A math expression $\alpha+\beta$. Below is a code chunk:
x <- 5
y <- 10

I can see the math expression after I save it as test.R and run spin('test.R') . 将其另存为test.R并运行spin('test.R')后,可以看到数学表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM