Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\intertext{...} from LaTeX to Typst #213

Open
joshniemela opened this issue Apr 15, 2023 · 6 comments
Open

\intertext{...} from LaTeX to Typst #213

joshniemela opened this issue Apr 15, 2023 · 6 comments

Comments

@joshniemela
Copy link

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
Copy link
Owner

jgm commented Apr 16, 2023

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

@jgm jgm transferred this issue from jgm/pandoc Apr 16, 2023
@joshniemela
Copy link
Author

Is this perhaps something I could try to implement?

@jgm
Copy link
Owner

jgm commented Apr 20, 2023

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.

@Enivex
Copy link

Enivex commented Dec 5, 2023

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
Copy link
Owner

jgm commented Dec 6, 2023

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

@10decikelvin
Copy link

In the meantime, I've made a hacky solution based on the amazing work by @jorsn on this other github issue that somewhat implements the functionality of \intertext{}.

Demo

What this does

  • Insert text between aligned equations
  • Independently cite and label equations within a group of aligned equations

Known issues

  • Doesn't work across page breaks (can't be fixed)
  • Doesn't work for text longer than one line (can be fixed but very difficult)

This is only a temp fix, and I really hope the typst devs pay attention to this issue and fix it soon once and for all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants