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

New approach to LaTeX math environments #9711

Open
jgm opened this issue May 1, 2024 · 0 comments
Open

New approach to LaTeX math environments #9711

jgm opened this issue May 1, 2024 · 0 comments

Comments

@jgm
Copy link
Owner

jgm commented May 1, 2024

Certain LaTeX environments contain math but cannot occur in math mode: e.g., align. So

\[
\begin{align}...
...\end{align}
\]

is not legal. We would like to handle these in the best possible way. Parsing them to RawInline elements would be one approach, but this would mean that they were lost when converting to non-LaTeX formats. So instead we parse them as pandoc Math inlines. But because the LaTeX writer outputs Math inlines between \[..\] or \(..\), we modify these environments to versions that can live inside math mode: e.g., align -> aligned. For the most part this gives acceptable results, but there are rough edges. align environments are numbered, and aligned environments are not, so numbering gets lost when round-tripping LaTeX -> Markdown -> LaTeX.

Proposal: instead of "downshifting" these environments in the LaTeX reader, we could just put them in Math inlines. They should be harmless there, except in (a) LaTeX output and (b) HTML output using KaTeX. (MathJaX just allows them inside \[...\], and texmath, which we use for conversion to non-TeX math formats, can handle align.) For (a) and (b) we could do a check in the writers and, when these environments are encountered in Math, we could either "downshift" them or (in the case of LaTeX) just emit a raw LaTeX block.

Here are the affected environments: https://github.com/jgm/pandoc/blob/main/src/Text/Pandoc/Readers/LaTeX/Math.hs#L84-L110
The "downshifting" is done here and in mathEnvWith.

If we implemented this change, we'd also need to add handling to texmath for some of these special environments. (Some, but not all, are currently handled.)

I'm putting this up for comment and further consideration.

@jgm jgm added the enhancement label May 1, 2024
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

1 participant