I have been working in R Markdown, which supports LaTeX, including in display mode. I had the following snippet for displaying aligned equations
$$
\begin{align}
a_1 &= \beta_0 \\
b_1 &= \beta_1 \\
c_1 &= \beta_2 \\
d_1 &= \beta_3
\end{align}
$$
This worked great for me when I chose to output as HTML. I believe this uses MathJax.
However, when I changed the output format to PDF, I get the following error message:
processing file: dummy.Rmd output file: dummy.knit.md
! Package amsmath Error: Erroneous nesting of equation structures; (amsmath) trying to recover with `aligned'.
See the amsmath package documentation for explanation. Type H for immediate help. ...
l.87 \end{align}
pandoc: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43 Execution halted
When I change this to use aligned
instead of align
, it works with both.
This is an entire .Rmd file that shows the problem:
---
title: "dummy"
author: "Harold Ship"
date: "23 December 2015"
output: pdf_document
---
$$
\begin{align}
a_1 &= \beta_0 \\
b_1 &= \beta_1 \\
c_1 &= \beta_2 \\
d_1 &= \beta_3
\end{align}
$$
My question is, what is the difference between align
and aligned
, and why does align
not work here with pandoc?
align
is a full math environment, which must not be enclosed within (the deprecated!)$$
form or$
.aligned
on the other hand requires to appear in a math-mode enabling environment. I don't know whymathjax
does allow this syntax, butpandoc
uses LaTeX externally (as far as I know) and the error is reported.