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

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

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.

-
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

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
+1 for paratype –  Artem Pelenitsyn Jun 14 at 16:45

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

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

Cherepanov's russlh

Usage

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


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.
One has to (download and) use a non-standard package. Doesn't work with hyperref` (at least not with the current version).