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

Compilation fails when \cite{} is added #236

Closed RMeli closed 2 years ago

RMeli commented 3 years ago

Compilation fails when \cite{} is added. MWE below, but this also happens on more complex files where \cite{} is not empty.


File zero.tex:

\documentclass{article}
\begin{document}
Without reference.
\end{document}

File one.tex:

\documentclass{article}
\begin{document}
With reference \cite{}.
\end{document}

diff.tex (obtained with latexdiff zero.tex one.tex > diff.tex):

\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL zero.tex   Mon Jul 12 18:13:38 2021
%DIF ADD one.tex    Mon Jul 12 18:13:37 2021
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
\providecommand{\DIFmodbegin}{} %DIF PREAMBLE
\providecommand{\DIFmodend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF LISTINGS PREAMBLE %DIF PREAMBLE
\RequirePackage{listings} %DIF PREAMBLE
\RequirePackage{color} %DIF PREAMBLE
\lstdefinelanguage{DIFcode}{ %DIF PREAMBLE
%DIF DIFCODE_UNDERLINE %DIF PREAMBLE
  moredelim=[il][\color{red}\sout]{\%DIF\ <\ }, %DIF PREAMBLE
  moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ } %DIF PREAMBLE
} %DIF PREAMBLE
\lstdefinestyle{DIFverbatimstyle}{ %DIF PREAMBLE
    language=DIFcode, %DIF PREAMBLE
    basicstyle=\ttfamily, %DIF PREAMBLE
    columns=fullflexible, %DIF PREAMBLE
    keepspaces=true %DIF PREAMBLE
} %DIF PREAMBLE
\lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{} %DIF PREAMBLE
\lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}
\DIFdelbegin \DIFdel{Without reference }\DIFdelend \DIFaddbegin \DIFadd{With reference \mbox{%DIFAUXCMD
\cite{}}\hspace{0pt}%DIFAUXCMD
}\DIFaddend .
\end{document}

Compilation fails with the following error:

Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 29 September 2020, version: 4.70b.
Rule 'pdflatex': The following rules & subrules became out-of-date:
      'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  -synctex=1 -interaction=nonstopmode -file-line-error -recorder -output-directory="/Users/rmeli/Desktop/latexdiff"  "/Users/rmeli/Desktop/latexdiff/diff.tex"'
------------
Set environment variable BIBINPUTS='/Users/rmeli/Desktop/latexdiff:'
Set environment variable TEXINPUTS='/Users/rmeli/Desktop/latexdiff:'
Latexmk: applying rule 'pdflatex'...
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(/Users/rmeli/Desktop/latexdiff/diff.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18> (/usr/local/texlive/2021/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2021/texmf-dist/tex/generic/ulem/ulem.sty) (/usr/local/texlive/2021/texmf-dist/tex/latex/graphics/color.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/graphics-cfg/color.cfg) (/usr/local/texlive/2021/texmf-dist/tex/latex/graphics-def/pdftex.def)) (/usr/local/texlive/2021/texmf-dist/tex/latex/listings/listings.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2021/texmf-dist/tex/latex/listings/lstmisc.sty) (/usr/local/texlive/2021/texmf-dist/tex/latex/listings/listings.cfg)) (/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def) (/Users/rmeli/Desktop/latexdiff/diff.aux) (/usr/local/texlive/2021/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
/Users/rmeli/Desktop/latexdiff/diff.tex:46: Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.46 }
      \DIFaddend .
/Users/rmeli/Desktop/latexdiff/diff.tex:46: Extra }, or forgotten \endgroup.
\UL@stop ... \UL@putbox \fi \else \egroup \egroup 
                                                  \UL@putbox \fi \ifnum \UL@...
l.46 }
      \DIFaddend .
/Users/rmeli/Desktop/latexdiff/diff.tex:46: Missing } inserted.
<inserted text> 
                }
l.46 }
      \DIFaddend .
/Users/rmeli/Desktop/latexdiff/diff.tex:46: Missing } inserted.
<inserted text> 
                }
l.46 }
      \DIFaddend .
[1{/usr/local/texlive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (/Users/rmeli/Desktop/latexdiff/diff.aux) )
(see the transcript file for additional information)</usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/latxfont/lasy6.pfb>
Output written on /Users/rmeli/Desktop/latexdiff/diff.pdf (1 page, 15136 bytes).
SyncTeX written on /Users/rmeli/Desktop/latexdiff/diff.synctex.gz.
Transcript written on /Users/rmeli/Desktop/latexdiff/diff.log.
Latexmk: Log file says output to 'diff.pdf'
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 1
      Refer to '/Users/rmeli/Desktop/latexdiff/diff.log' for details
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs, or warnings treated as errors.
Latexmk: Examining '/Users/rmeli/Desktop/latexdiff/diff.log'
=== TeX engine is 'pdfTeX'
Latexmk: Errors, so I did not complete making targets

OS: macOS 11.4 latexdiff: LATEXDIFF 1.3.1.1 (Algorithm::Diff 1.15 so, Perl v5.30.2)

RMeli commented 3 years ago

This is actually a duplicate of #218, but fixes are not yet included in the latest version.

ccaprani commented 2 years ago

FWIW, replicated using LATEXDIFF 1.3.1a (Algorithm::Diff 1.15 fast, Perl v5.32.1). Removing the \hspace{0pt} worked (found #218 after...c'est la vie).

LuminousXLB commented 2 years ago

I met the issue as well. But it seems to have been solved in 1.3.2.

ftilmann commented 2 years ago

It seems this is fixed now. Closing