For those interested why is this the case:
in a normal LaTeX environment,
align
also enables the math environment inside, so you do not have to enclose it in
$$
. However, Pandoc (which is responsible for Markdown -> Latex translation in RMarkdown) does not do that. If we surround the
align
environment with
$$
, you will get errors like these:
Package amsmath Error: Erroneous nesting of equation structures;
. To get around that, you have to use
aligned
, which does not create another math environment inside.
Closing notes
This pretty much covers basic LaTeX usage that you may need when working in RMarkdown. Please let me know what you think and if you had any issues using LaTeX in RMarkdown in the comments!