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.
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)
}
)
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.
- 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")))
Equations are rendered correctly and I have a table of content too.
Can you help me fix rstudio.markdownToHTML() so that it renders equations?
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?