I am trying to generate equation numbers and cross-referencing in docx using Rmarkdown, but it is not working.
Here is my YAML
output:
officedown::rdocx_document:
reference_docx: ref_transfer.docx
header-includes:
- \usepackage{amsmath}
I have tried using (\#eq:test)
in the equation chunk enclosed with $$ (code below)
\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}
and \@ref(eq:test)
to cross-reference in line. That produced @ref(eq:test) in line and (#eq:test) as the equation number, see RenderOutput below.
I have also tried using \label{eq:test}
(code below)
\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}
in conjunction with \eqref{eq:test}
in line.
And that produces blanks where you'd expect to see the equation number and citation, see RenderOutput2.
Does anyone have a work around for this type of problem?? Please help.