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

Problem with Bibliography #174

Closed JoTrab closed 4 years ago

JoTrab commented 5 years ago

I noticed that difflatex has problems with the bibliography. For me the pdflatex output failed when I added a new entry to the . Each field in the bibitem is added through \DIFadd which seems to result in the error. Enclosing the whole entry into DIFadd manually works.

Example:

\bibitem [{\DIFadd{\mbox{%DIFAUXCMD
        \citenamefont }\hspace{0pt}%DIFAUXCMD
        }{\DIFadd{Nocedal}}\DIFadd{\ and\ \mbox{%DIFAUXCMD
        \citenamefont
          }\hspace{0pt}%DIFAUXCMD
        }{\DIFadd{Wright}}\DIFadd{(1999)}}]{\DIFadd{Nocedal1999}}%DIF > 
          \BibitemOpen
          \bibfield  {\DIFadd{author}} {\bibinfo {\DIFadd{author}} {\bibfnamefont {\DIFadd{Jorge}}\DIFadd{\ }\bibnamefont
          {\DIFadd{Nocedal}}}\DIFadd{\ and\ }\bibinfo {\DIFadd{author}} {\bibfnamefont {\DIFadd{S. J.}}\DIFadd{\ }\bibnamefont
          {\DIFadd{Wright}}}\DIFadd{,\ }} {\emph {\bibinfo {\DIFadd{title}} {{\DIFadd{Numerical Optimization}}}}}\DIFadd{,\
          }\href {\DIFadd{https://doi.org/10.1121/1.417106}} \bibinfo {\DIFadd{volume}} {\DIFadd{17}}\DIFadd{\ 
          (}\bibinfo  {\DIFadd{publisher}} {\DIFadd{Springer New York}}\DIFadd{,\ }\bibinfo {\DIFadd{year}}
          {\DIFadd{2006}}\DIFadd{)}\BibitemShut {\DIFadd{NoStop}}
        \DIFaddend 

fails

but

\DIFaddbegin 
\bibitem [{\citenamefont {Nocedal}\ and\ \citenamefont
  {Wright}(1999)}]{Nocedal1999}%
  \BibitemOpen
  \DIFadd{
  \bibfield  {author} {\bibinfo {author} {\bibfnamefont {Jorge}\ \bibnamefont
  {Nocedal}}\ and\ \bibinfo {author} {\bibfnamefont {S. J.}\ \bibnamefont
  {Wright}},\ } {\emph {\bibinfo {title} {{Numerical Optimization}}}},\
  \href {https://doi.org/10.1121/1.417106} \bibinfo {volume} {17}\ 
  (\bibinfo  {publisher} {Springer New York},\ \bibinfo {year}
  {2006})}\BibitemShut {NoStop}
\DIFaddend          
ftilmann commented 5 years ago

Thanks for the report. This is something that works out of the box for me with natbib package, e.g. this is what latexdiff generates automatically for a citation for me:

\DIFaddbegin \bibitem[{Juli\`a et~al.(2000)Juli\`a, Ammon, Herrmann, and
  Correig}]{julia2000joint}
\DIFadd{Juli\`a, J., Ammon, C.~J., Herrmann, R.~B., Correig, A.~M., 2000. }{\DIFadd{Joint
  inversion of receiver function and surface wave dispersion observations}}\DIFadd{.
  Geophys. J. Int. 143, 99--112, doi:10.1046/j.1365-246x.2000.00217.x.
}

\DIFaddend 

So you have to be a more specific what packages you use exactly for preparing your bibliography. Maybe you can post a complete MWE, i.e. including the full tex for a very simple document (old and new versions, along with any needed sequence). I might not deal with this issue immediately, but if the package is popular, and more people report in with this problem, this would bubble up in priority.

Just looking at your text I can see two possible issues:

The best work-around for you might be to put all the citations in separate file and not process it with latexdiff, but include as-is. Of course, you lose the highlighting. Or switch to natbib but I guess that might not be acceptable for you.

JoTrab commented 5 years ago

Thanks for the quick answer. I usually use natbib, so great to hear that it works. In this specific case I actually copied the created bibliography into the texfile (required for submission to a scientific journal, apparently to be sure not to have any problems for compilation on their servers). The bibliography itself was created through revtex, I'll try to put together a MWE soon. For the moment I´l just l continue putting the citations in a separate file for latexdiff.

chponte commented 4 years ago

I am facing the same issue, although I may be using a different latex template than @JoTrab. In my case I have the bibliography on a separate file, and citing the references with \cite{#TAG}. The result is the same highlighted here:

\DIFdelbegin %DIFDELCMD < \cite{Wei2014a}%%%
\DIFdelend \DIFaddbegin \cite
{\DIFadd{Wei2014a}}\DIFaddend

The journal template used is this one: cabios-template.zip. I can work around the error if I use the argument --allow-spaces previously suggested.

I hope this helps in finding the cause! Cheers!

rashigeek commented 8 months ago

I am facing the same issue, although I may be using a different latex template than @JoTrab. In my case I have the bibliography on a separate file, and citing the references with \cite{#TAG}. The result is the same highlighted here:

\DIFdelbegin %DIFDELCMD < \cite{Wei2014a}%%%
\DIFdelend \DIFaddbegin \cite
{\DIFadd{Wei2014a}}\DIFaddend

The journal template used is this one: cabios-template.zip. I can work around the error if I use the argument --allow-spaces previously suggested.

I hope this helps in finding the cause! Cheers!

Super helpful! Thanks!