TransWikia.com

How to only use last name with textcite although uniquename setting requires full name?

TeX - LaTeX Asked on December 27, 2021

I am currently working on a document that cites a large number of Chinese authors. As there are many authors that share the same last name, I decided to use the setting uniquename=minfull, and to avoid these names being abbreviated to, for instance, W. Wang, added a bit of code that results in the full name being given.

This works as intended for citations in brackets. However, I just noticed that it does not work as well in cases of textcite, where it results in a comma between the last and first name (see output of MWE):

According to Wang, Xiuying (2020)…

For Chinese names, it would work to simply omit the comma between the last and the first name (as the name would usually be given as Wang Xiuying, so I also want to avoid the output Xiuying Wang), but this would of course also affect other names and is therefore not an option.

What I think could work is to have the first name omitted only for the textcite command (in effect ignoring the uniquenamesetting in this case) as I could ensure that it is clear from the context which author is referred to.

I am not quite sure how to approach this. Would it make sense to create a new command textcitelast so I can manually control where I only use the last name? I am grateful for your suggestions!

documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}

usepackage[style=authoryear-icomp,
  ibidpage=true,
  ibidtracker=constrict,
  idemtracker=context,
  mergedate=basic, 
  uniquename=minfull, 
  bibstyle=authoryear,
  backend=biber
  ]
 {biblatex}


% I wanted to avoid Chinese names being abbreviated to `W. Zhang', etc., so this bit forces it to use the full name
DeclareNameFormat{labelname}{%
  ifnumequal{value{uniquename}}{0}
    {usebibmacro{name:family}
       {namepartfamily}
       {namepartgiven}
       {namepartprefix}
       {namepartsuffix}}
    {usebibmacro{name:family-given}
       {namepartfamily}
       {namepartgiven}
       {namepartprefix}
       {namepartsuffix}}
  usebibmacro{name:andothers}}

usepackage{filecontents}

begin{filecontents*}{testbib.bib}

@online{test1,
  author = {Zhang, Xiuying},
  title = {Test title},
  year = {2020}
}

@online{test2,
  author = {Wang, Xiuying},
  title = {Another test title},
  year = {2020}
}

@online{test3,
  author = {Zhang, Wei},
  title = {Test title three},
  year = {2020}
}

@online{test4,
  author = {Wang, Wei},
  title = {Test title four},
  year = {2020}
}

end{filecontents*}

addbibresource{testbib.bib}


begin{document}

Citation number one autocite{test1}, another citation autocite{test2} and yet another one autocites{test3,test4}.

As textcite{test1} argued ldots According to textcite{test2} ldots

end{document}

One Answer

Of course it is possible to write a name format that ignores uniquename data and only shows the family name (see DeclareNameFormat{family}{...} below). It is also easy to locally change the labelname format to this new format (with DeclareNameAlias{labelname}{family}). You just need a good way to hook into textcite to change the name format.

To keep the code short I decided to go via cbx@textcite, but the most elegant (shortest/quickest/natural/...) way will depend on the style you use and your taste. This bit of the answer was specifically written for authoryear-icomp it may not work with other styles.

documentclass{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}

usepackage[backend=biber,
  style=authoryear-icomp,
  uniquename=minfull,
  mergedate=basic,
  ibidtracker=constrict,
  idemtracker=context,
  ibidpage=true,
]{biblatex}

DeclareNameFormat{labelname}{%
  ifnumequal{value{uniquename}}{0}
    {usebibmacro{name:family}
       {namepartfamily}
       {namepartgiven}
       {namepartprefix}
       {namepartsuffix}}
    {usebibmacro{name:family-given}
       {namepartfamily}
       {namepartgiven}
       {namepartprefix}
       {namepartsuffix}}%
  usebibmacro{name:andothers}}

makeatletter
DeclareCiteCommand{cbx@textcite}
  {usebibmacro{cite:init}}
  {usebibmacro{citeindex}%
   DeclareNameAlias{labelname}{family}%
   usebibmacro{textcite}}
  {}
  {usebibmacro{textcite:postnote}}
makeatother

DeclareNameFormat{family}{%
  usebibmacro{name:family}
    {namepartfamily}
    {namepartgiven}
    {namepartprefix}
    {namepartsuffix}%
  usebibmacro{name:andothers}}

begin{filecontents*}{jobname.bib}
@online{test1,
  author = {Zhang, Xiuying},
  title = {Test title},
  year = {2020}
}
@online{test2,
  author = {Wang, Xiuying},
  title = {Another test title},
  year = {2020}
}
@online{test3,
  author = {Zhang, Wei},
  title = {Test title three},
  year = {2020}
}
@online{test4,
  author = {Wang, Wei},
  title = {Test title four},
  year = {2020}
}
end{filecontents*}
addbibresource{jobname.bib}

begin{document}

Citation number one autocite{test1}, another citation autocite{test2} and yet another one autocites{test3,test4}.

As textcite{test1} argued ldots According to textcite{test2} ldots


printbibliography
end{document}

As Zhang (2020) argued ... According to Wang (2020) ...


If you are interested in a solution to get non-western names to show up nicely without these kinds of workarounds (but by employing a much more complex machinery with an arguably more clumsy input syntax on the .bib side), you may want to have a look at CJK Bibliography Problem, Biblatex-Chicago author-date style (and the linked questions). In case you would like to get this going in your document, but are having trouble to port the code from that answer to your setup, feel free to ask a new question about that.

Answered by moewe on December 27, 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