1 The Russian language

The file russianb.dtx^{1} defines all the language-specific macros for the Russian language. It needs the file cyrcod for success documentation with Russian encodings (see below).

For this language the character " is made active. In table 1 an overview is given of its purpose.

"|  disable ligature at this position.

"- an explicit hyphen sign, allowing hyphenation in the

rest of the word. "" like "-, but producing no hyphen sign (for compund

words with hyphen, e.g. x-""y or some other signs as “disable/enable”).

"~  for a compound word mark without a breakpoint.

"= for a compound word mark with a breakpoint, allowing hyphenation in the composing words.

"`  for German left double quotes (looks like ,,).
"'  for German right double quotes (looks like “).
” "< for French left double quotes (looks like <<).
">  for French right double quotes (looks like >>).

Table 1: The extra definitions made by russianb

The quotes in table 1 can also be typeset by using the commands in table 2.

\glqq  for German left double quotes (looks like ,,).
\grqq  for German right double quotes (looks like “).
” \flqq for French left double quotes (looks like <<).
\frqq  for French right double quotes (looks like >>).
\dq  the original quotes character (").

Table 2: More commands which produce quotes, defined by babel

The quotation marks traditionally used in Russian language were borrowed from other languages (e.g. French and German) so they keep their original names.

The macro \LdfInit takes care of preventing that this file is loaded more than once, checking the category code of the @ sign, etc.

1 ⟨∗code⟩

 2 \LdfInit{russian}{captionsrussian}

When this file is read as an option, i.e., by the \usepackage command, russianb will be an ‘unknown’ language, in which case we have to make it known. So we check for the existence of \l@russian to see whether we have to do something here.

1The file described in this section has version number v1.1e and was last revised on 1996/12/29. This file was initially derived from the original version of german.sty, which has some definitions for Russian. Later the definitions from russian.sty version 1.0b (for L^{A}TEX 2.09), russian.sty version v2.5c (for L^{A}TEX2e) and francais.sty version 4.5c and germanb.sty version 2.5c were added.

 3 \ifx\l@russian\@undefined
 4 \@nopatterns{Russian}%
 5 \adddialect\l@russian0
 6 \fi

Tyesetting Russian texts implies that a special set of fonts needs to be used. The current support for Russian uses a set of fonts that more or less ‘match’ with the computer modern fonts. Therefore we define the Local WashingtoN encoding (LWN, see the file cyrillic.fdd). We make sure that this encoding is known to L^{A}TEX.

 7 \input{LWNenc.def}

\latinencoding We need to know the encoding for text that is supposed to be typeset in latin text. We assume that it will be the encoding which is active at the end of the babel package. If the fontenc package is loaded later, then... too bad!

 8 \AtEndOfPackage{\edef\latinencoding{\cf@encoding}}

Now we define two commands that offer the possibility to switch between cyrillic and roman encodings.

\cyrillictext \latintext The command \cyrillictext will switch from latin font encoding to the cyrillic font encoding, the command \latintext switches back. This assumes that the ‘normal’ font encoding is a latin one. These commands are declarations, for shorter peaces of text the commands \textlatin and \textcyrillic can be used.

 9 \DeclareRobustCommand{\cyrillictext}{%
10 \fontencoding{LWN}\selectfont
11 \def\encodingdefault{LWN}}
12 \DeclareRobustCommand{\latintext}{%
13 \fontencoding{\latinencoding}\selectfont
14 \def\encodingdefault{\latinencoding}}
15 \let\lat\latintext
16 \let\cyr\cyrillictext

\textcyrillic \textlatin These commands take an argument which is then typeset using the requested font encoding.

The next step consists of defining commands to switch to (and from) the Russian language.

\captionsrussian The macro \captionsrussian defines all strings used in the four standard document classes provided with L^{A}TEX. There are the two commands: \cyr and \lat which switch on the right (Cyrillic or Latin) encoding.

17 \addto\captionsrussian{%
18 \def\prefacename{%
19  {\cyr \CYRP\CYRr\CYRe\CYRd\CYRi\CYRs\CYRl\CYRo\CYRv\CYRi\CYRe}}%
20 %{\cyr \CYRV\CYRv\CYRe\CYRd\CYRe\CYRn\CYRi\CYRe}}%
21 \def\refname{%
22  {\cyr \CYRS\CYRp\CYRi\CYRs\CYRo\CYRk\space
23  \CYRl\CYRi\CYRt\CYRe\CYRr\CYRa\CYRt\CYRu\CYRr\CYRy}}%
24 \def\abstractname{%
25  {\cyr \CYRA\CYRn\CYRn\CYRo\CYRt\CYRa\CYRc\CYRi\CYRya}}%
26 \def\bibname{%
27  {\cyr\CYRB\CYRi\CYRb\CYRl\CYRi\CYRo\CYRg\CYRr\CYRa\CYRf\CYRi\CYRya}}%

28 \def\chaptername{%
29  {\cyr \CYRG\CYRl\CYRa\CYRv\CYRa}}%
30 \def\appendixname{%
31  {\cyr \CYRP\CYRr\CYRi\CYRl\CYRo\CYRzh\CYRe\CYRn\CYRi\CYRe}}%

There are two names for the Table of Contents that are in use in Russian publications.

32 \def\contentsname{%

For books this one is appropriate:

33  {\cyr \CYRO\CYRg\CYRl\CYRa\CYRv\CYRl\CYRe\CYRn\CYRi\CYRe}}%

but for proceedings the following is preferred:

34 %{\cyr \CYRS\CYRo\CYRd\CYRe\CYRr\CYRzh\CYRa\CYRn\CYRi\CYRe}}%
35 \def\listfigurename{%
36  {\cyr \CYRS\CYRp\CYRi\CYRs\CYRo\CYRk\space
37  \CYRi\CYRl\CYRl\CYRyu\CYRs\CYRt\CYRr\CYRa\CYRc\CYRi\CYRishrt}}%

