Closed nail1962 closed 4 years ago
Sorry, this is not quite enough information. Could you post a minimal example.
Ok, step by step. 1) old file old.tex
\documentclass{article} \usepackage[hidelinks]{hyperref} \begin{document} Bla-bla \cite{p1} \bibliography{self} \bibliographystyle{elsarticle-num} \end{document}
2) New file with added one reference
\documentclass{article} \usepackage[hidelinks]{hyperref} \begin{document} Bla-bla \cite{p1,p2} new Bla-bla \bibliography{self} \bibliographystyle{elsarticle-num} \end{document}
3) self.bib file
@book{p1, author = {Hawking, S W and Ellis, G F R}, publisher = {Cambridge University Press}, title = {{The Large Scale Structure of Space-Time}}, year = {1973}, } @article{p2, author = {Thomson, J J}, journal = {Philos. Mag.}, number = {68}, pages = {229--249}, publisher = {Informa {{}UK{}} Limited}, title = {{On the electric and magnetic effects produced by the motion of electrified bodies}}, volume = {11}, year = {1881}, doi = {10.1080/14786448108627008}, }
4) latexdiff --packages=hyperref old.tex new.tex >diff-no-bbl.tex gives good file, which is compiled without error, but has no mark changes in references
5) The way with errors. I include bbl in tex file: 5.1) latexpand --expand-bbl old.bbl old.tex -o old-bbl.tex 5.2) latexpand --expand-bbl new.bbl new.tex -o new-bbl.tex
File old-bbl.tex
\documentclass{article} \usepackage[hidelinks]{hyperref} \begin{document} Bla-bla \cite{p1} \begin{thebibliography}{1} \expandafter\ifx\csname url\endcsname\relax \def\url#1{\texttt{#1}}\fi \expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi \expandafter\ifx\csname href\endcsname\relax \def\href#1#2{#2} \def\path#1{#1}\fi \bibitem{p1} S.~W. Hawking, G.~F.~R. Ellis, {The Large Scale Structure of Space-Time}, Cambridge University Press, 1973. \end{thebibliography} \bibliographystyle{elsarticle-num} \end{document}
File new-bbl.tex
\documentclass{article} \usepackage[hidelinks]{hyperref} \begin{document} Bla-bla \cite{p1,p2} new Bla-bla \begin{thebibliography}{1} \expandafter\ifx\csname url\endcsname\relax \def\url#1{\texttt{#1}}\fi \expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi \expandafter\ifx\csname href\endcsname\relax \def\href#1#2{#2} \def\path#1{#1}\fi \bibitem{p1} S.~W. Hawking, G.~F.~R. Ellis, {The Large Scale Structure of Space-Time}, Cambridge University Press, 1973. \bibitem{p2} J.~J. Thomson, {On the electric and magnetic effects produced by the motion of electrified bodies}, Philos. Mag. 11 (68) (1881) 229--249. \newblock \href {http://dx.doi.org/10.1080/14786448108627008} {\path{doi:10.1080/14786448108627008}}. \end{thebibliography} \bibliographystyle{elsarticle-num} \end{document}
6) Difference with references: latexdiff --packages=hyperref old-bbl.tex new-bbl.tex >diff-with-bbl.tex File diff-with-bbl.tex
\documentclass{article} %DIF LATEXDIFF DIFFERENCE FILE %DIF DEL old-bbl.tex Fri May 15 11:18:01 2020 %DIF ADD new-bbl.tex Fri May 15 11:32:32 2020 \usepackage[hidelinks]{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 \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 HYPERREF PREAMBLE %DIF PREAMBLE \providecommand{\DIFadd}[1]{\texorpdfstring{\DIFaddtex{#1}}{#1}} %DIF PREAMBLE \providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %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} Bla-bla \DIFdelbegin \DIFdel{\mbox{%DIFAUXCMD \cite{p1} }\hspace{0pt}%DIFAUXCMD }\DIFdelend \DIFaddbegin \DIFadd{\mbox{%DIFAUXCMD \cite{p1,p2} }\hspace{0pt}%DIFAUXCMD new Bla-bla }\DIFaddend \begin{thebibliography}{1} \expandafter\ifx\csname url\endcsname\relax \def\url#1{\texttt{#1}}\fi \expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi \expandafter\ifx\csname href\endcsname\relax \def\href#1#2{#2} \def\path#1{#1}\fi \bibitem{p1} S.~W. Hawking, G.~F.~R. Ellis, {The Large Scale Structure of Space-Time}, Cambridge University Press, 1973. \DIFaddbegin \bibitem{p2} \DIFadd{J.~J. Thomson, }{\DIFadd{On the electric and magnetic effects produced by the motion of electrified bodies}}\DIFadd{, Philos. Mag. 11 (68) (1881) 229--249. }\newblock \href {\DIFadd{http://dx.doi.org/10.1080/14786448108627008}} {\path{doi:10.1080/14786448108627008}}\DIFadd{. }\DIFaddend \end{thebibliography} \bibliographystyle{elsarticle-num} \end{document}
7) Compilation with pdflatex gives error
TeX capacity exceeded, sorry [input stack size=5000]. ...p://dx.doi.org/10.1080/14786448108627008}}
in line 69:
}\newblock \href {\DIFadd{http://dx.doi.org/10.1080/14786448108627008}}
If delete \DIFadd in this line, then compilation works well and show differences in references. Taking this into account I made simple string sed -i 's/\href {\DIFadd/\href {/g' diff.tex which delete \DIFadd where \href appears. But I think the problem must be solved in latefdiff itself. Could you please take your attention on this problem? In fact I use git-latexdiff, but error appears and I found this error by applying step-by-step all operators without git.
Sorry, I accidentally closed issue. I reopen now once more.
Duplicate of #178
But could you please fix this problem?
The problem is the space between \href and its argument that is being used by the citation style. This goes against the constraint defined in the latexdiff manual. You can use --allow-spaces option to work around this but it might cause some undesired side effects. As a better fix I am planning to introduce an option to apply this option only to the bibliography but it might take some time, as my work on latexdiff is only a hobby, and I am quite busy otherwise. Instead of using latexexpand you could probably do this
latexdiff old.tex new.tex > diff.tex
latexdiff --allow-spaces old.bbl new.bbl > diff.bbl
xelatex diff.tex
xelatex diff.tex
Thank you, it works.
I just verified in bitbucket, the following
git latexdiff -t CFONT HEAD~1 --allow-space --bibtex --main proba.tex
is working without problem with adding and deleting references. In fact the key --allow-space solves the problem.
Should be fixed now.
I use package hyperref. Then made "latexdiff --packages=hyperref --no-links old.tex new.tex >diff.tex" and then the compiling diff.tex gives error "TeX capacity exceeded, sorry [input stack size=5000]. ...add{http://dx.doi.org/10.1007/bf02959697}}". The error appears where \href and \DIFadd appears together.