Closed yzcj105 closed 4 years ago
The problem is that [prl]revtex4-1 puts a space between \bibitem
and its arguments. It is a known and documented limitation of latexdiff that this is not allowed and will generally lead to confusion. You can work around this by using --allow-spaces
option but I don't consider it fully satisfactory because it can have negative side effects for your main text, and deleted references are not marked up. Depending on your workflow and programming skills I would recommend to either write a little pre-processor that removes the spaces between the arguments in the bbl file, or change the bibliography style to one that does not have these spurious spaces (note that in your toy example it still fails because there is a problem if the first item in the bibliography is deleted - that's a bug really, but I hope that situation is quite rare in real cases)
Note that I changed the title of this issue to better reflect the root cause. I will leave the issue open (as the pre-processor mentioned above could theoretically be integrated into latexdiff, but as "Low" priority, meaning I will not be working on it in the foreseeable future. Still you can let me know if you found a workable solution (and if you do write a pre-processor, please let me have a copy)
@ftilmann Thank you very much. Here is some quick feedback. I tested with --allow-space and get
\documentclass[prl]{revtex4-1}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL old-fl.tex Tue Mar 31 04:49:32 2020
%DIF ADD new-fl.tex Tue Mar 31 04:49:32 2020
\usepackage[colorlinks=false]{hyperref}
%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{\DIFaddtex}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdeltex}[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
%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 HYPERREF PREAMBLE %DIF PREAMBLE
\providecommand{\DIFadd}[1]{\texorpdfstring{\DIFaddtex{#1}}{#1}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF
\begin{document}
hello world
Reference \DIFdelbegin \DIFdel{C \mbox{%DIFAUXCMD
\cite{Verstraete:2004d}}%DIFAUXCMD
,
}\DIFdelend \DIFaddbegin \DIFadd{A \mbox{%DIFAUXCMD
\cite{Czarnik:2015}}%DIFAUXCMD
.
Reference B \mbox{%DIFAUXCMD
\cite{Czarnik:2012}}%DIFAUXCMD
.
}\DIFaddend
\DIFdelbegin %DIFDELCMD < \begin{thebibliography}{1}
%DIFDELCMD < %%%
\DIFdelend \DIFaddbegin \begin{thebibliography}{2}
\DIFaddend \makeatletter
\providecommand \@ifxundefined [1]{
\@ifx{#1\undefined}
}
\providecommand \@ifnum [1]{
\ifnum #1\expandafter \@firstoftwo
\else \expandafter \@secondoftwo
\fi
}
\providecommand \@ifx [1]{
\ifx #1\expandafter \@firstoftwo
\else \expandafter \@secondoftwo
\fi
}
\providecommand \natexlab [1]{#1}
\providecommand \enquote [1]{``#1''}
\providecommand \bibnamefont [1]{#1}
\providecommand \bibfnamefont [1]{#1}
\providecommand \citenamefont [1]{#1}
\providecommand \href@noop [0]{\@secondoftwo}
\providecommand \href [0]{\begingroup \@sanitize@url \@href}
\providecommand \@href[1]{\@@startlink{#1}\@@href}
\providecommand \@@href[1]{\endgroup#1\@@endlink}
\providecommand \@sanitize@url [0]{\catcode `\\12\catcode `\$12\catcode
`\&12\catcode `\#12\catcode `\^12\catcode `\_12\catcode `\%12\relax}
\providecommand \@@startlink[1]{}
\providecommand \@@endlink[0]{}
\providecommand \url [0]{\begingroup\@sanitize@url \@url }
\providecommand \@url [1]{\endgroup\@href {#1}{\urlprefix }}
\providecommand \urlprefix [0]{URL }
\providecommand \Eprint [0]{\href }
\providecommand \doibase [0]{http://dx.doi.org/}
\providecommand \selectlanguage [0]{\@gobble}
\providecommand \bibinfo [0]{\@secondoftwo}
\providecommand \bibfield [0]{\@secondoftwo}
\providecommand \translation [1]{[#1]}
\providecommand \BibitemOpen [0]{}
\providecommand \bibitemStop [0]{}
\providecommand \bibitemNoStop [0]{.\EOS\space}
\providecommand \EOS [0]{\spacefactor3000\relax}
\providecommand \BibitemShut [1]{\csname bibitem#1\endcsname}
\let\auto@bib@innerbib\@empty
\DIFdelbegin %DIFDELCMD < \bibitem [{\citenamefont {Verstraete}\ \emph {et~al.}(2004)\citenamefont
%DIFDELCMD < {Verstraete}, \citenamefont {Garc\'ia-Ripoll},\ and\ \citenamefont
%DIFDELCMD < {Cirac}}]{Verstraete:2004d}
%DIFDELCMD < %%%
\DIFdelend \DIFaddbegin \bibitem [{\citenamefont {Czarnik}\ and\ \citenamefont
{Dziarmaga}(2015)}]{Czarnik:2015}
\DIFaddend \BibitemOpen
\DIFdelbegin %DIFDELCMD < \bibfield {author} {\bibinfo {author} {\bibfnamefont {F.}~\bibnamefont
%DIFDELCMD < {Verstraete}}, \bibinfo {author} {\bibfnamefont {J.~J.}\ \bibnamefont
%DIFDELCMD < {Garc\'ia-Ripoll}}, \ and\ \bibinfo {author} {\bibfnamefont {J.~I.}\
%DIFDELCMD < \bibnamefont {Cirac}},\ }\href%%%
\DIFdel{@noop }%DIFDELCMD < {} {\bibfield {journal} {\bibinfo
%DIFDELCMD < {journal} {Phys. Rev. Lett.}\ }%%%
\textbf {%DIFDELCMD < \bibinfo {volume} {93}%%%
}%DIFAUXCMD
\DIFdel{,\ }%DIFDELCMD < \bibinfo
%DIFDELCMD < {pages} {207204} %%%
\DIFdel{(}%DIFDELCMD < \bibinfo {year} {2004}%%%
\DIFdel{)}%DIFDELCMD < }%%%
\DIFdelend \DIFaddbegin \bibfield {author} {\bibinfo {author} {\bibfnamefont {Piotr}\ \bibnamefont
{Czarnik}}\ and\ \bibinfo {author} {\bibfnamefont {Jacek}\ \bibnamefont
{Dziarmaga}},\ }\bibfield {title} {\enquote {\bibinfo {title} {Variational
approach to projected entangled pair states at finite temperature},}\ }\href
{\doibase 10.1103/PhysRevB.92.035152} {\bibfield {journal} {\bibinfo
{journal} {Phys. Rev. B}\ }\textbf {\bibinfo {volume} {92}},\ \bibinfo
{pages} {035152} (\bibinfo {year} {2015})}\BibitemShut {NoStop}
\bibitem [{\citenamefont {Czarnik}\ \emph {et~al.}(2012)\citenamefont
{Czarnik}, \citenamefont {Cincio},\ and\ \citenamefont
{Dziarmaga}}]{Czarnik:2012}
\BibitemOpen
\bibfield {author} {\bibinfo {author} {\bibfnamefont {Piotr}\ \bibnamefont
{Czarnik}}, \bibinfo {author} {\bibfnamefont {Lukasz}\ \bibnamefont
{Cincio}}, \ and\ \bibinfo {author} {\bibfnamefont {Jacek}\ \bibnamefont
{Dziarmaga}},\ }\bibfield {title} {\enquote {\bibinfo {title} {Projected
entangled pair states at finite temperature: Imaginary time evolution with
ancillas},}\ }\href {\doibase 10.1103/PhysRevB.86.245101} {\bibfield
{journal} {\bibinfo {journal} {Phys. Rev. B}\ }\textbf {\bibinfo {volume}
{86}},\ \bibinfo {pages} {245101} (\bibinfo {year} {2012})}\DIFaddend \BibitemShut
{NoStop}
\end{thebibliography}
\end{document}
The generated pdf file has only two references. I put the diff-fl.pdf
in the repo.
The problem seems like \href@noop
has been split into \href
and @noop
. Both \href
and \href@noop
have been individually defined as commands.
The problem with @ in commands is fixed in the master. I know a new release is overdue.
After the commit referenced above, at least the test example worked. Hopefully, it also works for longer documents
All the files listed here can be found in latexdiff_sample repo.
Suppose we have old version old.tex with old.bib, new.tex and new.bib. Both can be compiled individually
My latexdiff version
old.tex file
with old.bib file
new.tex file
new.bib file
I have also tried to run
old-fl.tex file
and new-fl.tex file
They also works perfectly. However, there is error when running
Here is the generated diff.tex