/
Generating equation numbers in RMarkdown files

Generating equation numbers in RMarkdown files

I came across a MathJax script that you can add to the top of a .Rmd file, which then automatically generates numbers to the right of your display equation (i.e., $$eqn$$):

<script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "all", formatNumber: function (n) {return +n} } } }); </script>

The script is placed at the top of the Rmd file, below the YAML block. I’m not sure if this works for other documents, but this is how it looks in a webpage:

It also appears that the numbers don’t show up for in-line equations. And you can stop a number from showing up to the right of a display equation using \nonumber in the LaTeX code. For example: $$E=mc^2\nonumber$$ would not have a number associated with it.

Source: https://stackoverflow.com/questions/35026405/auto-number-equations-in-r-markdown-documents-in-rstudio

 

Related content

Ensuring Rmd equations render in web pages
Ensuring Rmd equations render in web pages
More like this
How to interpret R within Latex - not R markdown
How to interpret R within Latex - not R markdown
More like this
How to use Make with R and Latex
How to use Make with R and Latex
More like this
An introduction to different R dialects: Base R, the Tidyverse and data.table
An introduction to different R dialects: Base R, the Tidyverse and data.table
More like this
Installing R packages on Teton
Installing R packages on Teton
More like this
Installing R packages
Installing R packages
More like this