# Non-ASCII character in label

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?

-
Short answer: no. –  egreg Oct 3 '13 at 15:26
Apparently, there's a simple workaround. tex.stackexchange.com/questions/93719/… –  roffe Oct 3 '13 at 20:33
That's why I wrote "short answer". While it may be possible, I don't recommend it. –  egreg Oct 3 '13 at 20:36
There is this old book about LaTeX by some guy called Lamport. You might want to read it - it answers your question (among others). –  Martin Schröder Oct 4 '13 at 11:20
I've also read a really ancient tome by a guy named Knuth, about TeX, which gives the impression that much of what is written in the more recent book under some circumstances might be called both “jokes” and “lies”. –  roffe Oct 5 '13 at 12:51

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.

-
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 3 '13 at 15:37
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 3 '13 at 18:21
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! –  roffe Oct 3 '13 at 18:43