4

Is it possible to have Biblatex generate a label using the correct first letters of the author's name (including umlauts)?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[safeinputenc,backend=biber, style=alphabetic]{biblatex}

\begin{filecontents}{test.bib}
@Article{Morgan,
  Title   = {Article title},
  Author  = {M{\"u}ller, John},
  Journal = {Journal title},
  Year    = {2014}
}
\end{filecontents}

\bibliography{test}

\begin{document}
  \nocite{*}
  \printbibliography
\end{document}

Result

The correct label should be Mül14.

Edit: I'm sorry, I forgot to add the biblatex package option safeinputenc in the above MWE. This option seems to be the culprit for the missing umlaut in the label. I've updated the MWE to better reflect my original document.

So, is there a way to get a correct label despite using safeinputenc? I use this option in order to circumvent the declaration of some unicode chars like ǧ for which I otherwise had to add

\DeclareUnicodeCharacter{01E7}{\v{g}}

What is the best practice for using those chars not interpretable by inputenc's utf8 mode?

3
  • 2
    Load inputenc with the correct encoding of your file. But I'm wondering if it is deliberate or an oversight that you don't get the Umlaut without inputenc. – Ulrike Fischer May 27 '14 at 8:57
  • @UlrikeFischer I guess it's deliberate, but maybe one could ask for a change. – egreg May 27 '14 at 10:01
  • You could remove the safeinputenc option and call biber with the option --output_safechars instead. Imho you should also add an issue to the tracker of biber. – Ulrike Fischer May 28 '14 at 8:41
1

That's easy to achieve.

Add the following two lines to your preamble:

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

The first line tells LaTeX which encoding your files are using. The second line tells LaTeX to embed the real umlaut-characters as characters in the pdf, or you will get John M¨uller if you copy text out of your pdf.

Then you have to change the encoding of your documents to UTF-8 without BOM; maybe you should alos exchange all umlaut-commands {\"u} with their characters ü etc., but it's not necesary, see egregs command

In my tests I always get problems if I want to use UTF-8 with filecontents, so in this case better create a real file test.bib.

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage[backend=biber, style=alphabetic]{biblatex}
\usepackage{csquotes}%I get a warning, if I don't add it.
\addbibresource{test.bib}%the correct command

\begin{document}
  \nocite{*}
  \printbibliography
\end{document}

Content of test.bib:

@Article{Morgan,
  Title   = {Article title},
  Author  = {Müller, John},
  Journal = {Journal title},
  Year    = {2014}
}

Output:

enter image description here

3
  • 1
    It works also with author={M{\"u}ller, John}; the essential bit is loading inputenc. – egreg May 27 '14 at 10:03
  • you're right, I've updated my answer. – musicman May 27 '14 at 11:59
  • @musicman: I'm sorry, I had a mistake in my MWE. I have updated the question accordingly. – Bloops May 27 '14 at 16:33

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.