0

I want to cite two articles from the same author using biblatex with citation style biblatex-aer (https://github.com/dmsul/biblatex-aer). However, when I use \textcite{key1,key2}, I get e.g.

Gurley and Shaw (1955), 1966

instead of

Gurley and Shaw (1955, 1966)

Going into the code from biblatex-aer, it boils down to this code snippet:

\renewbibmacro*{textcite}{%
  \ifboolexpr{
    ( not test {\iffieldundef{prenote}} and
      test {\ifnumequal{\value{citecount}}{1}} )
    or
    ( not test {\iffieldundef{postnote}} and
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
  }
    {\DeclareFieldAlias{textcitehyperref}{noformat}}
    {}%
  \printtext[textcitehyperref]{%
    \restorebibmacro{textcite}%
    \usebibmacro{textcite}}}

If I delete these lines, I receive the correct citation, however, hyperref does not color the whole name anymore rather only the year of publication.

Do you know how to fix this?

1

The code used in https://github.com/dmsul/biblatex-aer/blob/master/biblatex-aer.tex to get full links in citations was taken from Audrey's answer to hyperlink name with biblatex authoryear (biblatex 1.4b). That answer was written with style=authoryear, in mind (it also works for some other styles), but biblatex-aer is based upon biblatex-chicago's authordate style, which is more similar to the much more complex style=authoryear-comp, (in addition biblatex-chicago itself is also very complex).

This means you need a different strategy for the links. The following variation is inspired by Audrey's code in hyperlink name with biblatex authoryear (biblatex 1.4b) and by my answer to How to change the color of first half of parenthesis in citation?.

I also updated the code for bold names in biblatex-aer.tex so that the following preamble completely replaces biblatex-aer.tex from https://github.com/dmsul/biblatex-aer/blob/master/biblatex-aer.tex.

\documentclass[american]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[authordate, backend=biber, uniquename=false, noibid]{biblatex-chicago}
\usepackage[colorlinks]{hyperref}

\makeatletter
\newrobustcmd{\blx@imc@transparentprinttext}[2][]{%
  \ifblank{#2}
    {}
    {\ifblank{#1}
       {\let\blx@theformat\@firstofone}
       {\blx@getformat\blx@theformat{ffd}{#1}{}}%
     \ifdefvoid\blx@theformat
       {}
       {\blx@theformat{#2}}}}

\newcommand*{\blx@imc@iffieldequalstr@swap}[2]{\iffieldequalstr{#2}{#1}}

\newcommand*{\blx@imc@iffieldequalsdefstring}[2]{%
  \expandafter\blx@imc@iffieldequalstr@swap\expandafter{#2}{#1}}

\blx@regimcs{\transparentprinttext \iffieldequalsdefstring}
\makeatother

\DeclareFieldFormat{citehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}%
  \bibhyperref{#1}}

\letbibmacro{orig:cite}{cite}

\renewbibmacro*{cite}{%
  \transparentprinttext[citehyperref]{%
    \usebibmacro{orig:cite}}}

\letbibmacro{orig:textcite}{textcite}
\letbibmacro{orig:textcite:postnote}{textcite:postnote}

\renewbibmacro*{textcite:postnote}{}

\renewbibmacro*{textcite}{%
  \transparentprinttext[citehyperref]{%
    \usebibmacro{orig:textcite}%
    \ifnumequal{\value{citecount}}{\value{citetotal}}
      {\usebibmacro{orig:textcite:postnote}}
      {}%
  }%
}

\newcommand\ifmknamebold{%
  \ifboolexpr{test {\ifcurrentname{labelname}}
              or
              test {\iffieldequalsdefstring{labelnamesource}{\currentname}}}}

\DeclareNameWrapperFormat{default}{\ifmknamebold{\mkbibbold{#1}}{#1}}
\DeclareNameWrapperFormat{labelname}{#1}


\addbibresource{biblatex-examples.bib}


\begin{document}
\textcite{knuth:ct:a,knuth:ct:b}

\cite{sigfridsson,gaonkar:in,westfahl:space,westfahl:frontier,companion}

\printbibliography
\end{document}

Fully linked citations and bits of the bibliography (with bold labelnames/sortnames).

| improve this answer | |

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.