Workflow for Rmarkdown with equations


I am writing a series of case studies about fitting with stan different kinds of bayesian factor models usefull for ecologists. I write actually for a github page based on the “minimal mistake” jekyll theme.

However, I have trouble processing my Rmarkdown documents to a format easily compiled by jekyll through github pages. This is especially the case for equations, which I am used to write in a general latex syntaxe. Even the simplest like this one might be messed up :

F \sim MultiNormal(0, \Sigma)\\
diag(\Sigma) = 1
F \sim MultiNormal(0, \Sigma)\\ diag(\Sigma) = 1

I tried different options : iframing html produced by knit in posts (shows equations correctly, but cut the document before the end!), using intermediate .md file used by knit to create the final html (do not display every equation correctly), or using directly the “github_document” output in Rmarkdown specification (do not display any equation).

What do you think is the best workflow to go from an Rmarkdown file to a correctly displayed and integrated post using jekyll through github pages?

Thank you!

EDIT : code correction

A detail : both html and pdf produced by these Rmarkdown look very great!

Have you considered MathJax?

I am looking at mathjax and Rmarkdown docs, and I think latex equations in Rmarkdown would be transformed in mathjax when compiled. Am I right?

Do you mean that writing directly in mathjax would be more efficient?

MathJax is an Ajax library for displaying LaTeX via html in most browsers, in some cases it needs to added to the end of an html file for LaTeX formatted equations to be displayed correctly. This is possibly not always included by default since there may be alternative methods.

1 Like