0

I'm generating an html report from a knitr::spin marked up document

1) It works doing the following

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

2) However, the html file that is generated by spin('document.R') directly does not display LaTeX equations.

This is because (1) generates the MathJax scripts tags, but (2) does not.

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 
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419

1 Answers1

1

knitr::spin() calls markdown::markdownToHTML(), which does include MathJax when math expressions are present. 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').

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419