[Tex/LaTex] Have Biblatex display only the first of first names for an author

biberbiblatex

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.

Best Answer

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}
Related Question