[Tex/LaTex] Sorting and citing names with ‘von’ prefix using biblatex

biblatexsorting

Consider a document whose author is "van Beethoven, Ludwig". I'd like to cite it as "van Beethoven" in the text and list it as "van Beethoven" in the references. This could be achieved with useprefix=true. However, I'd like to list the entry not under "v" but under "B" in the references. In Germany, this is often considered to be the proper way to treat names with von and van prefixes. I understand that I can get this behavior by adding a sortkey field to the relevant BibTeX entries, but an automatic solution would of course be preferable.

Best Answer

I'm not a regexp person, really, so I suspect many people could improve on this. But there are two different approaches: a more 'manual' one, which is easier (for me) to fine-tune the final sorting scheme; and a fancier one that may cause havoc if you have many van and von entries with names otherwise identical to other people. (The worst case scenario would be to have a Ludwig Beethoven, Ludwig van Beethoven, and Ludwig von Beethoven --- not sure if it would ever get that bad, but there you have it.) So:

Manual fine-tuning:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,useprefix=true,style=authortitle]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}

@article{aaa,
  author =    {Adams, Ludwig},
  title =     {Title},
  journal =   {Sort this one under Adams},
  date =      1998,
}

@article{ccc,
  author =    {Curtius, Ludwig},
  title =     {Title},
  journal =   {Sort this one under Curtius},
  date =      1998,
}

@article{sss,
  author =    {Smith, Ludwig},
  title =     {Title},
  journal =   {Sort this one under Smith},
  date =      1998,
}

@article{www,
  author =    {Williams, Ludwig},
  title =     {Title},
  journal =   {Sort this one under Williams},
  date =      1998,
}

@article{van,
  author =    {van Beethoven, Ludwig},
  title =     {Title},
  journal =   {Sort this one under Beethoven},
  date =      1998,
}

@article{von,
  author =    {von Beethoven, Ludwig},
  title =     {Another Title},
  journal =   {Sort this one under Beethoven},
  date =      1999,
}

@article{nosort,
  author =    {van~Beethoven, Ludwig},
  title =     {Another Title},
  journal =   {Don't Sort this One via DeclareSourceMap, thanks to the Tilde},
  date =      2001
}

@article{override,
  author =    {van Beethoven, Ludwig},
  title =     {Title},
  journal =   {Sortname is: ZZZ -- Will be Overwritten!},
  date =      2000,
  sortname =  {ZZZ},
}


@article{beethoven,
  author =    {Beethoven, Ludwig},
  title =     {Title},
  journal =   {Sort this one under Beethoven but
               before the von/van entries (to pinpoint final sort)},
  date =      1998,
}

@article{beZthoven,
  author =    {Bezthoven, Ludwig},
  title =     {Title},
  journal =   {Sort this one under BeZthoven (to pinpoint final sort)},
  date =      1998,
}

\end{filecontents*}

\DeclareSourcemap{%
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \perdatasource{\jobname.bib}
      \step[fieldsource=author, final]
      \step[fieldset=sortname, origfieldval]
      \step[fieldsource=sortname,
            match=\regexp{van\s(Beethoven,)\s(Ludwig)*},
            replace={BeethovenY, Ludwig}]
      \step[fieldsource=sortname,
            match=\regexp{von\s(Beethoven,)\s(Ludwig)*},
            replace={BeethovenZ, Ludwig}]
    }% The disadvantage is clear: you need to add manual sorting
  }%   rules for each individual.  But the advantage is that it is
}%     easier to control the final sorting scheme


\begin{document}

\nocite{*}
\printbibliography

\end{document}

Trying to be clever with REGEXP:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,useprefix=true,style=authortitle]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
% well, just use the same entries as above
\end{filecontents}

\DeclareSourcemap{% 
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \perdatasource{\jobname.bib}
      \step[fieldsource=author, final]
      \step[fieldset=sortname, origfieldval]
      \step[fieldsource=sortname,
            match=\regexp{(v.n)\s(\w+,)\s(\w+)*},
            replace={$2}]
    }% the problem: 'von' will be sorted before 'van' IFF the title
  }%   of the 'von' entry is alphabetically prior to the title of
}%     the 'van' entry. Worse(?): a regular 'Beethoven, Ludwig' will
%      also be sorted among the 'van's and 'von's based solely on their 
%      titles.


\begin{document}

\nocite{*}
\printbibliography

\end{document}