TransWikia.com

Change author font for specific cite command

TeX - LaTeX Asked by petobens on March 21, 2021

Consider the following MWE

documentclass{article}
usepackage[style=authoryear-comp,backend=biber]{biblatex}
addbibresource{biblatex-examples.bib}
AtBeginDocument{%
  renewcommand*{mkbibnamelast}[1]{textsc{#1}}
}

begin{document}
textcite{knuth:ct:e}
fullcite{salam}
Footcitefootfullcite{baez/article}
printbibliography
end{document}

This will print author surnames in small caps for all cite command both in the document and in the bibliography. Just for the textcite command I want the surname (i.e Knuth in the example) to be printed in the text in regular font rather than in small caps.

EDIT: As of March 2016 (biblatex 3.3), you need to change mkbibnamefamily instead of mkbibnamelast

3 Answers

A possible solution is to introduce a toggle to determine whether we are in a text cite or not. Then the modification of mkbibnamelast is parametrised to the toggle. This solution uses the xpatch package to modify the textcite bibmacro, to set the toggle to true just before executing the textcite macro and to false right after the textcite macro has been executed.

newtoggle{textcite}

AtBeginDocument{
  renewcommand*{mkbibnamelast}[1]{%
    iftoggle{textcite}{#1}{textsc{#1}}}
}

xpretobibmacro{textcite}{toggletrue{textcite}}{}{}
xapptobibmacro{textcite}{togglefalse{textcite}}{}{}

enter image description here

Correct answer by Guido on March 21, 2021

documentclass{article}
usepackage[style=authoryear-comp,backend=biber]{biblatex}
addbibresource{biblatex-examples.bib}
AtBeginDocument{%
  renewcommand*mkbibnamelast[1]{textsc{#1}}}
letTCtextcite
renewcommandtextcite[1]{{defmkbibnamelast##1{##1}TC{#1}}}% hold it local
%% If you need the optional argument of textcite then we have to modify
%% the macro    

begin{document}
textcite{knuth:ct:e}
fullcite{salam}
Footcitefootfullcite{baez/article}
printbibliography
end{document}

enter image description here

Answered by user2478 on March 21, 2021

With more recent versions of biblatex we can use an approach similar to Guido's answer, but instead of patching citation commands to set a flag we test for the delimiter context.

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

makeatletter
renewcommand*{mkbibnamefamily}{%
  ifcsundef{mkbibnamefamily@blx@delimcontext}
    {textsc}
    {csuse{mkbibnamefamily@blx@delimcontext}}}

newcommand*{mkbibnamefamily@textcite}[1]{#1}
makeatother


begin{document}
textcite{knuth:ct:e}

fullcite{salam}

Footcitefootfullcite{sigfridsson}

printbibliography
end{document}

"Knuth (1986)" no small caps//"Abdus Salam (1968)." "Salam" in small caps

Answered by moewe on March 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP