【发布时间】:2023-02-01 21:55:39
【问题描述】:
我正在尝试使用 Rmarkdown 在 docx 中生成方程式编号和交叉引用,但它不起作用。
这是我的 YAML
output:
officedown::rdocx_document:
reference_docx: ref_transfer.docx
header-includes:
- \usepackage{amsmath}
我试过在用 $$ 括起来的等式块中使用 (\#eq:test)(下面的代码)
\begin{equation}
\begin{gather}
\text{Y}_{ij} = \alpha_{0} + \beta_{0}\text{X}_{1ij} + \alpha_{1}\text{Z}_{1j} +
\alpha_{2}\text{Z}_{2j} + \beta_{1}\text{Z}_{1j}\text{X}_{1ij} +
\beta_{2}\text{Z}_{2j}\text{X}_{1ij} + v_j\text{X}_{1ij} + u_j + \epsilon_{ij} \\
\text{where} \\
\epsilon_{} \sim N(0, \sigma^2) \\
u_j \sim N(0, \sigma^2_u) \\
v_j \sim N(0, \sigma^2_v)
\end{gather}
(\#eq:test)
\end{equation}
和\@ref(eq:test)在线交叉引用。那产生了@ref(当量:测试)在线和(#eq:测试)作为方程式编号,请参见下面的RenderOutput。
我也尝试过使用\label{eq:test}(下面的代码)
\begin{equation}
\begin{gather}
\text{Y}_{ij} = \alpha_{0} + \beta_{0}\text{X}_{1ij} + \alpha_{1}\text{Z}_{1j} +
\alpha_{2}\text{Z}_{2j} + \beta_{1}\text{Z}_{1j}\text{X}_{1ij} +
\beta_{2}\text{Z}_{2j}\text{X}_{1ij} + v_j\text{X}_{1ij} + u_j + \epsilon_{ij} \\
\text{where} \\
\epsilon_{} \sim N(0, \sigma^2) \\
u_j \sim N(0, \sigma^2_u) \\
v_j \sim N(0, \sigma^2_v)
\end{gather}
\label{eq:test}
\end{equation}
与 \eqref{eq:test} 一起使用。
这会在您希望看到方程式编号和引用的地方产生空白,请参阅RenderOutput2。
有没有人可以解决此类问题?请帮忙。
【问题讨论】:
标签: latex r-markdown pandoc equation officedown