The List of Tables is not used so we provide an empty definition by default.

38 \def\listtablename{%
39  %\CYRS\CYRp\CYRi\CYRs\CYRo\CYRk\space
40  %\CYRt\CYRa\CYRb\CYRl\CYRi\CYRc}%

41 }

42 \def\indexname{%
43  {\cyr \CYRP\CYRr\CYRe\CYRd\CYRm\CYRe\CYRt\CYRn\CYRy\CYRishrt\space
44  \CYRu\CYRk\CYRa\CYRz\CYRa\CYRt\CYRe\CYRl\CYRssgn}}%
45 \def\authorname{%
46  {\cyr \CYRI\CYRm\CYRe\CYRn\CYRn\CYRo\CYRishrt\space
47  \CYRu\CYRk\CYRa\CYRz\CYRa\CYRt\CYRe\CYRl\CYRssgn}}%
48 \def\figurename{{\cyr \CYRR\CYRi\CYRs.}}%
49 \def\tablename{{\cyr \CYRT\CYRa\CYRb\CYRl\CYRi\CYRc\CYRa}}%
50 \def\partname{{\cyr \CYRCH\CYRa\CYRs\CYRt\CYRssgn}}%
51 \def\enclname{{\cyr \CYRv\CYRk\CYRl.}}%
52 \def\ccname{{\cyr \CYRi\CYRs\CYRh.}}%
53 \def\headtoname{{\cyr \CYRv\CYRh.}}%
54 \def\pagename{{\cyr \CYRs.}}%
55 \def\seename{{\cyr \CYRs\CYRm.}}%
56 \def\alsoname{{\cyr \CYRs\CYRm.\ \CYRt\CYRa\CYRk\CYRzh\CYRe}}}

\daterussian The macro \daterussian redefines the command \today to produce Russian dates.

57 \def\month@russian{\ifcase\month\or
58 \CYRya\CYRn\CYRv\CYRa\CYRr\CYRya\or
59 \CYRf\CYRe\CYRv\CYRr\CYRa\CYRl\CYRya\or
60 \CYRm\CYRa\CYRr\CYRt\CYRa\or
61 \CYRa\CYRp\CYRr\CYRe\CYRl\CYRya\or
62 \CYRm\CYRa\CYRya\or
63 \CYRi\CYRyu\CYRn\CYRya\or
64 \CYRi\CYRyu\CYRl\CYRya\or
65 \CYRa\CYRv\CYRg\CYRu\CYRs\CYRt\CYRa\or
66 \CYRs\CYRe\CYRn\CYRt\CYRya\CYRb\CYRr\CYRya\or
67 \CYRo\CYRk\CYRt\CYRya\CYRb\CYRr\CYRya\or
68 \CYRn\CYRo\CYRya\CYRb\CYRr\CYRya\or
69 \CYRd\CYRe\CYRk\CYRa\CYRb\CYRr\CYRya\fi}
70 \def\daterussian{%
71 \def\today{\number\day~\month@russian\space\number\year~\CYRg.}}

\extrasrussian The macro \extrasrussian will perform all the extra definitions needed for the Russian language. The macro \noextrasrussian is used to cancel the actions of

\extrasrussian.

The first action we define is to switch to the LWN encoding whenever we enter ‘russian’.

72 \addto\extrasrussian{\cyrillictext}

When the file LWNenc.def was processed by LaTeX it stores the current font encoding in \latinencoding, assuming that L^{A}TEX uses T1 or OT1 as default. Therefore we switch back to \latinencoding whenever the russian language is no longer ‘active’.

73 \addto\noextrasrussian{\latintext}

