ankitects / anki

Anki's shared backend and web components, and the Qt frontend
https://apps.ankiweb.net
Other
18.63k stars 2.12k forks source link

Generating tmp.tex from [$$] block adds blank lines, breaking some environments #3466

Open dae opened 2 weeks ago

dae commented 2 weeks ago

A card with the following text: [$$] \begin{tikzcd} PB \ar[r, "g^{-1}"] \ar[d, "k*"'] & PD \ar[d, "h*"] \ PC \ar[r, "f^{-1}"'] & PA \end{tikzcd} [/$$]

generates the following tmp.tex file: [... preamble, including the needed \usepackage etc commands, snipped ...] \begin{displaymath} \begin{tikzcd} PB \ar[r, "g^{-1}"] \ar[d, "k_*"']

& PD \ar[d, "h_*"] \

PC \ar[r, "f^{-1}"']

& PA \end{tikzcd}

\end{displaymath} \end{document}

which fails to compile, because of the blank lines. I don’t know why Anki is introducing these blank lines, and I don’t know how to stop it doing so. Anki version: Anki 24.06.3 (d678e393) Python 3.9.18 Qt 6.6.2 PyQt 6.6.1 Platform: macOS-14.7-arm64-arm-64bit

Originally reported on https://forums.ankiweb.net/t/generating-tmp-tex-from-block-adds-blank-lines-breaking-some-environments/50169/2

juliangilbey commented 2 weeks ago

(And that forum post also has an analysis of the cause of the problem and a suggested resolution.)