# Cyrilic characters in \label and \ref in pdflatex

I want to write \label and \ref with Cyrillic(Russian) characters in pdflatex. \usepackage[russian]{babel} in preamble.

I tried \label{\detokenize{}}, but it doesn't work.

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

\begin{document}
\section{Раздел}
\label{\detokenize{Ссылка_на_раздел}}
Русский текст \ref{\detokenize{Ссылка_на_раздел}}
\end{document}

• Welcome to TeX.SX! Could you please add a complete but minimal example document with your attempts? – siracusa Dec 7 at 7:04
• With pdfLaTeX I would only use safe ASCII characters in labels. Sometimes certain non-ASCII characters may work by accident, but that is not at all guaranteed (e.g. \section{Ä}\label{ä}\ref{ä} works for me, but \section{ß}\label{ß}\ref{ß} fails spectacularly). If you want non-ASCII labels you need to use a full Unicode engine such as XeLaTeX or LuaLaTeX. – moewe Dec 7 at 7:35

It sort of works if you do a “double detokenization”:

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

\begin{document}
\section{Раздел}
\label{\detokenize{\detokenize{Ссылка_на_раздел}}}
Русский текст \ref{\detokenize{Ссылка_на_раздел}}
\end{document}


What's the problem? With a single \detokenize, the label is written as is in the .aux file, but when the .aux file is read in, the Cyrillic characters are no longer “detokenized” and it's impossible to form control sequence names with them.

You see you can, is it worth the pain? I don't think so. On the other hand, Unicode TeX engines such as XeLaTeX and LuaLaTeX have no problem with those characters in labels.

• It works as I expected, unless hyperref package destroys all success even it placed before or after redefined \label and \ref – Shalom Alecheim Dec 7 at 10:45
• @ShalomAlecheim hyperref does further massaging, so it's kind of expected that it doesn't work. – egreg Dec 7 at 12:45