ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
506 stars 72 forks source link

Insert preamble extension right after \documentclass #291

Closed ilveroluca closed 4 months ago

ilveroluca commented 7 months ago

Currently latexdiff inserts its preamble defining \DIF* commands just before the \begin{document}. With some documents, this approach results in markup commands being used before they're defined (e.g., see #163).

Could it (at least optionally) insert the its preamble earlier, say right after \documentclass?

ftilmann commented 4 months ago

The reason for putting them at the end of the preamble is that these commands pull in some packages. If the user also imports these packages but with different options, then the user-desired options could potentially be over-ridden. Of course, making this optional with an argument is a possibility.

ftilmann commented 4 months ago

Looking into this I remembered that I had actual implemented this a long time ago, but first tests often showed errors, for the reason I just mentioned (incompatible options of imported packages). The latexdiff source contains a line $earlylatexdiffpreamble=0; If you find that line and change to $earlylatexdiffpreamble=1; you should be able to get the functionality that you want (not tested for a long time, though). The other possibility, if the .tex file is under your control, to just copy/paste the preamble where you want it in the old and new sources (or use \input to avoid clutter) and use --preamble=/dev/null (on linux) to stop latexdiff from adding it again. I will close this because it actually seems not such a good idea to allow this easily. If your experiences are more positive feel free to re-open