2

I use Biblatex with the authoryear-icomp citation style. The \textcite{ref} command prints out Lastname (year) ie Groenig (2000) but I want it to give me Firstname Lastname (year) ie Peter Groenig (2000).

As you can see, this customization does not only involve formatting but also retrieving new informations from the .bib file. I want all others citation commands, such as \parencite, to keep their original behaviour.

How can I do this ?

3

With authoryear-icomp we need to modify the bibmacro textcite to use the name format first-last instead of the labelname format, we can do this either by redefining the entire macro

\makeatletter
\renewbibmacro*{textcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\setunit{\addcomma}%
           \usebibmacro{cite:extrayear}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labelyear+extrayear}%
           \savefield{labelyear}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\ifnameundef{labelname}
       {\iffieldundef{shorthand}
          {\usebibmacro{cite:label}%
           \setunit{%
             \global\booltrue{cbx:parens}%
             \addspace\bibopenparen}%
           \ifnumequal{\value{citecount}}{1}
             {\usebibmacro{prenote}}
             {}%
           \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
             {\usebibmacro{cite:ibid}}
             {\usebibmacro{cite:labelyear+extrayear}}}
          {\usebibmacro{cite:shorthand}}}
       {\printnames[first-last]{labelname}%<----- this is the modification
        \setunit{%
          \global\booltrue{cbx:parens}%
          \addspace\bibopenparen}%
        \ifnumequal{\value{citecount}}{1}
          {\usebibmacro{prenote}}
          {}%
        \iffieldundef{shorthand}
          {\iffieldundef{labelyear}
             {\usebibmacro{cite:label}}
             {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
                {\usebibmacro{cite:ibid}}
                {\usebibmacro{cite:labelyear+extrayear}}}%
           \savefield{labelyear}{\cbx@lastyear}}
          {\usebibmacro{cite:shorthand}%
           \global\undef\cbx@lastyear}}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}}
\makeatother

Or using the xpatch package as follows

\xpatchbibmacro{textcite}
  {\printnames{labelname}}
  {\printnames[first-last]{labelname}}
  {}
  {}

MWE (using xpatch)

\documentclass{article}  
\usepackage[style=authoryear-icomp,backend=biber]{biblatex}  
\addbibresource{biblatex-examples.bib}

\usepackage{xpatch}
\xpatchbibmacro{textcite}
  {\printnames{labelname}}
  {\printnames[first-last]{labelname}}
  {}
  {}

\begin{document}
Lorem \textcite{geer} ipsum \textcite{worman} dolor \textcite{sigfridsson}.

Lorem \cite{geer} ipsum \cite{worman} dolor \cite{sigfridsson}.

\printbibliography
\end{document}

enter image description here

This modification cannot be adopted wholesale to all other styles, because \textcite unlike other commands is implemented using a variety of different ways. The basic idea of making the \printnames{labelname} directive use the first-last name format, however, should almost always be the right one.

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.