Skip to content

Spurious paragraph breaks before and after LaTeX {subequations} maths environment #7883

@krivit

Description

@krivit

I had an issue in Rmarkdown which I ultimately tracked down to Pandoc.

To reproduce

  1. Construct the following Markdown file, e.g., testfile.md:
    Text before equations.
    \begin{subequations}
    \begin{align}
    a\\
    b
    \end{align}
    \end{subequations}
    Text after equations.
    
    Text before equations.
    \begin{align}
    a\\
    b
    \end{align}
    Text after equations.
  2. Run pandoc testfile.md -o testfile.tex.

Expected result

The following LaTeX file:

Text before equations. \begin{subequations}
\begin{align}
a\\
b
\end{align}
\end{subequations} Text after equations.

Text before equations. \begin{align}
a\\
b
\end{align} Text after equations.

Actual result

Text before equations.

\begin{subequations}
\begin{align}
a\\
b
\end{align}
\end{subequations}

Text after equations.

Text before equations. \begin{align}
a\\
b
\end{align} Text after equations.

Thus, spurious paragraph breaks are created before \begin{subequations} and after \end{subequations} but not so with the align environment.

Workaround

For now, this can be worked around by replacing \begin{subequations} and \end{subequations} with LaTeX macros:

\def\bse{\begin{subequations}}
\def\ese{\end{subequations}}

Notes

From keyword searching through the source code, I suspect that at least a part of the fix would be to add "subequations" to the list below. However, I know neither Haskell nor Pandoc's internals, so I don't know what else is involved.

where envName = T.takeWhile (/= '}') (T.drop 7 s)
mathmlenvs = [ "align"
, "align*"
, "alignat"
, "alignat*"
, "aligned"
, "alignedat"
, "array"
, "Bmatrix"
, "bmatrix"
, "cases"
, "CD"
, "eqnarray"
, "eqnarray*"
, "equation"
, "equation*"
, "gather"
, "gather*"
, "gathered"
, "matrix"
, "multline"
, "multline*"
, "pmatrix"
, "smallmatrix"
, "split"
, "subarray"
, "Vmatrix"
, "vmatrix" ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions