3

I'm having trouble getting latexdiff to work when using the biblatex citation commands \parencite and \textcite.

Take old.tex:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@article{greenwade93,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1993",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}
\begin{document}

\textcite{greenwade93} is the best article on \LaTeX \parencite{goossens93}.

\printbibliography

\end{document}

and new.tex:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@article{greenwade93,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1993",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}
\begin{document}

\textcite{goossens93} is the best book on \LaTeX \parencite{greenwade93}.

\printbibliography

\end{document}

Running latexdiff old.tex new.tex > diff.tex gives:

\documentclass[a4paper]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL old.tex   Sun Jul 26 18:28:46 2020
%DIF ADD new.tex   Sun Jul 26 18:28:55 2020
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@article{greenwade93,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1993",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}
%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
%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 END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}

\textcite{\DIFdelbegin \DIFdel{greenwade93}\DIFdelend \DIFaddbegin \DIFadd{goossens93}\DIFaddend } is the best \DIFdelbegin \DIFdel{article }\DIFdelend \DIFaddbegin \DIFadd{book }\DIFaddend on \LaTeX \DIFdelbegin %DIFDELCMD < \parencite{goossens93}%%%
\DIFdelend \DIFaddbegin \parencite{greenwade93}\DIFaddend .

\printbibliography

\end{document}

which, when compiled with pdflatex yields:

enter image description here

The problem is that latexdiff puts the markup commands within the \textcite command, which obvious doesn't work. Adding natbib=true to the biblatex options and changing \textcite to \citet and \parencite to \citep gives the correct output: enter image description here

The documentation (section 4) says:

The following packages trigger special behaviour:
...
apacite, biblatex
Redefine the commands recognised as citation commands.

Is this a bug in latexdiff or am I missing something?

I'd be happy to use the natbib commands instead, but I am using the code from this answer to to include the author name in the hyperlink.

EDIT: turns out that the code from moewe to include the author(s) in the citation links works perfectly fine when using the natbib command instead of the standard biblatex ones. I have no idea how that works, but it solves my immediate problem.

  • Either latexdiff does not detect biblatex correctly or it detects it correctly, but does not handle its commands correctly. In either case I'd say this is a bug or limitation of biblatex. I suggest you contact the author about this. – moewe Jul 26 at 19:41
  • @moewe I guess you meant to write it is a bug in latexdiff. Indeed it is; or better was - I just fixed it on the github repository. So the answer is either use the master from github repository of latexdiff or wait for the next release. – frederik Jul 27 at 16:34
  • @frederik Oh yeah, absolutely. Muscle memory: I type biblatex way too often. Sorry for the confusion. Thanks for catching that. – moewe Jul 27 at 18:04
1

You can add the option --exclude-textcmd=textcite to force latexdiff to treat the \textcite command correctly (from latexdiff v1.3.2 this behaviour will be the default if biblatex package is used)

| improve this answer | |
  • After making my post I tried this but with textcite in quotes. Is that not the correct syntax? Because that didn't work. – avs Jul 27 at 17:21
  • I would have expected to have worked with the quotes also. I just tried this, and the result seems to be the same. Maybe there is some dependence on the operating system or shell – frederik Jul 27 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.