Sorry for my lack of clarity. I'm asking too many questions at the same time and it must be hard to follow. I should have rewritten that last email before sending it.

1. My question about aligned.
I see in the code that the typst reader parses typst multilines into this DisplayMath begin{aligned} structure.
Is that how you / the pandoc team has decided to handle multiline math in the future?

2. You propose to wrap align.
This is not working on my side, but I might be doing something wrong?
Here are some minimal examples:
```
$$
\begin{align}
x & = 5\\
y &= 3
\end{align}
$$
```
parses into latex as (with pandoc test.md --to latex; on pandoc 3.1.8)
```
\[
\begin{align}
x & = 5\\
y &= 3
\end{align}
\]
```
which fails to compile to pdf (with pandoc test.md --to pdf -o test.pdf
```
Error producing PDF.
! 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.62 \end{align}
```

removing the $$
```
\begin{align}
x & = 5\\
y &= 3
\end{align}
```
parses as is into latex and works

Am I missing something?

3. I'm surprised at how easy it actually is to write down a filter.
This is a really great feature of pandoc

Thank you for all the great work on this project, and thank you for your help
Best
Guillaume

On Friday, October 20, 2023 at 7:27:05 PM UTC+2 John MacFarlane wrote:


> On Oct 20, 2023, at 12:40 AM, Guillaume Dehaene <guillaum...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
> Thank you for your insight.
>
> 1. I'm not 100% satisfied with your solution since it does not work with latex environments which open math-mode (such as a align). These produce errors because of the double-opening of math-mode. It's also pretty cumbersome compared to usual md.
>
> I see that this is how pandoc parses typst equations (I should have looked!)
> [ Math
> DisplayMath
> "\\begin{aligned}\n1 + 1 & = 2 \\\\\n1 + 1 & = 2\n\\end{aligned}"
> ]
>
> Is that now going to be the accepted format for multiline equations?

I'm not sure I understand. This has always been possible in pandoc (and LaTeX); we use it here because it's the way to get equivalent LaTeX math to the typst formula.


Side note:

in pandoc you can also do

$$
\begin{align}
x & = 5\\
y &= 3
\end{align}
$$

even though this isn't possible in LaTeX. Pandoc will do the right thing the output format. Try it.

> 2. I had overlooked the possibility of writing a filter.
> The principle of the filter would then be:
>
> parse DisplayMath
> if there are & and/or \\ present, modify the block
> depending on writer:
> - latex, HTML: transform to align
> - everything else: transform to accepted format(??) \begin{aligned}
>
> Is that correct? If so, I'll start hacking at it in the near future.

Yes, something like that.

--
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/e9222236-9514-4cdc-b986-ae8e7e198576n%40googlegroups.com.