4

Here's my MWE:

\documentclass[norsk]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\begin{document}

\begin{figure}

  \caption{Skjærgårdsøl}
  \label{Skjærgårdsøl}
\end{figure}

\end{document}

This gives the following error message:

(/opt/local/share/texmf-texlive/tex/latex/base/omsenc.dfu))) (./test.aux
! Missing \endcsname inserted.
<to be read again> 
                   \OT1\ae 
l.3 ... {\ae }rg\IeC {\r a}rds\IeC {\o }l}{{1}{1}}


LaTeX Warning: Label `Skj\IeC {\ae }rg\IeC {\r a}rds\IeC {\o }l' multiply defined.

I use TeXLive 2013 for Macintosh, the code is written using Emacs 24.3.1 for MacOS X, pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/MacPorts 2013_2).

I'd very much like to not have to use workarounds when labels are generated - is there a way to make æøåÆØÅ work with labels?

1 Answers1

11

TeX is a programming language. \label and some other constructs define variables in this language.

It is common for programming languages to allow only ASCII characters in variable names. You cannot, for example, write in C

int Skjærgårdsøl;
Skjærgårdsøl=5;

etc. The same is with TeX.

Update: as commenters tell us, nowadays some programming languages allow some Unicode in names. Also, xetex & luatex allow some Unicode in labels. Still I'd recommend to stick to ASCII for portable code.

Boris
  • 38,129
  • 7
    This is an interesting view of the problem. However, with XeLaTeX and LuaLaTeX all characters (except for a few) are allowed in \label. Not that I recommend using them, of course, because it hinders code reusability. – egreg Oct 03 '13 at 15:37
  • 1
    Beginning with ISO-C99, C actually does allow non-ASCII (UTF8) characters in identifiers, even though with some restrictions (the lists of valid Unicode code points in identifiers exclude all combining forms.) The same holds for many other programming languages nowadays. – Daniel Oct 03 '13 at 18:21
  • 1
    This makes sense. I was playing with xetex - which gave other problems but not this - and didn't realize this was the reason it worked then.

    Thanks!

    – Rolf Marvin Bøe Lindgren Oct 03 '13 at 18:43