tomduck / pandoc-eqnos

A pandoc filter for numbering equations and equation references.
GNU General Public License v3.0
221 stars 27 forks source link

Added feature of using multiline equations in LaTeX #42

Closed MFlossmann closed 4 years ago

MFlossmann commented 4 years ago

I added a feature that te script detects if you wrote an (aligned, or unaligned) equation with multiple lines. It only needs the amsmath package, which basically everyone already uses.

Didn't use align, because its' layout is considered to be a bit more messy and it expects to label every individual line which I'm not even sure on how to properly do without writing even more TeX-syntax into the equations.

tomduck commented 4 years ago

Hi Michael,

Thank you for this contribution, and sorry for the long wait. There was a similar PR submitted which was a little more general. I decided to go with that approach in today's release to make different LaTeX equation environments available. I hope it meets your needs.

Cheers, Tom

tomduck commented 4 years ago

This note is for future reference.

A design goal for the pandoc-xnos filters is to support all target output formats equally, and so customizations that apply to LaTeX only are normally avoided. LaTeX-only specializations should ideally be handled by a separate filter (e.g., pandoc-latex-extensions). This was a bit of a corner case.

By default, pandoc uses the math environment for equations. To enable numbered equations, pandoc-eqnos replaced this with the equation environment. That choice, however, was a little arbitrary. There are alternative environments that could have been used. Supporting users' ability to customize the environment to their needs seems appropriate.

Note, however, that in some cases there might be better choices than swapping out the equation environment. For aligned equations, for example, the aligned environment may be embedded as follows:

$$ \begin{aligned}
y &= x^2 + 2xy + y^2 \\
  &= (x+y)^2
\end{aligned} $${#eq:1}

This formulation will display as expected in all output formats.