Skip to content

Latex: math environments not handled properly #11266

@cagix

Description

@cagix

Although the fix in #9711 has been implemented, not all math environments appear to be handled correctly.

Consider the following MWE:

# handled as expected

$$\begin{eqnarray}
S &\rightarrow& a A                      \nonumber \\
A &\rightarrow& d B \ | \ b A \ | \ c A  \nonumber \\
B &\rightarrow& a c \ | \ b C \ | \ c A  \nonumber \\
C &\rightarrow& \epsilon                 \nonumber
\end{eqnarray}$$

# will emit additional math environment

$$
\begin{eqnarray}
S &\rightarrow& a A                      \nonumber \\
A &\rightarrow& d B \ | \ b A \ | \ c A  \nonumber \\
B &\rightarrow& a c \ | \ b C \ | \ c A  \nonumber \\
C &\rightarrow& \epsilon                 \nonumber
\end{eqnarray}
$$

Compiling this with Pandoc 3.8.2.1 to LaTeX (pandoc mwe.md -t latex) the first case is recognised correctly, while in the second case an additional math environment is incorrectly wrapped around the eqnarray.

Output:

\section{handled as expected}\label{handled-as-expected}

\begin{eqnarray}
S &\rightarrow& a A                      \nonumber \\
A &\rightarrow& d B \ | \ b A \ | \ c A  \nonumber \\
B &\rightarrow& a c \ | \ b C \ | \ c A  \nonumber \\
C &\rightarrow& \epsilon                 \nonumber
\end{eqnarray}

\section{will emit additional math
environment}\label{will-emit-additional-math-environment}

\[
\begin{eqnarray}
S &\rightarrow& a A                      \nonumber \\
A &\rightarrow& d B \ | \ b A \ | \ c A  \nonumber \\
B &\rightarrow& a c \ | \ b C \ | \ c A  \nonumber \\
C &\rightarrow& \epsilon                 \nonumber
\end{eqnarray}
\]

Now, I could just drop the $$ when writing my Markdown files, but unfortunately they are needed for generating Github Markdown (gfm). If I drop the $$ and compile the example with pandoc mwe.md -t gfm, the eqnarray are simply ignored completely – whereas with $$ they are compiled as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions