4

Biblatex implements one single mechanism for abbreviating first names: it just prints the first character of the first name. For instance, "Philippe" is abbreviated into "P.".

However, some languages require some first names to be abbreviated differently.

In French, all first names starting with a pair of consonants making a single phoneme have to be abbreviated into that pair of consonants. For instance, "Philippe" must be abbreviated into "Ph.", not "P.".

A solution to get this with LaTeX is to protect the starting pair of consonants of a first name with \relax: if {\relax{}Ph}ilippe is detected as a first name by biblatex (or by bibtex), it will be abbreviated into "Ph.", as wanted.

This solution is exposed here: BibTeX: Abbreviate first name (aka given name) to 2 or 3 letters (not 1)

However, this solution requires to manually insert \relax command in the .bib file which is tedious.

5

I implemented the following code that automatically abbreviates first names starting with Ph, Th or Ch into that starting pair of consonant. No manual insertion of \relax in the .bib file is required.

\DeclareSourcemap{%
  \maps[datatype=bibtex]{%
    \map{%
      \stepfixfirstnameabbr{author}%
      \stepfixfirstnameabbr{editor}%
      \stepfixfirstnameabbr{editora}%
      \stepfixfirstnameabbr{editorb}%
      \stepfixfirstnameabbr{editorc}%
    }}}

\newcommand{\stepfixfirstnameabbr}[1]{
  % step 1
  \step[fieldsource=#2,
    match={\regexp{([^,]\s+)\b(Ch|Th|Ph)(\S*(\s+and|$))}},
    replace={\regexp{$1\{$2\}$3}}]%
  % step 2
  \step[fieldsource=#2,
    match={\regexp{(^|[^,]\s+)\b(Ch|Th|Ph)(\S*,)}},
    replace={\regexp{$1\{$2\}$3}}]%
  % step 3
  \step[fieldsource=#2,
    match={\regexp{\b(Ch|Th|Ph)([^\}])}},
    replace={\regexp{\{\\relax\{\}$1\}$2}}]%
}

Step 1 parses name fields written with form "firstname lastname". It wraps the beginning of a lastname if it matches Ch, Th or Ch.

Philippe Charmet and Charmet, Philippe
=> Philippe {Ch}armet and Charmet, Philippe

Step 2 parses name fields written with form "lastname, firstname". It wraps the beginning of a lastname if it matches Ch, Th or Ch.

Philippe {Ch}armet and Charmet, Philippe
=> Philippe {Ch}armet and {Ch}armet, Philippe

Step 3 wraps Th, Ch or Th starting a first name with a relax, as follows:

Philippe {Ch}armet and {Ch}armet, Philippe
=> {\relax{}Ph}ilippe {Ch}armet and {Ch}armet, {\relax{}Ph}ilippe

Steps 1 and 2 may look useless at first glance but they are not: it is important that no \relax is inserted at the beginning of a family name because it could affect its sorting in an index of authors generated using makeindex. I did not succeed in doing everything in a single step.

This code has been working pretty well so far so I would like to share it. Any improvement suggestions are welcome.

Yves

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.