anki icon indicating copy to clipboard operation
anki copied to clipboard

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

Open dae opened this issue 1 year ago • 3 comments

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

dae avatar Oct 02 '24 13:10 dae

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

juliangilbey avatar Oct 02 '24 15:10 juliangilbey

Hi! I'm new to contributing and this will be my first issue. I will start by investigating the code that generates the tmp.tex file from the [$$] blocks and try to remove the unwanted blank lines. Does this still need to be fixed?

Thanks!

matbe766 avatar Sep 08 '25 11:09 matbe766

Hi @matbe766, thanks! As far as I know, this still needs to be fixed (though I haven't had a chance to check recently). I have given a detailed analysis of the code as it was last year on the forums and a proposed fix - I do suggest reading that.

juliangilbey avatar Sep 09 '25 05:09 juliangilbey