1
votes

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.

1
You don't need to use the $$, it is enough to just use the align environmentuser20650
I actually think the removal of the $$ has fixed another issue I was having - it didn't seem to want o print to pdf if I included the \tag{1} and \tag{2} clauses. As soon as I removed the $$ dollars, it worked, so thank you!GCJ

1 Answers

0
votes

I've managed to solve this issue by adding this code to the YAML section of the document:

header-includes:
  - \usepackage{amsmath}