Search code examples
rlatexrstudior-markdownmathjax

auto-number equations in R markdown documents in RStudio


I can auto-number mathjax equations in an R markdown document in RStudio by adding the following statement to the beginning of the Rmd document:

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

The following also works, but not with the $$..$$ equations, only equations bracketed with \begin{equation}..\end{equation}.

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

I can change the numbering to a static label with \tag{mylabel} inside the $$..$$, and the auto-numbering will skip that equation.

Unfortunately, to skip with no label add \tag{} results in the equation still labeled with ().

Does anyone know how to get rid of the empty brackets?

Does anybody know a simple statement to add to either the mathjax script statement or the $$..$$ equations within a Rmd doc that would add an auto-numbered Section number to the equation number?

most of the info from here: http://mathjax.readthedocs.org/en/latest/tex.html#automatic-equation-numbering

Thanks


Solution

  • You can use \notag or \nonumber on an expression to prevent an automatic tag from being applied to it. So if you are using autoNuber: "all", you can do

    $$E=mc^2\nonumber$$
    

    to get the equation with no number.