问题
$$
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