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
513 stars 72 forks source link

Latexdiff --flatten not including preamble when whole body is in additional file #114

Open cnicolai opened 6 years ago

cnicolai commented 6 years ago
latexdiff-vc --version
This is LATEXDIFF-VC 1.2.1
  (c) 2005-2017 F J Tilmann

Hi there,

first of all thank you very much for offering latexdiff, it is an amazing and helpful tool. I tried to latexdiff-vc it to compare the latest versions on two different branches. This is the full command:

latexdiff-vc --git --force --pdf --only-changes --flatten -r $(git rev-parse master) -r $(git rev-parse HEAD) filename.tex

This creates a .tex file without the definitions of the "diff" commands (i.e. \DIFdelbegin and all the other commands are not defined) and therefore pdflatex will fail. Is this the expected behavior?

Any comments are greatly appreciated :)

ftilmann commented 6 years ago

It is the expected behaviour if filename.tex does not have a preamble, i.e. does not follow the structure

\documentclass{..}
...
\begin{document}
...
\end{document}

If this is the case, then normally filename.tex itself is included in a larger master file, so the DIF commands should be defined in the master, and I would say it is unusual to try and flatten a document, which is not itself the master. You can work with --show-preamble option but really this is not a good way because latexdiff adapts its behaviour somewhat in response to the used packages, and it cannot do this if it does not see the actual preamble (or you would have to tell it about included packages manually with --packages option.

cnicolai commented 6 years ago

Wow, that is a quick response, thank you very much!

In my situation, filename.tex just sets the document class, i.e. it just contains

\documentclass{...}
\input{settings}

while settings.tex contains

\usepackage{...}
...
\usepackage{...}
...
\begin{document}
...
\end{document}
ftilmann commented 6 years ago

latexdiff does the splitting of the text into premable and body before flattening. Actually, I would consider this behaviour a bug. I use the same structure as you describe for my beamer presentations, but I had never run latexdiff on them so never noticed this shortcoming. It should be possible to fix this, but might take a little time to get around to do it. In the meantime you might have to use an external flattening program.

cnicolai commented 6 years ago

Alright, thanks for the update. Take your time!

cnicolai commented 6 years ago

Hi, I just wanted to ask what your plans are regarding this bug. Do you think you will have the time to look into it? No pressure, I'm just curious :-)

ftilmann commented 6 years ago

Hi, I had put latexdiff a bit on the backburner lately due to other commitments, but this is still on the agenda (as are a number of other feature requests, though).

cnicolai commented 6 years ago

Hi, thank you for the feedback. Totally understandable, I don't want to urge you :-)