I have a issue when trying to generate table of contents with lualatex in russian. Following example fails to build with ! Undefined control sequence. \contentsname ->{\cyr \CYRS \cyro \cyrd \cyre \cyrr \cyrzh \cyra \cyrn \cyri... which stands for 'Содержание' ('Contents' in russian)


\setmainfont[Ligatures=TeX]{DejaVu Serif}

\section{тест 1}
\section{тест 2}
\section{тест 3}

When I load english version of babel it ok, execept of table of contents title in english "Contents". Is there a way to correctly specify encoding for babel in lualatex?

6 Answers 6


The following covers the Russian alphabet:



\setmainfont[Ligatures=TeX]{DejaVu Serif}

\section{тест 1}
\section{тест 2}
\section{тест 3}

A more abstract way for getting (almost) all the known cyrillic characters can be obtained with code by David Carlisle (see https://tex.stackexchange.com/a/110016/4427)


\setmainfont[Ligatures=TeX]{DejaVu Serif}

% This code must go after xunicode is loaded (by fontspec),
% but before babel.
    \lccode`E=`E \lccode`U=`U
\typeout{Redefined \string#2}
\input{x2enc.dfu}% this contains all the cyrillic characters


\section{тест 1}
\section{тест 2}
\section{тест 3}

Another way might be to redefine \captionsrussian and the other relevant commands (taken from gloss-russian.ldf of polyglossia)

   \def\refname{Список литературы}%
   \def\listfigurename{Список иллюстраций}%
   \def\listtablename{Список таблиц}%
   \def\indexname{Предметный указатель}%
   \def\authorname{Именной указатель}%
  \space \number\year\space г.}}
   А\or Б\or В\or Г\or Д\or Е\or Ж\or
   З\or И\or К\or Л\or М\or Н\or О\or
   П\or Р\or С\or Т\or У\or Ф\or Х\or
   Ц\or Ч\or Ш\or Щ\or Э\or Ю\or Я\else\@ctrerr\fi}
   а\or б\or в\or г\or д\or е\or ж\or
   з\or и\or к\or л\or м\or н\or о\or
   п\or р\or с\or т\or у\or ф\or х\or
   ц\or ч\or ш\or щ\or э\or ю\or я\else\@ctrerr\fi}

Added April 2013: the forthcoming version 3.9 of babel should solve the problem by checking whether the typesetting engine understands Unicode natively and setting the fixed words accordingly. This version of babel is already on CTAN, but still hasn't found its way in TeX Live. It will soon.

  • First. Why you are declaring \cyr.. commands for EU2 encoding? Future unicode solution will not need any \cyr... command, hence this should be named something like OU2 (old unicode). Second. In fact, I am using cited set of \DeclareTextCommand{\cyrya}{EU2}{...} commands for some time. It really works, but I wonder where EU2 encoding is activated? As far as I know, by default, fontspec declares EU1 encoding. Commented Oct 6, 2011 at 15:16
  • @Igor fontspec declares EU1 encoding for XeLaTeX and EU2 for LuaLaTeX. Of course one has to declare those commands for EU2 encoding, because babel uses them in the .ldf file for Russian and so they must be known
    – egreg
    Commented Oct 6, 2011 at 21:40
  • Thank you. Perhaps, it is worthy to elaborate unicode russian stuff for babel, it would be named russian_u_.ldf or even russian.ldf since currently babel comes with russian_b_.ldf. however, I am not sure that babel is the only package which relies on \cyr.. commands. I will try... Commented Oct 7, 2011 at 3:20

Sadly polyglossia is still not adapted for lualatex. It uses xetex specific commands for which no lualatex equivalent exist. But as far as I can see gloss-russian.ldf doesn't need them so you can try this:

\setmainfont[Ligatures=TeX]{DejaVu Serif}
\def\newXeTeXintercharclass#1{} %hack to fool polyglossia


Attention! This will probably break horribly if you load a polyglossia language like french which actually needs the \XeTeXintercharclass feature. In this case one the work-arounds of egreg is better.

  • That's right! Adding French results in subtle errors, even if babel is used. I'll add an example of such errors soon in separate post. Commented Jun 14, 2011 at 7:04
  • Although lualatex does run without crashing, it seems that this hack does not allow the hyphenation patterns to be loaded, even in languages that do not need the \XeTeXintercharclass feature. Commented Oct 19, 2011 at 22:49
  • 1
    @Mateus: I haven't the time to test now. But: lualatex loads hyphenations differently than xelatex (there are loaded on the fly). Perhaps polyglossia needs some adaption. You could contact the new maintainer of polyglossia. Commented Oct 20, 2011 at 9:11
  • @UlrikeFischer: Indeed! The systems are independent! The issue was that I was trying the hyphenation patterns for the language brazil, which XeTeX knows about, but LuaTeX doesn't. I changed it to portuguese, and it worked. Probably someone should add the synonym to language.dat.lua. Thanks! Commented Oct 20, 2011 at 14:31

There isn't yet either (full) babel or (any) polyglossia support for lualatex. So unless you need the specific extras such as direct lua code, you should use xelatex + polyglossia for the time being or work with the solutions posted by Ulrike and egreg.


Use updated russianb.ldf from http://www.ctan.org/pkg/russian instead of that that came with babel 3.8. Updated russianb.ldf will be included with babel 3.9.


Try to use [russian] as an argument to \documentclass instead of Babel. At least for me, using lualatex 0.60 with texlive 2010 including all updates, that works.

  • It doesn't work with lualatex 0.70.1 Commented Jun 30, 2011 at 21:52

I have not much experience in using LuaTeX. Your code seems to be more for XeLaTeX. Perhaps you should replace babel with polyglossia. The example below works at least with XeLaTeX.

\setmainfont[Ligatures=TeX]{DejaVu Serif}

\section{тест 1}
\section{тест 2}
\section{тест 3}
  • 5
    No, both lualatex and xelatex use fontspec. But the problem is that there isn't yet either babel or polyglossia support for lualatex. So unless Avsej needs the specific extras such as direct lua code, he should use xelatex for the time being.
    – Alan Munn
    Commented Jan 17, 2011 at 19:18
  • 2
    @Alan: I think this comment is worth to be transformed to an answer. Commented Jan 17, 2011 at 19:43
  • Thank you. Frankly speaking I using xelatex now. But I think that it is good thing to have embedded lua :) Shall I close this question? There are many posts in internets about lack of babel/polyglossia for lualatex. Is there some roadmap for this features?
    – avsej
    Commented Jan 18, 2011 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .