Cyrillic in (La)TeX

What are different ways to use Cyrillic in (La)TeX? What are their pros and cons?

• Does "(la)tex" preclude the use of XeLaTeX? Because unless there is something I'm missing, in the same way that I can typeset in Japanese with XeLaTeX, you should be able to typeset in Cyrillic, provided you have the fonts. – José Figueroa-O'Farrill Aug 2 '10 at 16:17
• Oh, xelatex definitely counts. Looks like it works fine with Cyrillic but I used xelatex only a couple of times and probably there are some caveats. – Grigory M Aug 2 '10 at 17:11
• Probably xelatex is the best choice for new documents. But sometimes I need, for example, to build some old book from the source. And I suspect switching to xelatex there won't be an easy task (although I should try). – Grigory M Aug 2 '10 at 17:20
• – Grigory M Aug 20 '10 at 16:01
• Doesn't have to be XeLaTeX. LuaLaTeX also works directly with Open Type fonts (using fontspec package). See the complete info provided by Sergei, far down this page. – user103221 May 10 '17 at 17:46

inputenc + babel

Usage

\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}


Pros

Standard — works with any LaTeX installation. One can use any encoding in .tex files. Works fine with hyperref.

Cons

Cyrillic letters become active symbols — so one can neither define commands with Cyrillic names nor use them in arguments of \label, \cite etc. Cyrillic letters in .aux and .toc files become unreadable.

Note
If you get this error: Unknown option 'russian'. Either you misspelled it or the language definition file francais.ldf was not found try installing the texlive-lang-cyrillic package. (source)

• Cyrillics is not active any more if xetex or luatex is used to compile your document. See ctan.org/pkg/russian. – Igor Kotelnikov Apr 15 '13 at 8:24
• The huge advantage of this method is the vast range of font shapes present in the CMU font. The drawback... one you get used to it, you will be disappointed by the fact that there is virtually no alternative to this mega-font except for the paratype package (T2A is poorly supported as of today). Some users might install the “Literaturnaya” typeface, but Computer Modern will become your daily bread. IMHO, it is has a very aristocratic look. – Andreï Kostyrka Jan 24 '16 at 14:25
• Another possible con is the treatment of diacritics. Try for example to enter Его́р Тиму́рович Гайда́р. For me it break the rendering of all Cyrillic text in my document like the economy of the 90s. Without accents like "´" on vowels, all is well again in latex. Though not often used in Russian, for us non-native speakers, accents are sometimes crucial. I, for example, always thought his name was Га́йдар :/ – nJGL Mar 22 at 20:32

XeLaTeX

Usage

\documentclass{article}
\usepackage{fontspec} % loaded by polyglossia, but included here for transparency
\usepackage{polyglossia}
\setmainlanguage{russian}
\setotherlanguage{english}

% XeLaTeX can use any font installed in your system fonts folder
% Linux Libertine in the next line can be replaced with any
% OpenType or TrueType font that supports the Cyrillic script.

\newfontfamily\russianfont[Script=Cyrillic]{Linux Libertine}

\begin{document}
Привет
\begin{english}
Hello!
\end{english}
\end{document}


Compile with xelatex.

Pros

Works out of the box in fresh TeX distributions. Cyrillic letters can be used freely in control sequence names, labels, etc.

Cons

One needs a pretty modern TeX distribution. (What else?)

• Computer Modern Unicode is a far lesser deviation from the default fonts than Linux Libertine. Is there any reason to not to use it in this example? – Andrey Vihrov Mar 8 '11 at 13:22
• Until your comment, I'd never heard of this font. I used Linux Libertine because it seems to be widely known. Since xelatex can use any font installed in your system, the actual font doesn't matter. I've added a comment to the code to this effect. – Alan Munn Mar 22 '11 at 15:42
• With babel 3.9, there is no need to use polyglossia instead of babel. At least, I don't know any reason for that. – Igor Kotelnikov Apr 15 '13 at 8:21
• Is it somehow possible to enter "Привет" into a LaTeX document right from a standard English keyboard? If not, what would better ways to do this, without a physical Russian keyboard? – Iosif Pinelis Oct 13 '17 at 0:05

For multilingual texts with pdflatex (as opposed to using the xelatex or lualatex engines), the best option is to use the UTF-8 encoding for the input and babel:

\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}

\begin{document}

Text in English

\begin{otherlanguage*}{russian}
Текст на русском языке
\end{otherlanguage*}

A word and another \foreignlanguage{russian}{слово}

\end{document}


There are a number of fonts available in the T2A encoding for pdflatex:

For a wider choice, XeLaTeX or LuaLaTeX are best.

• @Cortizol This answer is about pdflatex, not XeLaTeX or LuaLaTeX. – egreg Nov 6 '13 at 22:06
• It appears that passing option T2A to fontenc is optional, this is arranged by russian babel option already. Mentioning this because it can be useful to know for automatically generated document which only use T1 a priori. – user4686 Oct 10 '17 at 11:41

Mixing Cyrillic and Latin letters

The basic idea is to use babel and inputenc (like inputenc+babel). Your document looks like:

\documentclass{article}
\usepackage[OT2, T1]{fontenc}
\usepackage[russian, english]{babel}
\begin{document}
\foreignlanguage{russian}{Druzhba} means friendship.
\end{document}


Especially important is OT2-encoding and russian as option to babel. The command \foreignlanguage allows you to switch between English and Russian.

Pros

• You don't need a Cyrillic keyboard.
• Nearly every LaTeX system has OT2.
• babel also offers specific names e.g. for the table of contents (Содержание), table of ..

Cons

• Hyphenation does not work perfect.
• Using OT2 encoding is like a poor man's alternative to T2A

Some time ago I wrote a blog post in German: Kyrillischen Text mit LaTeX setzen

• Walter Schmidt's document (in German), mentioned in the blog posting, has a table of the OT2 input encoding, which I've not been able to find anywhere else: home.vr-web.de/was/x/pmcyr.pdf – ptomato Aug 10 '10 at 10:31
• T2A encoding is default for russian document. OT2 is considered to be outdated encoding. I could hardly understand why you are recommending OT2. Perhaps, because I do have russian keyborad, :). – Igor Kotelnikov Oct 8 '11 at 12:51
• I tried this and what I got is "Package babel Error: No Cyrillic encoding definition files were found." :( – Karel Bílek Feb 8 '13 at 10:14
• @IgorKotelnikov: This method (using OT2) was the only one successful in getting some of the non-base-256 cyrillic letters to get displayed in LaTeX. Very good! – Alex Mar 8 '15 at 4:21

Using UTF-8

If you're using UTF-8, you have a Russian keyboard and you want to type only Russian texts, the best would be:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\begin{document}
ЛаТеХ
\end{document}


This way you don't have to change your behaviour. Typing LaTeX texts is as easy as typing other texts. Usually you also have correct hyphenation patterns, so you can use the full feature set of LaTeX. :-)

• Isn't it just a method "inputenc + babel" (with all it cons) but without working hyphenation? – Grigory M Aug 2 '10 at 20:24
• This works also for bilangual english-russian docs. So your statement that it works only for russian text seemed to be suspicious. – Igor Kotelnikov Oct 8 '11 at 12:56
• I tried this and what I got is " Package fontenc Error: Encoding file t2aenc.def' not found. (fontenc) You might have misspelt the name of the encoding." – Karel Bílek Feb 8 '13 at 10:15
• Problem: words in Cyrillic aren't searchable (in Cyrillic) if you typeset them using control sequences. Solution: this answer. – mathematrucker May 27 '17 at 15:09

Cherepanov's russlh

Usage

%&latex --tcx=koi2t2
\usepackage{russlh}


Pros

Cyrillic letters are \catcode'd to 11 ("letter"); thus, they can be used freely in control sequence names, labels, etc. In text files written by LaTeX (.toc, .aux, .idx, etc.) Russian letters are recoded back to their initial form, which makes these files readable and simplifies the processing of .idx files.

Cons

One has to (download and) use a non-standard package. Doesn't work with hyperref (at least not with the current version).

• Any reason to use one of many-many outdated medhods of russification superseeded by official babel? – Igor Kotelnikov Oct 8 '11 at 12:53
• @Igor Well, one typical scenario is that one needs to use a complicated .sty file with Cyrillic control sequence names / some .tex file with a lot of Cyrillic labels. – Grigory M Oct 8 '11 at 15:43

LuaLaTeX

Another modern option for Cyrillics is LuaLaTeX (with babel or polyglossia, though polyglossia still has an annoying bug and forgets to switch font family/shape sometimes).

Usage

\documentclass{article}
\usepackage{fontspec}

% The default Latin Modern font family doesn't contain Cyrillics,
% so load Computer Modern Unicode instead
\setmainfont{CMU Serif}[Ligatures=TeX]

\usepackage[english,russian]{babel}

\begin{document}
Привет
{\selectlanguage{english}%
Hello!
}
\end{document}


Pros

LuaLaTeX can use any TTF or OTF font without any additional work like creating TFM an virtual fonts for pdfLaTeX.

To use a font by its name, one can just drop it into her ~/texmf/ tree and doesn't have to install it as a system font.

Since LuaTeX is a fully unicode-aware engine, one can freely mix languages, with only requirement that all the necessary glyphs are present in utilized fonts.

Auxiliary files like .aux, .toc, .idx` etc. are human readable in contrast to pdfLaTeX (with inputenc). It helps with debugging index or PDF bookmarks.

Cons

Requires modern TeX distribution. For example, limits positioning for slanted math operators (like integrals) was fixed only in version 1.0 (TeXlive 2016 has 0.95).