5

I am looking for a way to force biblatex to strip all first names except the very first one. I am actually using only initials, but even that gets messy when the author has 3-4 first names in a row and is known only by the first one.

Say I am citing this guy:

John Paul Peter Julian Doe

the output will be:

J. P. D. J. Doe

which is already quite long. Removing the dots and thin-spaces is not really an option. I would like it to just end up being J. Doe for the in-text (cbx) part of the reference.

Based on this related question, I suppose it is possible with biblatex+biber and it is the solution I would favour.

  • 1
    Somewhat related: tex.stackexchange.com/questions/126061/… – Christoph Mar 3 '14 at 21:28
  • 1
    A very dirty (and not really advisable) solution might be {{John Paul Peter Julian} Doe}, but that will not work if you want all initials in the bibliography and only "J. Doe" in citations. – moewe Mar 4 '14 at 18:22
  • @Christoph Thank you, I see how this may work for me, but I need to take a look at the code and see if I can work something out. – ienissei Mar 4 '14 at 23:18
  • @moewe Yes, that's an idea, but as you say, it is not very advisable… especially with a very large database. As much as possible, I would like not to impose a specific format for the .bib file. – ienissei Mar 4 '14 at 23:19
4

This can be solved by creating a new name format that formats the first name(s) as just the very first initial:

% Format for VeryFirstInitial - LastName
\DeclareNameFormat{firstfirstinit-last}{%
\usebibmacro{name:first-last}{#1}{\firstinit{#4}\adddot}{#5}{#7}%
\usebibmacro{name:andothers}}

To do this, I use a custom macro that identifies just the very first initial of the first names (courtesy of @StevenBSegletes, Typeset just the first letter in a group):

% Helper function to get initial letter
\def\firstinit#1{\justfirst#1\relax}
\def\justfirst#1#2\relax{#1}

Then biblatex is set to use first initials in the bibliography and just the very first initial in in-text citations:

% Set format for sortname (bibliography) and labelname (citation)
\DeclareNameAlias{sortname}{firstinits-last}
\DeclareNameAlias{labelname}{firstfirstinit-last}

The Result

example

MWE

\documentclass[]{article}

\usepackage{filecontents}
\begin{filecontents*}{bib.bib}
@article{jdoe,
    author       = {John Paul Peter Julian Doe},
    journal  = {Journal},
    title        = {Title},
    year      = 2014,
    pages = 111--222,
}
\end{filecontents*}

\usepackage[style=authoryear]{biblatex}
\addbibresource{bib.bib}

% Helper function to get initial letter
\def\firstinit#1{\justfirst#1\relax}
\def\justfirst#1#2\relax{#1}

% Format for FirstInitials - LastName (standard implementation)
\DeclareNameFormat{firstinits-last}{%
\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}%
\usebibmacro{name:andothers}}

% Format for VeryFirstInitial - LastName
\DeclareNameFormat{firstfirstinit-last}{%
\usebibmacro{name:first-last}{#1}{\firstinit{#4}\adddot}{#5}{#7}%
\usebibmacro{name:andothers}}

% Set format for sortname (bibliography) and labelname (citation)
\DeclareNameAlias{sortname}{firstinits-last}
\DeclareNameAlias{labelname}{firstfirstinit-last}

\begin{document}

\noindent Citation: \cite{jdoe}.

\printbibliography[]

\end{document}
  • 1
    +1 But there's a problem. If uniquename=true and you have two (different) J Does. For instance, if you added a 2014 work by "J Q Doe", biblatex would think it was printing citations to "JQ Doe" and "JPPJ Doe" and would not add alphabetics to the year, but your citations would both be "J Doe (2014)". So if you do this you must set uniquename=false. But that causes problems because it now means that you will get alphabetics added even where the first initial does sufficiently disambiguate. To do this really robustly it probably needs to be done at the biber level. – Paul Stanley Mar 20 '14 at 9:21
  • @PaulStanley Yes, your point is right. Thankfully for me, the style we use is derived from author-title, so there is no such need. But it is good to have it noted for other users. – ienissei Mar 20 '14 at 10:40
  • 1
    I can get your MWE to work just fine, but it gives me errors whenever I try to implement it in my file (Argument of \justfirst has an extra}). I am using XeLaTeX and accented characters which perhaps don't read well. Perhaps this comes from the way the helper macros are written, do you think there could way to make them more robust? – ienissei Mar 20 '14 at 12:59
  • @ienissei Can you post an example of the type of name that causes you problems? – cslstr Mar 20 '14 at 13:27
  • @cslstr I will provide you with a MWE as soon as I have time to work on one. Thank you for your reply in any event. – ienissei Mar 21 '14 at 17:20

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.