TransWikia.com

Only use first of double surnames in biblabel with biblatex

TeX - LaTeX Asked by thewaywewalk on June 10, 2021

I have the following bibliography setup

documentclass[ngerman]{article}

usepackage{babel}
usepackage{csquotes}
usepackage{filecontents}

usepackage[backend=biber,
            style=ieee-alphabetic,
            maxnames=99,
            maxcitenames=2,
            minalphanames=1, maxalphanames=1,
            giveninits=true,
            useprefix=false,
            doi=false, isbn=false, url=false,
            backref=false,
            dashed=false,
            ]{biblatex}
renewcommand*{labelalphaothers}{}


DeclareLabelalphaTemplate{
  labelelement{
    field[final]{shorthand}
    field{label}
    field{labelname}
  }
  labelelement{
    field{year}
  }
}

begin{filecontents}{jobname.bib}
@article{Garcia1984,
  author  = {García Lopéz, Frank and Orwell, George},
  title   = {1984},
  year    = {1948},
  journal = {Books About Big Brothers},
  volume  = {5},
  number  = {42},
  pages   = {100--111},
}
end{filecontents}
addbibresource{jobname.bib}
begin{document}

cite{Garcia1984}.
printbibliography
end{document}

With the following output:

enter image description here

Do you see any possibility to only show the first of the two surnames of the first author in the biblabel, so it is [García1984]? I could live with only the second name, if that would be easier, but knowing Spanish/Latin American people and how they use their names, I think the former is the preferable choice.

In the bibliography entry the name should remain as it is, so F. G. Lopéz or F. García L. are no options.

Thanks in advance!

2 Answers

One way to force a particular name for the label is to use the shortauthor field.

documentclass[ngerman]{article}
usepackage{babel}
usepackage{csquotes}

usepackage[
  backend=biber,
  style=ieee-alphabetic,
  maxnames=99, maxcitenames=2, minalphanames=1, maxalphanames=1,
  giveninits=true, useprefix=false,
  doi=false, isbn=false, url=false,
  dashed=false,
]{biblatex}

renewcommand*{labelalphaothers}{}

DeclareLabelalphaTemplate{
  labelelement{
    field[final]{shorthand}
    field{label}
    field{labelname}
  }
  labelelement{
    field{year}
  }
}

begin{filecontents}{jobname.bib}
@article{Garcia1984,
  author       = {García Lopéz, Frank and Orwell, George},
  shortauthor  = {García, Frank and Orwell, George},
  title        = {1984},
  year         = {1948},
  journal      = {Books About Big Brothers},
  volume       = {5},
  number       = {42},
  pages        = {100--111},
}
end{filecontents}
addbibresource{jobname.bib}
begin{document}

cite{Garcia1984}.
printbibliography
end{document}

[García1948].

Another much more complicated option would be to try and extend the name format to include two family names of which only one is used for citation labels. One would probably approach this similar to Bibtex/Biber: how to cite an author using Ethiopian conventions?, Bibliography according to icelandic system or Specifying author pseudonyms in BibLaTeX.

Correct answer by moewe on June 10, 2021

Another way is to postprocess the label, for example if you use a bibliography that you cannot change.

You have to put a separator between the name and the year so that the postprocessing macro can split it there, and then split off the part after the space.

documentclass[ngerman]{article}

usepackage{babel}
usepackage{csquotes}
usepackage{filecontents}

usepackage[backend=biber,
            style=ieee-alphabetic,
            maxnames=99,
            maxcitenames=2,
            minalphanames=1, maxalphanames=1,
            giveninits=true,
            useprefix=false,
            doi=false, isbn=false, url=false,
            backref=false,
            dashed=false,
            ]{biblatex}
renewcommand*{labelalphaothers}{}

letMYSEPrelax
DeclareLabelalphaTemplate{
  labelelement{
    field[final]{shorthand}
    field{label}
    field{labelname}
  }
  labelelement{literal{MYSEP}} % <<=======
  labelelement{
    field{year}
  }
}

DeclareFieldFormat{labelalpha}{expandafterextractfirsta#1MYSEP}

defextractfirsta#1MYSEP#2MYSEP{extractfirstb#1 MYSEP{#2}}
defextractfirstb#1 #2MYSEP#3{#1#3}

begin{filecontents}{jobname.bib}
@article{Garcia1984,
  author  = {García Lopéz, Frank and Orwell, George},
  title   = {1984},
  year    = {1948},
  journal = {Books About Big Brothers},
  volume  = {5},
  number  = {42},
  pages   = {100--111},
}
end{filecontents}
addbibresource{jobname.bib}
begin{document}

cite{Garcia1984}.
printbibliography
end{document}

enter image description here

Answered by Pieter van Oostrum on June 10, 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