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}}
19
  • 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
    Commented Apr 7, 2016 at 17:11
  • i'm not a biblatex user, but in bibtex, i would expect that {McC}lure would do what you want. Commented Apr 7, 2016 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
    Commented Apr 7, 2016 at 17:38
  • 3
    It makes no sense, in my opinion. Since when authors are identified by given name?
    – egreg
    Commented Apr 7, 2016 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
    Commented Apr 7, 2016 at 17:58

1 Answer 1

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}
5
  • Under certain circumstances this produces an unwanted extra space before the last name, this can be resolved using {\relax{}McC}lure.
    – dessert
    Commented Apr 7, 2016 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
    Commented Apr 7, 2016 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
    Commented Apr 8, 2016 at 6:39
  • @dessert - Many thanks for providing this specific example.
    – Mico
    Commented Apr 8, 2016 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
    Commented Apr 9, 2016 at 8:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .