[Tex/LaTex] Two or three letter initials in bibliography with Biblatex (again)

biberbiblatex

In French and some other European langages, given names should be abreviated keeping digraphs and trigraphs.

  • John should be abreviated as J.
  • Clare should be abreviated as Cl.
  • Charles should be abreviated as Ch.
  • Christine should be abreviated as Chr.
  • Philippe should be abreviated as Ph.
  • etc.

The classical solution was to modify the given name in the bibliographical data from

Charles

to

{\relax Ch}arles

A nice macro written by Yves de Saint-Pern uses the search and replace option with regexp in Biber/Biblatex to iterate over your bib file and insert on the fly

\relax
in the author field.

However, the latest Biber breaks this possibility. A bib entry with a \relax in the author field will result in a faulty *.bbl file with unmatched braces.
See here and here.

The only workaround is to use Biber extended name format which is cumbersome :

  • It makes it impossible to edit your bibliography file in a GUI application
  • It is a lot of manual work

Is there a possibility to modify Biber's initials creation routine to create correct giveni field if the given name starts with a list of digraphs and trigraphs ?

I include a MWE below :

\documentclass{article}
\usepackage{filecontents}
 \begin{filecontents}{\jobname.bib}
  % Extended name format
  @book{Book1,
  author = {family=Doe, given=Charles, given-i={Ch}},
  title  = {An Important Book},
  publisher = {Publisher},
  date = {2012},
}
@book{Book2,
  author = {Dolittle, Charlotte},
  title  = {Another Important Book},
  publisher = {Publisher},
  date = {2014},
}
@book{Book3,
  author = {Theodore Smith},
  title  = {A very Important Book},
  publisher = {Publisher},
  date = {2016},
}

@book{Book4,
    address = "Turnhout",
    author = "Arnoux, Mathieu and Gazeau, Véronique and Demetz, Christine",
    publisher = "Brepols",
    shorttitle = "Les chanoines réguliers de la province de Rouen",
    title = "{Des clercs au service de la réforme. Études et documents sur les chanoines réguliers de la province de Rouen}",
    year = "2000"
}
\end{filecontents}
\usepackage[style=verbose,giveninits=true, backend=biber]{biblatex}
% Does not work anymore with the latest Biber
% \DeclareSourcemap{
%  \maps[datatype=bibtex]{
%     \map{
%     \step[fieldsource=author, 
%             match={Charles},
%             replace=\regexp{\{\\relax \x20Ch\}arles}]
%   }
%  }
% }
\addbibresource{\jobname.bib}
\begin{document}

\cite{Book1}

\cite{Book2}

\cite{Book3}

\cite{Book4}
\end{document}

enter image description here

Best Answer

If you can live with inputting names always as "Family, Given" we can automate using the extended name format.

\makeatletter
\def\do#1{%
  \ifcsundef{blx@csv@datamodel@names}
    {\csdef{blx@csv@datamodel@names}{#1}}
    {\csappto{blx@csv@datamodel@names}{,#1}}}
\dolistcsloop{blx@datamodel@names}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[foreach=\blx@csv@datamodel@names]{
      \step[fieldsource=\regexp{$MAPLOOP}, 
            match=\regexp{(\A|\s+and\s+)([a-z'\s]+)?\s*(.+?)\,\s+(Chr?|Th|Ph|[B-DF-HJ-NP-TV-XZ](?:l|r)|\w)(.+?)(?=\Z|\s+and\s+)},
            replace=\regexp{$1 family=$3, prefix=$2, given=$4$5, given-i=\{$4\}}]
    }
  }
}
\makeatother

Splits off the initials with regexp and passes the name to the extended name format. This is now automatically done for all known name fields. The regex has been adapted from Two or three letter initials in bibliography with Biblatex.

\documentclass{article}
\usepackage{filecontents}
 \begin{filecontents}{\jobname.bib}
  % Extended name format
  @book{Book1,
  author = {Doe, Charles and Potter, William},
  title  = {An Important Book},
  publisher = {Publisher},
  date = {2012},
}
@book{Book2,
  author = {Dolittle, Charlotte},
  title  = {Another Important Book},
  publisher = {Publisher},
  date = {2014},
}
@book{Book3,
  author = {Smith, Theodore},
  title  = {A very Important Book},
  publisher = {Publisher},
  date = {2016},
}

@book{Book4,
    address = "Turnhout",
    author = "Arnoux, Mathieu and Gazeau, Véronique and Demetz, Christine",
    publisher = "Brepols",
    shorttitle = "Les chanoines réguliers de la province de Rouen",
    title = "{Des clercs au service de la réforme. Études et documents sur les chanoines réguliers de la province de Rouen}",
    year = "2000"
}
\end{filecontents}
\usepackage[style=verbose,giveninits=true, backend=biber]{biblatex}

\makeatletter
\def\do#1{%
  \ifcsundef{blx@csv@datamodel@names}
    {\csdef{blx@csv@datamodel@names}{#1}}
    {\csappto{blx@csv@datamodel@names}{,#1}}}
\dolistcsloop{blx@datamodel@names}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[foreach=\blx@csv@datamodel@names]{
      \step[fieldsource=\regexp{$MAPLOOP}, 
            match=\regexp{(\A|\s+and\s+)([a-z'\s]+)?\s*(.+?)\,\s+(Chr?|Th|Ph|[B-DF-HJ-NP-TV-XZ](?:l|r)|\w)(.+?)(?=\Z|\s+and\s+)},
            replace=\regexp{$1 family=$3, prefix=$2, given=$4$5, given-i=\{$4\}}]
    }
  }
}
\makeatother

\addbibresource{\jobname.bib}
\begin{document}

\cite{Book1}

\cite{Book2}

\cite{Book3}

\cite{Book4}
\end{document}

enter image description here

Related Question