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

LaTeX -> docx breaks with comment in last line of align environment #8122

Closed
gerritzen opened this issue Jun 13, 2022 · 1 comment
Closed
Labels

Comments

@gerritzen
Copy link

Explain the problem.
The environment

\begin{align}
  a &= b\\ % comment1
  c &= d   % comment2
\end{align}

compiles fine with pdflatex, but pandoc -o foo.docx foo.tex throws the error

[WARNING] Could not convert TeX math \begin{aligned}
    a &= b\\ % comment1
    c &= d   % comment2\end{aligned}, rendering as TeX:
  mment2\end{aligned}
                     ^
  unexpected eof
  expecting "&", "\\\\", white space or "\\end"

In markdown it becomes

$$\begin{aligned}
  a &= b\\ % comment1
  c &= d   % comment2\end{aligned}$$

so the \end{aligned}$$ is commented out as well. In my opinion there should be a line break before \end{aligned}, regardless comments in the previous line.

Pandoc version?
What version of pandoc are you using, on what OS?

pandoc 2.18
Compiled with pandoc-types 1.22.2, texmath 0.12.5, skylighting 0.12.3.1,
citeproc 0.7, ipynb 0.2, hslua 2.2.0
Scripting engine: Lua 5.4

on Fedora 36 with TeXLive 2021 from the official repository.

@gerritzen gerritzen added the bug label Jun 13, 2022
@jgm
Copy link
Owner

jgm commented Jun 14, 2022

This is really just about the LaTeX reader and doesn't have anything to do with docx specifically.

% pandoc -f latex -t native
\begin{align}
  a &= b\\ % comment1
  c &= d   % comment2
\end{align}
[ Para
    [ Math
        DisplayMath
        "\\begin{aligned}\n  a &= b\\\\ % comment1\n  c &= d   % comment2\\end{aligned}"
    ]
]

There is code in the reader to change the align environment to something that can go in a math context (hence aligned), and your case shows that it's broken.

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

No branches or pull requests

2 participants