4

Imagine Troy McClure wrote a book and his surname funnily enough now appears abbreviated in a biblatex+biber bibliography. The output of this is "M., Troy", but imho should better be "McC., Troy".

Question

How can I make biblatex detect prefixes like this (or at least this particular one) and get the correct abbreviated surname?

MWE

\documentclass{article}
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{bib.bib}
@book{mcd,
    author={McClure, Troy},
    title={Abbreviating My Surname In Biblatex Doesn't Work Well}}
\end{filecontents}
\addbibresource{bib.bib}
\DeclareNameFormat{author}{%
  \usebibmacro{name:last-first}{#2}{#3}{#5}{#7}}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

Output

output

Should be "McC., Troy. (…)".

PS: For biblatex 3.3 the \DeclareNameFormat command should be (untested):

\DeclareNameFormat{author}{\nameparts{#1}%
\usebibmacro{name:given-family}{\namepartfamilyi}{\namepartgiven}{\namepartpre‌​fix}{\namepartsuffix}}
  • 1
    Your code doesn't compile: On the line \usebibmacro{name:last-first}{#2}{#3}{#5}{#7}}, I get an "Illegal parameter number in definition of \blx@defformat@d." message. – Mico Apr 7 '16 at 17:11
  • i'm not a biblatex user, but in bibtex, i would expect that {McC}lure would do what you want. – barbara beeton Apr 7 '16 at 17:14
  • 4
    I'd be very surprised to get, from McClure, Troy the author's name printed as “M. Troy”, but rather “T. McClure”. Please, explain. – egreg Apr 7 '16 at 17:38
  • 3
    It makes no sense, in my opinion. Since when authors are identified by given name? – egreg Apr 7 '16 at 17:49
  • 2
    It makes no sense either. Before the colon you have the identifier used in the document, after it the essential data for specifying the reference. – egreg Apr 7 '16 at 17:58
4

Changing the author field to

author={{\relax McC}lure, Troy},

lets you achieve your objective, viz., make the surname show up as McC.

The full MWE (used with biblatex v. 3.3) -- note that I had to remove {\namepartpre‌​fix}:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{bib.bib}
@book{mcd,
    author={{\relax McC}lure, Troy},
    title={Abbreviating My Surname \dots},
}
\end{filecontents}

\usepackage{biblatex}
\addbibresource{bib.bib}
\DeclareNameFormat{author}{\nameparts{#1}%
   \usebibmacro{name:given-family}{\namepartfamilyi}{\namepartgiven}{\namepartsuffix}}

\begin{document}
\nocite{*}
\printbibliography
\end{document}
  • Under certain circumstances this produces an unwanted extra space before the last name, this can be resolved using {\relax{}McC}lure. – dessert Apr 7 '16 at 18:11
  • @dessert - Please be a bit more specific as to what the "certain circumstances" may entail. TeX should be eating up the space after \relax. If that's not the case, something odd may be going on. – Mico Apr 7 '16 at 18:22
  • 1
    Sorry about that. The identifier used in the document in authoryear style is rendered as " McClure 2016" with the space. You can check that using this style and citing the book with e.g. \parencite{mcd}. – dessert Apr 8 '16 at 6:39
  • @dessert - Many thanks for providing this specific example. – Mico Apr 8 '16 at 8:30
  • Nevertheless I accept your answer, as \relax is the right thing to do. Thanks again for your patience, especially with the \DeclareNameFormat struggle! – dessert Apr 9 '16 at 8:19

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.