jgm/texmath

\intertext{...} from LaTeX to Typst

Opened this issue · 5 comments

Currently, it isn't possible to convert aligned environments containing \intertext.
Immediate solution: converting \intertext{...} to $...$ in Typst will give the intended result of intertext

Is this solution good enough or did I miss something?

jgm commented

The fundamental problem is that texmath's TeX reader doesn't yet support intertext.
That should be added.

Is this perhaps something I could try to implement?

jgm commented

Maybe! First step would be figuring out how to represent intertext in our AST; second step would be implementing it in the parser (src/Text/TeXMath/Readers/TeX.hs)

This is how we currently represent aligned environments:

% texmath -t native
\begin{align}
x &= y \\
1 &= 2
\end{align}
^D
[ EArray
    [ AlignRight , AlignLeft ]
    [ [ [ EIdentifier "x" ] , [ ESymbol Rel "=" , EIdentifier "y" ] ]
    , [ [ ENumber "1" ] , [ ESymbol Rel "=" , ENumber "2" ] ]
    ]
]

As you can see, there's no dedicated construction for aligned equations (which is maybe a problem, see #209). We just use an array. This makes it hard to see how we'd support intertext.

To me it seems natural that intertext would just split the equation environment into two parts. Sure the alignment would be off, but at least the text would be there. As in

\begin{align*}
    Math part 1
    \intertext{Some text}
    Math part 2}
\end{align*}

gets treated as

\begin{align*}
    Math part 1
\end{align*}
Some text
\begin{align*}
    Math part 2}
\end{align*}
jgm commented

@Enivex yes that's a good idea and it should be feasible.