Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I auto-number math equations in RMarkdown?

$$
r  = \frac{1}{n-1} \sum_{i=1}^{n} \frac{(X_i - \bar{X})(Y_i - \bar{Y})}{S_xS_y}
$$

The rendered equation is not numbered. Using \begin{aligned} and \end{aligned} generates an error.

I am also using knitr in RStudio, knitting to PDF using pandoc and xelatex engine.

Thank you.

like image 935
Kranja Avatar asked Oct 23 '18 01:10

Kranja


1 Answers

As pointed out amsmath is already in the default template, so you can invoke the equation environment

\begin{equation}
y = mx+b
\end{equation}

This will automatically number equations in order of use. To use another character, say *,

\begin{equation}
\tag{*}
y = ax^2 + bx + c
\end{equation}

To leave equation unmarked simply leave tag{} blank.

For differences between align and equation see this answer

like image 111
Tcfkaj Avatar answered Sep 20 '22 01:09

Tcfkaj