Hello everyone,

Here is a "user story" in which I would like to discuss how math is handled by pandoc AST and pandoc markdown.
I haven't been able to find existing discussion on this topic. I hope I'm not retreading something that has been discussed before.
I'm sorry for any issues with clarity: this is my first time submitting something like this to a floss project.

I write this as a mathematician, somewhat familiar with latex but frustrated by its opacity and how ugly .tex files look.
I thus want to edit documents in a lighter markup while still having the following latex features:
- math shortcodes: to simplify source code and for faster typing
- multi-line equations
- cross-references for a given equation line
- cross-references for text blocks, for theorems
I'd like to author documents in HTML, since it is the standard output format for the web, and PDF, if possible via latex, for back-compatibility with editors.

Pandoc provides a solution for almost all of these. The only issue is multi-line equations.
A work-around I am aware of is to just use raw latex code like:
```latex
\begin{align}
1 + 1 &= 2 \label{first_line} \\
1 + 2 &= 3  \label{second_line}
\end{align}
```
which works fine when exporting to both HTML and latex: it is added as is to the HTML where it is parsed by both mathjax and katex.

However, I propose that formatting equations like typst might be a good way to make multiline math native to Pandoc, instead of piggy-backing on raw latex.

Multiline equations could be written as in latex, wrapped in `$$ $$`:
```
$$
1 + 1 &= 2 \\
1 + 2 &= 3
$$
```

which could be parsed as a new DisplayMathMultiline type in the AST.
(This is a mockup: I really don't understand how the AST is written)
```
[ Math DisplayMathMultiline
    [
        Math DisplayMathLine ["1+1", "=2"]
        Math DisplayMathLine ["1+2", "=3"]
    ]
]
```

This type can be written to:
- HTML and latex: as an `align` block
- typst: as a multiline math block
- pandoc markdown: as a multiline math block
- other: as multiple successive displayMath blocks

I do not see how modifying the AST in this way would produce an issue: it's an additive feature as far as I can tell. It can always default down to multiple displayMath blocks
For pandoc markdown, this makes the characters `&` and `\\` take on special meaning in math mode. I'm not familiar enough with math in markdown to know whether that could cause issues. If the behavior is implemented as an extension that the user can enable/disable, then this remains backwards compatible. It's also possible to use other characters, but this would mean that the syntax differs from latex.

Do you believe that this is an interesting feature to have for pandoc?

Best regards
Guillaume

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/672a5917-b04d-4eb9-966d-75b54df97837n%40googlegroups.com.