As biblatex
does not distinguish multiple first names, we need to split this list ourselves:
\makeatletter
\def\@empty{}
\def\first#1{\expandafter\@first#1 \@nil}
\def\@first#1 #2\@nil{#1\addspace%
\if\relax\detokenize{#2}\relax\else\@initials#2\@nil\fi}
\def\initials#1{\expandafter\@initials#1 \@nil}
\def\@initials#1 #2\@nil{%
\initial{#1}%
\def\NextName{#2}%
\ifx\@empty\NextName\relax%
\else\@initials#2\@nil\fi}
\def\initial#1{\expandafter\@initial#1\@nil}
\def\@initial#1#2\@nil{#1.\addspace}
\makeatother
Now calling \first{John Arthur Kyle}
yields "John A. K.".
The trick used is that the macro \first
passes its argument to \@first
which in turn delimits its arguments by spaces, i.e. #1
is "John" and #2
is "Arthur Kyle". This gets sent to \@initials
which goes through the list of names (in case there are more or less than two) and calls \initial
with each name. \initial
in turn calls \@initial
which throws away all but the first letter and adds a dot and a space.
Now we can use this in \DeclareNameFormat
:
\def\bibnamedelima{ }%
\def\bibnamedelimb{ }%
\DeclareNameFormat{author}{%
\ifblank{#5}{}{#5\addspace}% prefix if applicable
#1% last name
\edef\firstname{#3}%
\ifblank{#3}{}{\addcomma\addspace\expandafter\first{\firstname}}%
\ifthenelse{\value{listcount}<\value{liststop}}%
{\addslash}{}%
}
Note that for author = {Doe, John Arthur Kyle}
in the bib
file, #3
actually consists of John\bibnamedelimb Arthur\bibnamedelima Kyle
, so we need to eliminate these for the \first
macro to work.
EDIT: a "proper" NameFormat
should include deliminators for multiple names, thus we check if we are in the middle of a list of names and if so print a slash.
Additionally, the authoryear
style uses labelname
to display the author name in citations, so that format should be changed to keep the formatting of the citation in line with that of the bibliography entry:
\DeclareNameFormat{labelname}{%
\ifblank{#5}{}{#5\addspace}% prefix if applicable
#1% last name
\edef\firstname{#3}%
\ifblank{#3}{}{\addcomma\addspace\expandafter\first{\firstname}}%
\ifthenelse{\value{listcount}<\value{liststop}}%
{\addslash}{}%
}
To summarize: This code
\documentclass{scrartcl}
\usepackage[backend=biber,style=authoryear]{biblatex}
\bibliography{bibliography}
\usepackage[T1]{fontenc}
\def\bibnamedelima{ }%
\def\bibnamedelimb{ }%
\DeclareNameFormat{author}{%
\ifblank{#5}{}{#5\addspace}% prefix if applicable
#1% last name
\edef\firstname{#3}%
\ifblank{#3}{}{\addcomma\addspace\expandafter\first{\firstname}}%
\ifthenelse{\value{listcount}<\value{liststop}}%
{\addslash}{}%
}
\DeclareNameFormat{labelname}{%
\ifblank{#5}{}{#5\addspace}% prefix if applicable
#1% last name
\edef\firstname{#3}%
\ifblank{#3}{}{\addcomma\addspace\expandafter\first{\firstname}}%
\ifthenelse{\value{listcount}<\value{liststop}}%
{\addslash}{}%
}
\makeatletter
\def\@empty{}
\def\first#1{\expandafter\@first#1 \@nil}
\def\@first#1 #2\@nil{#1\addspace%
\if\relax\detokenize{#2}\relax\else\@initials#2\@nil\fi}
\def\initials#1{\expandafter\@initials#1 \@nil}
\def\@initials#1 #2\@nil{%
\initial{#1}%
\def\NextName{#2}%
\ifx\@empty\NextName\relax%
\else\@initials#2\@nil\fi}
\def\initial#1{\expandafter\@initial#1\@nil}
\def\@initial#1#2\@nil{#1.\addspace}
\makeatother
\begin{document}
\cite[123]{Doe}\par
\cite[124]{Doe2}\par
\cite[125]{vD}
\printbibliography
\end{document}
together with this bib
file:
@book{Doe,
title = {The secret life of John Doe},
author = {Doe, John Arthur Kyle and Jane Emma Dane and Someone Else},
year = {2013}
}
@book{Doe2,
title = {The secret life of John Doe 2},
author = {Doe, John},
year = {2013}
}
@book{vD,
title = {The secret life of John von Doe},
author = {John Arthur Kyle von Doe},
year = {2013}
}
produces this output:
EDIT: For more details on splitting strings, see e.g. the answers to this question; for information on macros using "strange" argument delimiters, see e.g. this thread.
Shameless plug: The styles of the biblatex-ext
bundle have a slightly more sophisticated version of this implemented as an option. Load ext-<standardstyle>
, e.g. ext-authoryear-comp
and set the option innamebeforetitle
to true
.
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,
style=ext-authoryear, innamebeforetitle=true]{biblatex}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareDelimFormat{editortypedelim}{\addspace}
\DeclareFieldAlias{translatortype}{editortype}
\DeclareDelimAlias{translatortypedelim}{editortypedelim}
\addbibresource{biblatex-examples.bib}
\begin{document}
\cite{sigfridsson,gaonkar:in,westfahl:space,vizedom:related}
\printbibliography
\end{document}
This is really where biblatex
is not that flexible.
We can use xpatch
to patch the drivers for @inbook
, @incollection
and @inproceedings
\xpatchbibdriver{inbook}
{\usebibmacro{in:}%
\usebibmacro{bybookauthor}%
\newunit\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{bybookauthor}%
\newunit\newblock
\usebibmacro{byeditor:in}%
\newunit\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{}{}
\xpatchbibdriver{incollection}
{\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{byeditor:in}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor}}
{}{}
\xpatchbibdriver{inproceedings}
{\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{event+venue+date}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{byeditor:in}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{event+venue+date}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{}{}
We also redefine byeditor:in
\newbibmacro*{byeditor:in}{%
\ifnameundef{editor}
{}
{\printnames[editorin]{editor}%
\addspace\bibsentence%
\mkbibparens{\usebibmacro{editorstrg}}%
\clearname{editor}%
\printunit{\addcomma\space}}}
and a new name format
\DeclareNameAlias{editorin}{first-last}
MWE
\documentclass{article}
\usepackage{xpatch}
\usepackage[style = authoryear-comp, maxnames = 99]{biblatex}
\renewcommand*{\finalnamedelim}{\addspace\&\space}
\renewcommand*{\intitlepunct}{\space}
\DeclareFieldFormat[article, incollection, unpublished]{pages}{#1}
\DeclareFieldFormat[article, incollection, unpublished]{title}{#1}
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@incollection{lennon1965,
author = {John Lennon},
booktitle = {A book with articles},
editor = {Paul McCartney and John Lennon and George Harrison and Richard Starkey},
title = {This is my article in this book},
year = {1965},
location = {Liverpool},
pages = {65--87},
publisher = {Cavern Club},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\DeclareNameAlias{editorin}{first-last}
\newbibmacro*{byeditor:in}{%
\ifnameundef{editor}
{}
{\printnames[editorin]{editor}%
\addspace\bibsentence%
\mkbibparens{\usebibmacro{editorstrg}}%
\clearname{editor}%
\printunit{\addcomma\space}}}
\xpatchbibdriver{inbook}
{\usebibmacro{in:}%
\usebibmacro{bybookauthor}%
\newunit\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{bybookauthor}%
\newunit\newblock
\usebibmacro{byeditor:in}%
\newunit\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{}{}
\xpatchbibdriver{incollection}
{\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{byeditor:in}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor}}
{}{}
\xpatchbibdriver{inproceedings}
{\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{event+venue+date}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{\usebibmacro{in:}%
\usebibmacro{byeditor:in}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{event+venue+date}%
\newunit\newblock
\usebibmacro{byeditor+others}}
{}{}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
Best Answer
This can be solved by creating a new name format that formats the first name(s) as just the very first initial:
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):
Then
biblatex
is set to use first initials in the bibliography and just the very first initial in in-text citations:The Result
MWE