\verbatim@font In order to get verbatim text in the latin alphabet we need to change the definition of an internal L^{A}TEX command somewhat:

74 \def\verbatim@font{%
75 \normalfont
76 \fontencoding\latinencoding\ttfamily}

In order to be able to use cyrillic letters in mathematics we need to have the package cyrmath available.

77 \AtEndOfPackage{\RequirePackage{cyrmath}}

The category code of the characters :, ;, ! and ? is made \active to insert a little white space.

For Russian (as well as for German) the " character also is made active.

78 \initiate@active@char{:}
79 \initiate@active@char{;}
80 \initiate@active@char{!}
81 \initiate@active@char{?}
82 \initiate@active@char{"}

The code above is necessary because we need extra active characters. The character " is used as indicated in table 1.

We specify that the russian group of shorthands should be used.

83 \addto\extrasrussian{\languageshorthands{russian}}

These characters are ‘turned on’ once, later their definition may vary.

84 \addto\extrasrussian{%
85 \bbl@activate{:}\bbl@activate{;}%
86 \bbl@activate{!}\bbl@activate{?}%
87 \bbl@activate{"}}
88 %\addto\noextrasrussian{%
89 %  \bbl@deactivate{:}\bbl@deactivate{;}%
90 %  \bbl@deactivate{!}\bbl@deactivate{?}%
91 %  \bbl@deactivate{"}}

\russian@sh@;@ \russian@sh@:@ \russian@sh@!@ \russian@sh@?@ We have to reduce the amount of white space before ;, : and !. This should only happen in horizontal mode, hence the test with \ifhmode.

92 \declare@shorthand{russian}{;}{%
93 \ifhmode

In horizontal mode we check for the presence of a ‘space’, ‘unskip’ if it exists and place a 0.1em kerning.

 94  \ifdim\lastskip>\z@
 95  \unskip\penalty\@M\thinspace
 96  \else
 97  \thinspace
 98  \fi
 99 \fi

Now we can insert a ; character.

100 \string;}

Because these definitions are very similar only one is displayed in a way that the definition can be easily checked.

101 \declare@shorthand{russian}{:}{%
102 \ifhmode
103  \ifdim\lastskip>\z@
104  \unskip\penalty\@M\thinspace
105  \else
106  \thinspace
107  \fi
108 \fi
109 \string:}
110 \declare@shorthand{russian}{!}{%
111 \ifhmode
112  \ifdim\lastskip>\z@
113  \unskip\penalty\@M\thinspace
114  \else
115  \thinspace
116  \fi
117 \fi
118 \string!}
119 \declare@shorthand{russian}{?}{%
120 \ifhmode
121  \ifdim\lastskip>\z@
122  \unskip\penalty\@M\thinspace
123  \else
124  \thinspace
125  \fi
126 \fi
127 \string?}

\system@sh@:@ \system@sh@!@ \system@sh@?@ \system@sh@;@ When the active characters appear in an environment where their Russian behaviour is not wanted they should give an ‘expected’ result. Therefore we define shorthands at system level as well.

128 \declare@shorthand{system}{:}{\string:}
129 \declare@shorthand{system}{!}{\string!}
130 \declare@shorthand{system}{?}{\string?}
131 \declare@shorthand{system}{;}{\string;}

To be able to define the function of ", we first define a couple of ‘support’ macros.

\dq We save the original double quote character in \dq to keep it available, the math accent \" can now be typed as ".

132 \begingroup \catcode`\"12
133 \def\x{\endgroup
134 \def\@SS{\mathchar"7019 }
135 \def\dq{"}}

136 \x

Now we can define the doublequote macros: german and french quotes. The french quotes are maded in Russian font so they are described in lhrcod.sty

137 \declare@shorthand{russian}{"`}{%
138 \textormath{\quotedblbase{}}{\mbox{\quotedblbase}}}
139 \declare@shorthand{russian}{"'}{%
140 \textormath{\kern-.07em\textquotedblleft{}}{\mbox{\textquotedblleft}}}
141 \declare@shorthand{russian}{"<}{%
142 \textormath{\flqq}{\mbox{\flqq}}}
143 \declare@shorthand{russian}{">}{%
144 \textormath{\frqq}{\mbox{\frqq}}}

and some additional commands:

145 \declare@shorthand{russian}{""}{\hskip\z@skip}
146 \declare@shorthand{russian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
147 \declare@shorthand{russian}{"=}{\penalty\@M\hskip\z@skip}
148 \declare@shorthand{russian}{"|}{%
149 \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
150  \allowhyphens}{}}

The next two macros for "- and "--- have some difference. We must check whether the second token is a hyphen character:

151 \declare@shorthand{russian}{"-}{%

If the next token is -, we typeset an emdash, else—hyphen sign:

152 \def\russian@sh@tmp{%
153  \if\russian@sh@next-\expandafter\russian@sh@emdash
154  \else\expandafter\russian@sh@hyphen\fi

155 }%

TEX looks for the next sign after first -, the meaning of this sign it writes to

 \russian@sh@next and call \russian@sh@tmp
156 \futurelet\russian@sh@next\russian@sh@tmp}

There are the definitions of hyphen and emdash: hyphen definition:

157 \def\russian@sh@hyphen{%
158 \penalty\@M\-\allowhyphens}

emdash definition, there are the two parameters: we must “eat” two last hyphen signs of our emdash:

159 \def\russian@sh@emdash#1#2{%
160 \ifdim\lastskip>\z@
161  \unskip
162 \fi
163 \penalty\@M
164 \hskip.2\fontdimen6\font
165 \hbox to.8\fontdimen6\font{--\hss--}%
166 \hskip.2\fontdimen6\font
167 \ignorespaces}

The russian hyphenation patterns can be used with \lefthyphenmin and

 \righthyphenmin set to 2.
168 \def\russianhyphenmins{\tw@\tw@}

Now the thing \extrasrussian needs to do is to make sure that \frenchspacing is in effect. If this is not the case the execution of \noextrasrussian will switch it off again.

169 \addto\extrasrussian{\bbl@frenchspacing}
170 \addto\noextrasrussian{\bbl@nonfrenchspacing}

Now we add a new enumeration style for Russian manuscripts with Cyrillic letters and later on we define some math operatornames in accordance with Russian typesetting traditions.

\Asbuk We begin by defining \Asbuk which functions like \Alph, but produces (uppercase) cyrillic letters intead of latin ones.

171 \def\Asbuk#1{\expandafter\@Asbuk\csname c@#1\endcsname}
172 \def\@Asbuk#1{\ifcase#1\or
173 \CYRA\or \CYRB\or \CYRV\or \CYRG\or \CYRD\or \CYRE\or \CYRZH\or
174 \CYRZ\or \CYRI\or \CYRK\or \CYRL\or \CYRM\or \CYRN\or \CYRO\or
175 \CYRP\or \CYRR\or \CYRS\or \CYRT\or \CYRU\or \CYRF\or \CYRH\or
176 \CYRC\or \CYRCH\or \CYRSH\or \CYRSHCH\or \CYRErev\or \CYRYU\or
177 \CYRYA\else\@ctrerr\fi}%

\asbuk The macro \asbuk is similar to \alph, it produces lowercase Russian letters.

178 \def\asbuk#1{\expandafter\@asbuk\csname c@#1\endcsname}
179 \def\@asbuk#1{\ifcase#1\or
180 \CYRa\or \CYRb\or \CYRv\or \CYRg\or \CYRd\or \CYRe\or \CYRzh\or
181 \CYRz\or \CYRi\or \CYRk\or \CYRl\or \CYRm\or \CYRn\or \CYRo\or
182 \CYRp\or \CYRr\or \CYRs\or \CYRt\or \CYRu\or \CYRf\or \CYRh\or
183 \CYRc\or \CYRch\or \CYRsh\or \CYRshch\or \CYRerev\or \CYRyu\or
184 \CYRya\else\@ctrerr\fi}

\mathrussian Some math functions in Russian math books have other names: e.g. sinh in Russian is written as sh etc. So we define a number of new math operators.

185 \def\sh{\mathop{\operator@font sh}\nolimits} % same as \sinh
186 \def\ch{\mathop{\operator@font ch}\nolimits} % same as \cosh
187 \def\tg{\mathop{\operator@font tg}\nolimits} % same as \tan
188 \def\arctg{\mathop{\operator@font arctg}\nolimits} % same as \arctan
189 \def\arcctg{\mathop{\operator@font arcctg}\nolimits} %
190 \def\th{\mathop{\operator@font th}\nolimits} % same as \tanh
191 \def\ctg{\mathop{\operator@font ctg}\nolimits} % same as \cot
192 \def\cth{\mathop{\operator@font cth}\nolimits} % same as \coth
193 \def\cosec{\mathop{\operator@font cosec}\nolimits} % same as \csc
194 \def\Prob{\mathop{\hbox{\sfshape P}}\nolimits}
195 \def\nod{\mathop{\operator@font \CYRn.\CYRo.\CYRd.}\nolimits}
196 \def\nok{\mathop{\operator@font \CYRn.\CYRo.\CYRk.}\nolimits}
197 \def\Variance{\mathop{\hbox{\sfshape D}}\nolimits}

The macro \ldf@finish takes care of looking for a configuration file, setting the main language to be switched on at \begin{document} and resetting the category code of @ to its original value.

198 \ldf@finish{russian}

199 ⟨/code⟩