latexdiff icon indicating copy to clipboard operation
latexdiff copied to clipboard

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

Open cnicolai opened this issue 8 years ago • 7 comments

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 :)

cnicolai avatar Sep 15 '17 09:09 cnicolai

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.

ftilmann avatar Sep 15 '17 09:09 ftilmann

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}

cnicolai avatar Sep 15 '17 09:09 cnicolai

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.

ftilmann avatar Sep 15 '17 11:09 ftilmann

Alright, thanks for the update. Take your time!

cnicolai avatar Sep 15 '17 15:09 cnicolai

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 :-)

cnicolai avatar Apr 04 '18 18:04 cnicolai

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).

ftilmann avatar Apr 04 '18 20:04 ftilmann

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

cnicolai avatar Apr 05 '18 06:04 cnicolai