7

How to include russian in LaTeX (LEd) ?

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage[russian]{babel}
\begin{document}
Hello
\end{document}

! Package babel /b/c9/cError:/b/c0/c You haven't loaded the option english yet. See the babel package documentation for explanation. Type H for immediate help.

user30167
  • 171

3 Answers3

9

It seems this problem is caused because you are not defining the input or encoding method. Furthermore, you are specifying the use of russian language, and then writting something in english.

For russian and english, you could try the following:

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

\begin{document}
Hello

\begin{quote}
  \selectlanguage{russian}
  Я помню чудное мгновенье:\\
  Передо мной явилась ты,\\
  Как мимолетное виденье,\\
  Как гений чистой красоты.
\end{quote}


\end{document}

Disclaimer: I don't speak Russian and and I have no idea what it says.

For more information about cyrillic, please see this post: Cyrillic in (La)TeX

Moriambar
  • 11,466
Mario S. E.
  • 18,609
  • 2
    I've changed the language order, since your sample document seems to use English as main language. If only Russian is desired, then \usepackage[russian]{babel} will do. – egreg May 04 '13 at 13:11
  • Its saying that I have no file lacodes.mf in "source" folder, but this is no even "source" folder in LEd directory. But this is such a folder in MikTex directory. Maybe problem is in using these 2 programs together? – user30167 May 04 '13 at 13:19
  • @user30167 have you tried what egreg said? "The error you get is probably because you changed the options to Babel. Just remove the .aux file when you do changes like that, it will be recreated automatically" – Mario S. E. May 04 '13 at 13:42
  • Isn’t this pretty much a duplicate of the question you’re linking to? Is there anything special about LEd? – doncherry May 04 '13 at 14:39
  • 4
    It is the beginning of a beautiful poem written by Pushkin in 1827 and dedicated to Anna Petrovna Kern, also a poetess: I still remember that amazing moment // You have appeared before my sight // As though a brief and fleeting omen, // Pure phantom in enchanting light. (transl. Mikhail Kneller) – yannis Jan 09 '17 at 23:11
  • I copy-pasted this example to try to reproduce it (after installing Babel 3.36 from https://ctan.org/pkg/babel?lang=en), but I am getting the following run-time error: "! Package babel Error: Unknown option `russian'. Either you misspelled it (babel) or the language definition file russian.ldf was not found. See the babel package documentation for explanation." However, I cannot find anywhere a file called "russian.ldf" in my installed Babel nor in the Babel PDF document. Am I doing something basic wrong? – Lucozade Nov 19 '19 at 23:50
  • Using \begin{otherlanguage*}{russian} and \end{otherlanguage*] is better than \selectlanguage{russian} – egreg Dec 01 '22 at 08:48
2

It is probably too easy and glib to say that, now, with Xelatex (or Lualatex), Unicode, a suitable font and a choice input method, you just type.

poetry 1830s style

I'm more impressed with TeX each day. And the various packages that add extra powerful functionality and the work that has gone into them.

So the answer probably depends on how much text, how you want or need to input it, and what you want to do with it, and (to a certain extent) what other text(s) surround it.

MWE

\documentclass[12pt,a5paper]{article}
\usepackage{xcolor}
\pagecolor{red!3}
\usepackage{psvectorian}
\usepackage{fontspec}
\setmainfont{Old Standard}%Palatino Linotype}%Times New Roman}%Old Standard}%DejaVu Serif}
\setmonofont{Courier New}
\begin{document}
\begin{center}
{\huge \uppercase{Я вас любил....}}\end{center}
\begin{center}
\psvectorian[scale=0.4]{88}
\end{center}

\vskip2em
Я вас любил : любовь ещё , быть может ,

В душе моей угасла не совсем ;

Но пусть она вас больше не тревожит ;

Я не хочу печалить вас ничем.

Я вас любил безмолвно , безнадежно ,

То робостью , то ревностью томим ;

Я вас любил так искренно , так нежно ,

Как дай вам Бог любимой быть другим. 

\vskip2em
\begin{center}
\psvectorian[scale=0.4]{88}
\end{center}

\vfill\footnotesize
\noindent\texttt{https://en.wikipedia.org/wiki/I\_Loved\_You\_(poem)}

\noindent\texttt{Журнал «Северные цветы», 1830\\
https://ru.wikipedia.org/wiki/Я\_вас\_любил…}

\newpage
\begin{center}
{\huge К ***}
\end{center}

Я помню чудное мгновенье :

Передо мной явилась ты ,

Как мимолетное виденье ,

Как гений чистой красоты.
\end{document}
Cicada
  • 10,129
0

Possibly the minimal setting for short text pieces. It provides no hyphenation rules though. (source Univ Berkeley)

  • Load the Cyrillic font encoding OT2 (not T2A,T2B or T2C) and the Latin one T1.
  • For the Russian text change locally the encoding to OT2.

Example,

\documentclass{article}
%VERY IMPORTANT, the principal enconding of the document must be
%the LAST option. In this case T1 (latin encoding).
\usepackage[OT2,T1]{fontenc}

%This command changes the input locally into OT2 \newcommand\textcyr[1]{{\fontencoding{OT2}\selectfont #1}}

\begin{document}

I begin with English, \textcyr{а потом перехожу на русский}.

Very practical!

\end{document}

enter image description here

Note: Remember, in case you need to hyphenate use \-, e.g., \textcyr{а по\-том пе\-ре\-хожу на русский}

========

I am aware that OT2 is a so-called obsolete encoding, but, precisely because of that, it is the most lightweight encoding for Russian. Moreover, it is a TeX encoding, hence not only restricted to LaTeX :).

I, personally, had the problem that both the encoding T2A and the package babel collided with two of my custom defined commands, namely, \C and \G. I wonder whether it is good practice to create such short names for the commands in packages that so many people around the world will be using :-\. Anyway, I use those commands everywhere in a very long document with a lot of included files, so I did not want to spent hours in "Search and Replace". Thank God, that the encoding OT2 does not collide with any of my commands.

  • Not really minimal. Hyphenation rules for Russian aren’t set. – Javier Bezos Nov 30 '22 at 18:13
  • @JavierBezos Thanks! Good to know. I'll warn about this. I would say, then, that is really minimal (even though suboptimal), because it simply allows the input of the alphabet. Ideal for very short text fragments or simple words. Why to load bigger packages? ;) – loved.by.Jesus Nov 30 '22 at 20:34
  • It’s the other way around: users should be careful when defining short names for commands, because they might be already taken. For blackboard bold C, i recommend \CC or \bC. – egreg Dec 01 '22 at 08:45
  • @egreg That is really a difficult question. I understand your perspective: If I make a package with commands, which I believe, are going to be used often, then I make the names short to make the life of the user easier (i.e., "usability"). At the same time, if the packages take all short names, I am forcing the user to create more complicated names, when he creates his own often-used commands, which contradicts "usability". The "usability" I wanted to provide as a package creator turns against the user. ´:-\ There is no easy solution. Be blessed! – loved.by.Jesus Dec 01 '22 at 09:31
  • 1
    @loved.by.Jesus Don't offer packages where short names are defined. Leave defining shorthands to the user. If your package defines \C, there are chances that other packages do, maybe for denoting the same thing, maybe not: conflict in either case. – egreg Dec 01 '22 at 09:38