How can I auto-number math equations in RMarkdown?

天大地大妈咪最大 提交于 2019-12-10 15:57:26

问题


$$
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.


回答1:


Try align not aligned

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



回答2:


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



来源:https://stackoverflow.com/questions/52939909/how-can-i-auto-number-math-equations-in-rmarkdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!