2

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.

closed as off-topic by egreg, Henri Menke, Mike Renfro, Troy, Zarko Jun 29 '17 at 3:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center." – egreg, Henri Menke, Mike Renfro, Troy, Zarko
If this question can be reworded to fit the rules in the help center, please edit the question.

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

  • thanks for the effort, but then formula does not appear in preview ie without $$...$$ – pkj Aug 2 '16 at 15:19
  • @pkj: What about wrapping all that in \[ and \]? – wilx Aug 2 '16 at 22:46
  • @pkj: Alternatively, change the Pandoc Option: Makrdown Flavor setting to include +raw_latex. – wilx Aug 2 '16 at 22:52
  • wrapping inside\[...\] gives correct preview, but in pdf output it leaves the brackets [ and ], have a look at the snapshot – pkj Aug 3 '16 at 5:50
  • Pandoc option pandoc test2.md -f markdown+raw_latex -s -o test2.pdf results in pandoc.exe: Unknown extension: raw_latex – pkj Aug 3 '16 at 5:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.