[Tex/LaTex] Abbreviate only middle names in biblatex

acronymsbiberbiblatex

I know of the option firstinits=true to abbreviate the first and all middle names in biblatex. What I would like to achieve is to only abbreviate the middle names. So e.g. author = {Smith, John Ethan Jacob} should be printed as Smith, John E. J.

Please see the MWE based on the answer of Jonathan from this post at the end of this question. I get the following output:

[SD95] Smith, John E. J./Doe, Jain L. Some book title. A Publisher, 1995.

But what I would like to see as output is:

[SD95] Smith, John E. J. ; Doe, Jain L: Some book title. A Publisher, 1995.

The ; between the author names and the : between the author names and the book title are specific to the bib style (custom made) I use. But the solution below doesn't respect this custom style. Any idea how to achieve the desired abbreviation, but don't loose the bib style?

MWE:

\documentclass{article}
\usepackage[backend=biber,style=din, autocite=footnote]{biblatex}

\begin{filecontents*}{bibliography.bib}
@BOOK{SD1995,
  author = {Smith, John Ethan Jacob and Doe, Jain Lauren},
  title = {Some book title},
  year = {1995},
  publisher = {A Publisher}
}
\end{filecontents*}

\addbibresource{bibliography.bib}

\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}
\null
\vfill

How the citation look like: \cite{SD1995}

\clearpage
\printbibliography
\end{document}

Edit
Please look here for the din style I'm using in the MWE. With this style I get two white spaces between the first author and the separating ;, when I use the modification by Andrew Swann. Without the modification there is only one white space. I'm now looking for a solution to this problem.

Best Answer

Here is something less invasive than the solution you have tried. It relies on adjusting the macro \mkbibnamegiven which is called to format the first and middle names rather than completely rewriting the name format:

Sample output

\documentclass{article}
\usepackage[backend=biber,style=alphabetic,autocite=footnote]{biblatex}

\begin{filecontents*}{bibliography.bib}
@BOOK{SD1995,
  author = {Smith, John Ethan Jacob and Doe, Jain Lauren},
  title = {Some book title},
  year = {1995},
  publisher = {A Publisher}
}
\end{filecontents*}

\addbibresource{bibliography.bib}

\usepackage[T1]{fontenc}

\renewcommand*{\mkbibnamegiven}[1]{\edef\firstname{#1}\expandafter\first{\firstname}}

\def\bibnamedelima{ }%
\def\bibnamedelimb{ }%

\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\bibinitdelim \@initials#2\@nil\fi}
\def\initial#1{\expandafter\@initial#1\@nil}
\def\@initial#1#2\@nil{#1\bibinitperiod}
\makeatother

\begin{document}
How the citations appear: \cite{SD1995}.

\printbibliography
\end{document} 

Update with the din style you point to in your update you should add

\AtBeginBibliography{\renewcommand*{\multinamedelim}{\addsemicolon\addspace}}

to your preamble. The din style contains the definition

\renewcommand*{\multinamedelim}{\mbox{ }\addspace\addsemicolon\addspace}

which adds a single space before the semicolon. Another way to get a single space would be

\AtBeginBibliography{\renewcommand*{\multinamedelim}{\addspace;\addspace}}
Related Question