I'm currently trying to knit a RMarkdown document to pdf, however, I keep getting an error. I've managed to figure out which bit of my code is causing the error, however, the code is displaying correctly when I preview the file or knit it to a html file. I can knit the file to pdf when I remove this block of code, but not sure why it won't work correctly. Here is the code:
$$
\begin{align}
R_{t+1} &= R_{t} + \alpha R_{t} - \beta R_{t}F_{t} \label{eq1} \tag{1} \\
F_{t+1} &= F_{t} + \beta R_{t}F_{t} - \gamma F_{t} \label{eq2} \tag{2}
\end{align}
$$
And here is the error I get:
! Package amsmath Error: Erroneous nesting of equation structures; (amsmath) trying to recover with `aligned'.
Further to the error, I've tried to altering the code to the following:
$$
\begin{aligned}
R_{t+1} &= R_{t} + \alpha R_{t} - \beta R_{t}F_{t} \label{eq1} \tag{1} \\
F_{t+1} &= F_{t} + \beta R_{t}F_{t} - \gamma F_{t} \label{eq2} \tag{2}
\end{aligned}
$$
However, when I do this, the equation doesn't display correctly in the html document.
I've managed to solve this issue by adding this code to the YAML section of the document:
header-includes:
- \usepackage{amsmath}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.