4

I am writing markdown in Atom editor and using package markdown-preview-plus for live preview on Windows 10. I have Miktex on my PC.

For the sake of simplicity consider that the .md file contain only one formula

$$
\begin{align}
\sum_{i=0}^n i^2 &= \frac{(n^2+n)(2n+1)}{6} \\
y &= mx+c
\end{align}
$$

I am able to preview it in my editor and also in stackedit.io. But when I try to convert it to a pdf using pandoc test1.md -s -o test1.pdf, I receive the following error:

! Package amsmath Error: Erroneous nesting of equation structures;
(amsmath)                trying to recover with `aligned'.

See the amsmath package documentation for explanation. Type H <return> for immediate help. ...

l.57 \end{align}

pandoc.exe: Error producing PDF

I have two solution to this problem:

  1. I can remove $$ before and after the equation, but then there is no math rendering in preview pane.
  2. I can use {aligned} instead of {align}, then pdf will not have equation numbers.

My doubt: Is the above code a legitimate markdown code? And if it is then why pandoc is not converting it?

Is it possible to generate appropriate result using $$, like passing additional arguments while converting the .md to .pdf OR may be by including some kind of package?

Attaching preview, in case if it helps.

Let me know if I have not made myself clear.

Thanks

Attaching preview, in case if it helps.

pkj
  • 511

1 Answers1

0

You probably need to use -f markdown+raw_tex and then type in normal LaTeX, to get the numbering and alignment right:

\begin{align}
\begin{aligned}
\sum_{i=0}^n i^2 &= \frac{(n^2+n)(2n+1)}{6} \\
y &= mx+c
\end{aligned}
\end{align}

Using \begin{aligned} works:

$$
\begin{aligned}
\sum_{i=0}^n i^2 &= \frac{(n^2+n)(2n+1)}{6} \\
y &= mx+c
\end{aligned}
$$

I am basing this on answer to Which one should I use: \begin{align} or \begin{aligned}?.

align is used for entering to math-mode while aligned is used for multiple horizon alignment

wilx
  • 2,339