summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/babel-contrib/russian/russianb.dtx
blob: 69f8ba04da75c2c9a0261c53eac6bf0b1fa62386 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
% \iffalse meta-comment
% !TEX program  = xeLaTeX
% !Mode:: TEX:DTX:UNIX:UTF-8:US:RU
%<*internal>
\iffalse
%</internal>
%<*readme>
----------------------------------------------------------------

# Russian language module for Babel

Released under the LaTeX Project Public License v1.3c or later.
See http://www.latex-project.org/lppl.txt

The package provides support for use of Babel in documents written in Russian
(in both traditional and ancient forms). The support is adapted for use both
under legacy TEX engines, and under X∃TEX and LuaTEX.

Current version 1.3m dated by 2021-01-10

Current Maintainer is Igor A. Kotelnikov.
Submit feature request to https://github.com/kia999/babel-russian


## 1. INSTALLATION

- Unpack babel-russian.zip.
- Run "xelatex.exe russianb.dtx" (recommended)
  or "pdflatex.exe russianb.dtx";
  alternatively run "tex.exe russianb.dtx"
  or "tex.exe russianb.ins", if you don't need documentation
- Move "russianb.ldf" to <textmf>/tex/latex/babel-russian
- Move "russianb.pdf" and README to <textmf>/doc/latex/russian-babel/
- Update filename base (see documentation for your TeX system)

## 2. USAGE

Russian language definition file can be used both with legacy 8-bit engines
(such as latex.exe or pdflatex.exe) and Unicode compilers (xelatex.exe or
lualatex.exe). The Unicode engines can be ran either in Unicode mode or 8-bit
compatibility mode, which emulates the legacy engines. The two modes differ by
a set of packages loaded in the preamble of a source TeX file. It is important
to keep recommended order of the packages loaded, especially when running
Unicode engines in a compatibility 8-bit mode.

In the examples below, it is assumed that a source file to be compile
has utf8 input encoding.

### 2.1. 8-bit mode

#### 2.1.1 PDFLATeX, LaTeX

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

#### 2.1.2 LuaLaTeX

    \usepackage[T1,T2A]{fontenc}
    \usepackage[lutf8]{luainputenc}
    \usepackage[english,russian]{babel}

#### 2.1.3 XeLaTeX

    \XeTeXinputencoding "bytes"
    \usepackage[utf8]{inputenc}
    \usepackage[T2A]{fontenc}
    \usepackage[english,russian]{babel}

### 2.2 Unicode mode, LuaLaTeX or XeLaTeX

    \usepackage{fontspec}
        \defaultfontfeatures{Ligatures={TeX}}
        \setmainfont{CMU Serif}
        \setsansfont{CMU Sans Serif}
        \setmonofont{CMU Typewriter Text}
    \usepackage[english,russian]{babel}

Instead of the Computer Modern Unicode (CMU) fonts loaded in this example,
you may try any True Type or Open Type fonts installed on your computer provided
that those fonts came with Russian letters.

### 2.3 Typesetting ancient book

    \usepackage[english,russian]{babel}
    \languageattribute{russian}{ancient}
or
    \usepackage[english,russian.ancient]{babel}

Using Unicode mode is strongly recommended for typesetting ancient texts.
Be sure to take X2 or OT2 font encodings when running 8-bit engine such
as latex or pdflatex.


## 3. DOCUMENTATION

See russianb.pdf for more information.


## 4. KNOWN PROBLEMS

Before switching from a legacy 8-bit engine (tex, pdftex) to an Unicode
engine (xetex, luatex) and vise versa delete all .aux, .toc, .lot, .lof
files as they might have stored incompatible internal encodings.

T2* font encodings do not have legacy Cyrillic letters `yat', which is
hard-coded in ancient caption names. Be sure to use an Unicode engine
or borrow `\cyryat` and `\CYRYAT` commands from X2 font encoding when setting
the language attribute to "ancient", for example:

    \usepackage[X2,T2A]{fontenc}
    \usepackage[utf8]{inputenc}
    \DeclareUnicodeCharacter{0462}{\CYRYAT}
    \DeclareTextSymbolDefault{\CYRYAT}{X2}
    \DeclareUnicodeCharacter{0463}{\cyryat}
    \DeclareTextSymbolDefault{\cyryat}{X2}
    \usepackage[english,russian.ancient]{babel}

Consult your font documentation for other ancient glyphs which
might be absent.


## 5. CHANGES

2021-01-10 version 1.3m

    * The macro `\cyrdash` that prints Cyrillic dash has been changed.
      Now it is alias of `\textemdash` in all encodings.

    * New Customisation section is added to the module documentation. It
      describes how to modify the `\cyrdash` macro and shorthand `"--~"` that
      is intended to print Cyrillic dash in compound names of physical
      laws, mathematical equations, company titles, e.t.c. such as the
      Ostrogradsky-Gauss theorem (thanks to Olga Lapko).

2020-10-16 version 1.3l

    * Patches for Russian language from hyperref package to babel-russian module
      (thanks to Ulrike Fischer).

2020-09-06 version 1.3k

    * Bug fixed in definition of \Russian command (thanks to Javier Bezos).


2017-08-08 version 1.3j

    * TU encoding is set as default for X∃TeX and LuaTeX.

    * \cyrdash now always prints dash 20 percents shorter than emdash.


2017-01-12 version 1.3i

    * Bug fixed in \NOD, \NOK and similar log-functions (thanks to V. Vlasov).

2016-02-18 version 1.3h

    * Bugs fixed in captions for revtex4 and revtex4-1 classes.

    * \cyrdash is now faked using \ProvideTextCommandDefault rather
      than \def.

2015-05-01 version 1.3g

    * Added support for revtex4 and revtex4-1 classes.

2014-10-21 version 1.3f

    * A documentation file russianb.pdf can now be generated by
      running pdflatex.exe over russianb.dtx although xelatex.exe
      is still recommended.

    * russianb.ins was missed in version 1.3e.

2014-10-14 version 1.3e

    * Generating all stuff from single dtx file.

2014-10-02 version 1.3d

    * Bug fix in \Proj.

2014-06-02 version 1.3c

    * Bug fix in \daterussian.

2013-04-06 version 1.3b

    * Added support for the packages \pkg{listing}, \pkg{nomencl}, and
      \pkg{nomentbl}.

2013-04-18 version 1.3a

    * Added the language attribute 'ancient' for typesetting old
      Slavonic and Church books.

2013-04-08 version 1.3

    * Updated for babel 3.9.
    * \Alph and \alph commands are not redefined any more by russianb.ldf.

2012-06-02 version 1.2a

    * russian/russianb.dtx, v1.2a : Indentation of 1st paragraph removed;
      use the indentfirst package to automatically indent first paragraph
      after sectioning commands.

2011-10-20 version 1.2 Igor A. Kotelnikov  <kia999 at mail dot ru>

    * Added support for LuaTeX and XeTeX;
      added translation for Glossary; removed \Rus, \English,
      \Eng, \cyrmath.., \latinencoding, \latintext;
      \Russian is now an alias for \selectlanguage{russian}.

Original source:  russianb.dtx,
    2008/03/21 v1.1r Russian support from the babel system.

----------------------------------------------------------------
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
----------------------------------------------------------------
Russian Language Support for the Babel package

Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt

Current version 1.3m dated by 2021-01-10

Submit feature request at https://github.com/kia999/babel-russian
----------------------------------------------------------------
\endpreamble
\postamble
----------------------------------------------------------------
Copyright 2011-2021 Igor A. Kotelnikov.
Copyright 1995-2008 Olga G. Lapko.
Copyright 1989-2012 Johannes L. Braams.

This file is a part of the Russian-Babel package.

It may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL), either
version 1.3c of this license or (at your option) any later
version.  The latest version of this license is in the file:

   http://www.latex-project.org/lppl.txt

The package is "maintained" (as per LPPL maintenance status) by
Igor A. Kotelnikov.

The package consists of the file  russianb.dtx
and the derived files             russianb.ins,
                                  russianb.ldf,
                                  russianb.pdf,
                                  README.
----------------------------------------------------------------
\endpostamble
\usedir{tex/generic/babel/contrib}
\generate{
  \file{\jobname.ldf}{\from{\jobname.dtx}{code}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/babel-russian}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/babel-russian}
\generate{
  \file{README.md}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*code>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{russianb.ldf}[2021/01/10 1.3m Russian support for the Babel system]
%</code>
%<*driver>
\documentclass[a4paper]{ltxdoc}
%%
%% This document should be compiled by
%% XeLaTeX or LuaLaTex since some cyrillic
%% glyphs are absent in T2* encodings used
%% by LaTeX.
%%
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi>0
    \usepackage{fontspec}
    \defaultfontfeatures{Ligatures={TeX}}
    \setmainfont{cmunrm.otf}%{CMU Serif}
    %\setmainfont{STIX Two Text}
    \setsansfont{cmunss.otf}%{CMU Sans Serif}
    \setmonofont{cmuntt.otf}%{CMU Typewriter Text}
    %%\setmonofont[Scale=MatchLowercase]{Courier New}
    %%\setmonofont[Scale=MatchUppercase]{Courier New}
    %%\setmonofont{Courier New}
\else
    \usepackage[X2,T2A]{fontenc}
    \usepackage[utf8]{inputenc}
    \DeclareUnicodeCharacter{0462}{\CYRYAT}
    \DeclareTextSymbolDefault{\CYRYAT}{X2}
    \DeclareUnicodeCharacter{0463}{\cyryat}
    \DeclareTextSymbolDefault{\cyryat}{X2}
    %% serbian letter, looks as a ligature IE, not defined anywhare
    %\DeclareUnicodeCharacter{0464}{\CYRESHRT} % no surch cmd in X2
    %% serbian letter, looks as a ligature ie, not defined anywhare
    %\DeclareUnicodeCharacter{0465}{\cyreshrt} % no surch cmd in X2
    %% therefor, we substitute it with є (#0454, \cyrie)
    \DeclareUnicodeCharacter{0464}{\CYRIE}%
    %\DeclareTextSymbolDefault{\CYRIE}{X2}
    \DeclareUnicodeCharacter{0465}{\cyrie}%
    %\DeclareTextSymbolDefault{\cyrie}{X2}
\fi
\usepackage[russian.ancient,main=english]{babel}
%\languageattribute{russian}{ancient}
\usepackage[dvipsnames,usenames]{xcolor}
    \definecolor{thered}  {rgb}{0.65,0.04,0.07}
    \definecolor{thegreen}{rgb}{0.06,0.44,0.08}
    \definecolor{thegrey} {gray}{0.8}
    \definecolor{theshade}{rgb}{1,1,0.97}
    \definecolor{theframe}{gray}{0.6}
    \definecolor{theblue}{cmyk}{1.00, 0.50, 0.00, 0.40}
%\usepackage[numbered]{hypdoc}
\usepackage[colorlinks=true
    ,linkcolor=violet %theblue %
    ,filecolor=purple %thegreen%
    ,citecolor=teal   %thegreen%
]{hyperref}
% ====================================
\newcommand*\TeXhax{\TeX hax}
\newcommand*\babel{\textsf{babel}}
\newcommand*\Babel{\textsf{Babel}}
\newcommand*\xetex{\textsf{xetex}}
\newcommand*\luatex{\textsf{luatex}}
\providecommand*\m[1]{\mbox{$\langle$\normalfont\itshape#1\/$\rangle$}}
\newcommand*\langlist{%
  \meta{language}\texttt{,}\meta{language}\texttt{,}...}
\newcommand*\langvar{\m{lang}}
\newcommand*\note[1]{}
\newcommand*\Lopt[1]{\textsf{#1}}
\newcommand*\Lenv[1]{\textsf{#1}}
\newcommand*\menv[1]{\char`\{#1\char`\}}
\newcommand*\Eenv[1]{%
  \quad\ldots\quad
  \texttt{\color{thered}\string\end\menv{#1}}}
\newcommand*\file[1]{\texttt{#1}}
\newcommand*\cls[1]{\texttt{#1}}
\newcommand*\pkg[1]{\texttt{#1}}
% ====================================
\IfFileExists{listings.sty}{
  \usepackage{listings}
  \lstset{
    gobble=1,
    columns=flexible,
    keepspaces,
    basicstyle=\MacroFont,
    keywords=[0]{\selectlanguage,\foreignlanguage
     ,\babelhyphen,\babelhyphenation
     ,\lefthyphenmin,\righthyphenmin
     ,\StartBabelCommands,\SetString,\EndBabelCommands,\shorthandoff,\shorthandon
     ,\languageshorthands,\useshorthands,\defineshorthand
     ,\AddBabelHook,\SetStringLoop,\SetCase,\AfterBabelLanguage
     ,\defaultfontfeatures,\setmainfont,\setsansfont,\setmonofont
     ,\Russian,\cyrdash,\cdash, \textemdash, \textemdash
     ,\cyr,\cyrillictext,\textcyrillic,\cyrillicencoding
     ,\addto,\captionsrussian,\daterussian,\noextrasrussian,\extrasrussian
     ,\languageattribute
     ,\glqq,\grqq,\guillemotleft,\guillemotright
     ,\Asbuk,\asbuk,\ch,\sh,\tg,\ctg,\arctg,\arcctg\,\th,\cth,\cosec
     ,\nod,\nok,\prog,\NOF\,\NOK,\Prog
     ,\dq,\Proj,\nod,\NOD,\nok,\NOK,\Prob,\Variance
     ,\XeTeXinputencoding
     ,xetex,luatex,tex, pdftex
     ,xelatex,lualatex,latex, pdflatex
     ,en,em,ex
    }
    ,keywordstyle=[0]\color{thered}
    ,keywords=[1]{main,russian,english,german,frenchb
     ,shorthands,extrasenglish
     ,stringprocess,afterextras
     ,soft,empty,nobreak,hard
     ,Renderer,Ligatures
     ,modern,ancient,standard
     ,T1,T2A,lutf8,utf8
     ,fontspec,babel,inputenc,fontenc,graphicx
     },
    keywordstyle=[1]\color{thegreen},
    comment=[l]\%,
    commentstyle=\color{thegrey}\itshape,
    alsoother={0123456789_},
    frame=single,
    backgroundcolor=\color{theshade},
    rulecolor=\color{theframe},
    framerule=\fboxrule,
  }
  \let\verbatim\relax
  \lstnewenvironment{verbatim}[1][]{\lstset{##1}}{}
  \AtBeginDocument{%
    \DeleteShortVerb{\|}%
    \lstMakeShortInline|%
  }
}{}
\def\PrintDescribeMacro#1{%
  \strut\MacroFont\color{thered}\normalsize\string#1}
\def\Describe#1{%
  \par\penalty-500\vskip3ex\noindent
  \DescribeMacro{#1}\args}
\def\DescribeOther{\vskip-5.8ex\Describe}
\makeatletter
\def\args#1{%
  \def\bbl@tempa{#1}%
  \ifx\bbl@tempa\@empty\else#1\vskip1ex\fi\ignorespaces}
\makeatother
% ====================================
\EnableCrossrefs
%\DisableCrossrefs   % Say \DisableCrossrefs if index is ready
\CodelineIndex       % Index code by line number
\RecordChanges       % Gather update information
%\PageIndex          % Index code by page number
% ====================================
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \DoNotIndex{\cyra,\cyrb,\cyrv,\cyrg,\cyrd,\cyre}
% \DoNotIndex{\CYRP,\cyrii,\cyrr,\cyre,\cyro,\CYRU,\cyrk,\cyrl,\CYRS,\cyrs|}
% \DoNotIndex{\cyrt,\cyri,\cyrz,\CYRT,\cyrm}
% \DoNotIndex{\cyr,\cyrc,\CYRD,\cyrery,\cyrh,\CYRK,\CYRM,\CYRN,\cyrn}
% \DoNotIndex{\cyrp,\cyrs,\cyrshch,\cyru,\CYRV,\cyrya}
% \DoNotIndex{\CYRA,\CYRB,\cyrch,\CYRE,\CYREREV,\CYRF,\cyrf,\CYRI,\cyrishrt}
% \DoNotIndex{\CYRO,\CYRR,\cyrsftsn,\CYRYA,\cyryu,\cyrzh}
% \DoNotIndex{\CYRSH,\cyrsh,\CYRSHCH,\CYRYU,\CYRZ,\CYRZH,\CYRG,\CYRH}
% \DoNotIndex{\z@skip,\z@}
% \DoNotIndex{\|,\~,\ }
% \DoNotIndex{\\&,\',\(,\),\`,\\,\/,\.}
% \DoNotIndex{\begin,\DeclareUTFcharacter}
% \DoNotIndex{\csname,\def}
% \DoNotIndex{\else,\endcsname,\end}
% \DoNotIndex{\expandafter,\fi}
% \DoNotIndex{\hbox,\hss}
% \DoNotIndex{\iffalse,\ifx,\ignorespaces,\iflanguage}
% \DoNotIndex{\language,\lastskip,\ldots,\let,\natexlab,\newblock,\nobreak}
% \DoNotIndex{\providecommand,\ProvideTextCommandDefault,\relax,\renewcommand}
% \DoNotIndex{\selectlanguage,\selectlanguageifdefined,\small,\textemdash}
% \DoNotIndex{\or,\if,\fi,\unskip,\url,\UTFencname}
% \DoNotIndex{\,,\catcode,\cite,\citeauthor,\citet,\citeyear,\href,\hskip,\ifdim}
%
%\GetFileInfo{russianb.dtx}
%\GetFileInfo{russianb.ldf}
%
% \title{The Russian Language\\
%  in the \babel\ system\\[0.5em]
%  \large Version \fileversion}
%
% \author{Igor A. Kotelnikov\footnote{E-mail: \href{mailto:kia999@mail.ru}{kia999 at mail dot ru}.}}
%
% \date{Released \filedate}
%
% \maketitle
%
% {\small\tableofcontents}
%
%
% \section{The Russian Language Definition File}
%
% The file \file{\filename}\footnote{The file described in this document
% has the version number \fileversion\ and was last revised on \filedate.}
% is the source file for the Russian Language Definition file
% \file{russianb.ldf} to be loaded by the \babel\ package with
% the option \Lopt{russian}. It was derived by Igor A.
% Kotelnikov from the original version of \file{\filename}, first
% released by Olga Lapko and Johannes Braams and then
% adapted to the T2* and X2 Cyrillic encodings
% by Vladimir Volovich  and Werner Lemberg.
%
% Starting the version 1.2, \file{russianb.ldf} is designed to work both with
% legacy non-unicode (8-bit) and new Unicode encodings of the source document
% files (input encodings) and of the font files (font encodings). This is
% achieved by excluding (bypassing) the |\cyr...| macros, which map every letter
% in a source file with given input encoding to a corresponding code point in a
% font file with a given font encoding when running modern engines, such as
% Lua\LaTeX\ or Xe\LaTeX, in native Unicode mode instead of legacy engines, such
% as \LaTeX\ or PDF\LaTeX, or Unicode engines in a compatibility (8-bit) mode. A
% few obsolete and controversial macros has been eliminated in first public
% release of version 1.2 of \file{russianb.ldf}.
%
% The version 1.3 of \file{russianb.ldf} has been adapted to new features
% introduced in the version 3.9 of the \pkg{babel} package. In particular, the
% language attribute \Lopt{ancient} has been introduced to support typesetting
% ancient and Church Slavonic books.
%
% \section{Usage}
%
% Typesetting Russian texts implies that a special input and output
% encodings should be used. Input encodings are those which are used in source
% (\file{.tex}) file. Output encoding is also known as the font encoding. It is
% implemented within the font files.
%
% Generally, the user may choose between different available Cyrillic
% encodings. The current support for Cyrillic uses LH family of MetaFont fonts
% and theirs Postscript versions such as CM-super. Lua\LaTeX\ and Xe\LaTeX,
% being the Unicode-based succeeders of \LaTeX, allow also for any Open Type
% (OTF) and True Type (TTF) fonts which have Cyrillic script, e.g. Computer
% Modern Unicode, Linux Libertine, and many other system fonts that came with
% Linux, Mac and Windows operating systems.
%
% With the advent of Unicode, \LaTeX\ community are moving towards eliminating
% all existing encodings in favor of Unicode, but nowadays one should take
% care when switching from \LaTeX\ to Lua\LaTeX\ or Xe\LaTeX\ since
% different packages should be loaded for those compilers.
%
% Since earlier versions \pkg{babel} did not
% support Xe\LaTeX\ (at least for some languages including Russian), the
% \pkg{polyglossia} package was generally recommended in the past for
% use with Xe\LaTeX\ as a replacement for \pkg{babel}. Nowadays, \pkg{babel}
% can be used with any engines, including \LaTeX, PDF\LaTeX, Lua\LaTeX, and
% Xe\LaTeX. Nevertheless some troubles may occur with some languages which
% have no promptly updated \file{.ldf} files.
%
%
% \subsection{\LaTeX}
%
% When user's document is compiled with \file{latex.exe} or \file{pdflatex.exe},
% recommended set of packages  includes the \pkg{inputenc} and \pkg{fontenc}
% packages. They should be loaded before \pkg{babel}, for example,
% \begin{verbatim}
%    \usepackage[T1,T2A]{fontenc}
%    \usepackage[utf8]{inputenc}
%    \usepackage[english,russian]{babel}
%\end{verbatim}
% Some variations in the order of loading the packages are allowed in this case
% but it is better to follow one and the same convention at all circumstances:
% the \pkg{babel} package should go last, and \pkg{fontenc} must be the first.
%
% Input encoding should be declared as option to the \pkg{inputenc}
% package. Known Cyrillic encodings include \texttt{cp866} (MS DOS),
% \texttt{cp1251} (Windows), \texttt{koi8-u} (UNIX) and their variants.
% Nowadays, this list is appended with \texttt{utf8} input encoding.
%
% Output encodings (also known as font encodings) are declared as options to
% the \pkg{fontenc} package. Known Cyrillic encodings are \texttt{T2A},
% \texttt{T2B}, \texttt{T2C}, \texttt{LCY},  and \texttt{X2};
% \texttt{LWN} is excluded from Russian support starting version 1.2 of
% \file{\filename} since \texttt{LWN} is excluded from the \pkg{cyrillic}
% bundle of related files.
%
%
% \subsection{Lua\LaTeX}
%
% If Unicode fonts are not available, Lua\LaTeX\ can run in compatibility
% (8-bit) mode to use same font as \LaTeX\ does. However the package
% \pkg{inputenc} does not work with Lua\LaTeX\ and should be substituted with
% \pkg{luainputenc}. Source file is to be converted to \texttt{UTF8}
% (Unicode-8) encoding; it is the only input encoding accepted by
% Lua\LaTeX. The 8-bit mode is invoked by the following sequence of packages:
%\begin{verbatim}
%\usepackage[T1,T2A]{fontenc}
%\usepackage[lutf8]{luainputenc}
%\usepackage[english,russian]{babel}
%\end{verbatim}
% The order of the packages is crucial for Lua\LaTeX\ in 8-bit mode. Since both
% \pkg{luainputenc} and \pkg{babel} should know what font encoding is selected,
% the \pkg{fontenc} package should be loaded first. Legacy input encoding
% management for Lua\TeX\ is needed only for compatibility with old documents.
% For new documents, using UTF-8 encoding and Unicode fonts is strongly
% recommended. \emph{You've been warned!} See
% \href{http://tex.stackexchange.com/questions/31709/can-one-instruct-lualatex-to-use-t2a-encoded-fonts}%
% {tex.stackexchange.com/questions/31709/can-one-instruct-lualatex-to-use-t2a-encoded-fonts}.
%
%
% To invoke Unicode mode, one needs to load the \pkg{fontspec} package instead
% of \pkg{luainputenc} and \pkg{fontenc} and explicitly indicate which True Type
% or Open Type fonts should be used for romanic, sans-serif and monospaced types.
% The following example shows how to load Computer Modern Unicode (CMU) fonts,
% which is a part of all modern \LaTeX\ distributions:
%\begin{verbatim}
%\usepackage{fontspec}
%  \defaultfontfeatures{Renderer=Basic,Ligatures={TeX}}
%  \setmainfont{CMU Serif}
%  \setsansfont{CMU Sans Serif}
%  \setmonofont{CMU Typewriter Text}
%\usepackage[english,russian]{babel}
%\end{verbatim}
% The |\defaultfontfeatures| declares default font features for subsequent
% |\setmainfont| (which sets romanic fonts), |\setsansfont| (sans-serif) and
% |\setmonofont| (monospaced font). Font features can be set up on per font
% bases; for example
% \begin{verbatim}
% \usepackage{fontspec}
%    \setmainfont[Renderer=Basic,Ligatures={TeX}]{CMU Serif}
%    \setsansfont[Renderer=Basic,Ligatures={TeX,Historic}]{CMU Sans Serif}
%    \setmonofont{CMU Typewriter Text}
% \usepackage[english,russian]{babel}
%\end{verbatim}
% Here |Renderer=Basic,Ligatures={TeX}| activates ligatures available in \LaTeX.
%
% Recall that the language enlisted last in the list of options of the \pkg{babel}
% package is assumed to be the main language of the document, which is also active
% language right after |\begin{document}|. As of version 3.9, the main language
% can be set as a value of the |main| option as follows
%\begin{verbatim}
% \usepackage{fontspec}
% \usepackage[english,main=russian,german]{babel}
%\end{verbatim}
% %\unskip
%
%
%
% \subsection{Xe\LaTeX}
%
% In Xe\LaTeX, there is also a special mode for 8-bit compatibility.
% One can use |\XeTeXinputencoding| to change the input encoding
% temporarily, and the \texttt{"bytes"} encoding makes Xe\LaTeX\ to work
% like a 8-bit \LaTeX\ engine:
% \begin{verbatim}
% \XeTeXinputencoding "bytes"
% \usepackage[utf8]{inputenc}
% \usepackage[T2A]{fontenc}
% \usepackage[english,russian]{babel}
%\end{verbatim}
% \unskip
% Xe\TeX\ can use a different input encoding but it always uses the Unicode
% internally, so that |\XeTeXinputencoding| performs a conversion of the input
% stream into Unicode;
% see \href{http://tex.stackexchange.com/questions/36188/do-xetex-and-luatex-always-use-unicode}
% {tex.stackexchange.com/questions/36188/do-xetex-and-luatex-always-use-unicode}.
%
%
% Unicode mode is set up same way as for Lua\LaTeX, however the option
% |Renderer=Basic| can be dropped:
%\begin{verbatim}
% \usepackage{fontspec}
%    \defaultfontfeatures{Ligatures={TeX}}
%    \setmainfont{CMU Serif}
%    \setsansfont{CMU Sans Serif}
%    \setmonofont{CMU Typewriter Text}
% \usepackage[english,russian]{babel}
%\end{verbatim}
% %\unskip
%
%
% \subsection{Modern and Ancient spelling}
% \label{ssec:speeling}
%
% By default, a modern spelling is enabled. For Church Slavonic and other old books
% ancient spelling can be enabled by setting the attribute to \Lopt{ancient}. To set
% an attribute, put the |\languageattribute| macro within a document preamble after
% \babel, for example,
%\begin{verbatim}
% \usepackage[english,russian]{babel}
% \languageattribute{russian}{ancient}
%\end{verbatim}
% Setting the \Lopt{ancient} attribute changes the built-in strings (caption names)
% and a date format. For example, the bibliography will be entitled as
% `\textcyrillic{Литература}' by default and as `\textcyrillic{Библіографія}' if the
% Russian language attribute is set to \Lopt{ancient}.
% Same result can be achieved using a modifier as follows:
%\begin{verbatim}
%\usepackage[english,russian.ancient]{babel}
%\end{verbatim}
% Using a modifier in a package option is often better. A modifier is set after
% the language name, and is prefixed with a dot (only when the language is set
% as package option – neither global options nor the main key accept them).
%
%
% \section{User's commands}
%
% In a multilingual document, some typographic rules are language
% dependent and should apply to the whole document.
%
%^^AAs of version~1.2, \file{russianb.ldf} behaves differently
%^^Aaccording to \babel's \emph{main language} defined as the \emph{last}
%^^Aoption. When Russian is
%^^A|babel|'s main language, it adjusts global layout of the document
%^^Aaccording to typographical conventions of Russian language. Namely,
%^^A\file{russianb.ldf} makes the following changes to global layout even
%^^Ain the parts where Russian is not current language:
%^^A\begin{enumerate}
%^^A\item
%^^A    the first paragraph of any section becomes indented (\LaTeX{} only).
%^^A    (this is obsolete statement starting from version 1.2a)
%^^A\end{enumerate}
%
% Regarding local typography, the macro |\selectlanguage{russian}|
% switches to the Russian language, with the following effects:
% \begin{enumerate}
% \item Russian hyphenation patterns are made active;
% \item |\today| prints the date in Russian;
% \item the caption names are translated into Russian;
% \item emdash typed by the ligature |---| might be 20\% shorter when Russian
% is the current language; the result depends on the current encoding; |---|
% always produce long emdash in Lua\TeX\ and Xe\TeX\ since these engines
% use same encodings for all languages;
% \item emdash typed by the ligature |"---| in Russian is 20\% shorter, however
% the ligature |"---| might not be defined in other languges; a
%      shorter emdash (i.e. |\cyrdash|) can be typeset in any language using
%      special macros enlisted in table \ref{tab:russian-quote}.
% \end{enumerate}
%
% By default, a modern spelling is used for built-it strings (caption names) and
% the date. The spelling can be reverted to ancient by setting the language
% attribute to \Lopt{ancient} in the document preamble as discussed in
% Sec.~\ref{ssec:speeling}.
%
% Since Russian has its own numbering system, \file{russianb.ldf} adds macros
% |\asbuk|\marg{counter} and |\Asbuk|\marg{counter} for formatting numbers appropriately the alphabetic
% sequence in the Russian alphabet. Additional commands are provided
% to typeset quotes:
% \begin{enumerate}
% \item French quotation marks can be entered using the commands
%      |\guillemotleft| and |\guillemotright| which work in \LaTeXe\
%      and Plain\TeX.
% \item German quotation marks can be entered using the commands
%      |\glqq| and |\grqq| which work in \LaTeXe\ and Plain\TeX.
% \end{enumerate}
%
% The macro |\Russian| is now defined as an alias for
% |\selectlanguage{russian}|, and its ``opponent'' |\English|, existed
% in \file{russianb.ldf} prior to version 1.2 has been removed since the Russian
% language definition file is wrong place for definition of macros which
% switch to a distinct other language.
%
% The macro |\textcyrillic|\marg{text} is intended to typeset small chunks of text
% in Russian; it is essentially an alias for |\foreignlanguage{russian}|\marg{text}.
%
%
% \subsection{Active character}
%
% Table~\ref{tab:russian-quote} shows macros and active string which can be
% used to typeset various dashes and quotes.
% In the Russian language, the character |"| is made active. It can be
% considered as second escape character in addition to |\|. Some dashes and
% all quotes can be typed using both active character |"| and ordinary
% macros as indicated in the table. However, some shorthanded hyphenations
% have no macro counterpart.
%
% \begin{table}[ht]\centering
%  \caption{Extra definitions made
%           by \file{russianb.ldf}}\label{tab:russian-quote}
%  \medskip
%  \begin{tabular}{llp{7cm}}
%  \hline\hline\\[-0.5em]
%   |\glqq| & |"`| &
%       German opening double quote (looks like ,\kern-0.08em,).     \\
%   |\grqq| & |"'| &
%       German closing double quote (looks like ``).                 \\
%   |\guillemotleft| & |"<| &
%       French opening double quote (looks like $<\!\!<$).           \\
%   |\guillemotright| & |">| &
%       French closing double quote (looks like $>\!\!>$).           \\
%   |\dq|   &  &
%       Original quotes character (|"|).                       \\[0.5em]
%   |\babelhyphen{soft}|
%   & |"-| & Optional (soft) hyphen sign, similar to |\-| but allows
%            hyphenation in the rest of the word;
%            equivalent to |\babelhyphen{soft}| in \pkg{babel} 3.9. \\
%   |\babelhyphen{empty}|
%   & |""| & Similar to |"-| but prints no hyphen sign
%            (used for compound words with hyphen, e.g. |x-""y|);
%            equivalent to |\babelhyphen{empty}| in \pkg{babel} 3.9. \\
%   |\babelhyphen*{nobreak}|
%   & |"~| & Compound word mark without a breakpoint, prints hyphen
%            prohibiting hyphenation at the point;
%            equivalent to |\babelhyphen*{nobreak}| in \pkg{babel} 3.9. \\
%   |\babelhyphen{hard}|
%   & |"=| & A compound word mark with a breakpoint, prints hyphen
%            allowing hyphenation in the composing words.
%            equivalent to |\babelhyphen{hard}| in \pkg{babel} 3.9. \\
%   |\babelhyphen{nobreak}|
%   & \verb="|= & Disables ligature at this position;
%            equivalent to |\babelhyphen{nobreak}| in \pkg{babel} 3.9.
%                                                                  \\[0.5em]
%   |\cyrdash|  &        & Raw Cyrillic emdash (does not care
%       spaces around).                                            \\
%   |\cdash---| & |"---| &
%       Cyrillic emdash in plain text.                              \\
%   |\cdash--~| & |"--~| &
%       Cyrillic emdash in compound names
%                                 (as in |Mendeleev"--~Klapeiron|). \\
%   |\cdash--*| & |"--*| &
%       Cyrillic emdash for denoting direct speech.                           \\
%   & |",| & Thin space
%               (allows further hyphenation as in |D.",Mendeleev|). \\[0.5em]
%  \hline\hline
%  \end{tabular}
% \end{table}
% Note that the standard soft hyphen |\-| is equivalent to |\babelhyphen*{soft}|.
%
% \medskip
%
% The quotation marks traditionally used in Russian were borrowed from
% other languages (e.g., French and German) so they keep their original
% names.
%
% The French quotes are also available as ligatures `|<<|' and `|>>|' in
% 8-bit Cyrillic font encodings (\texttt{LCY}, \texttt{X2}, \texttt{T2*})
% and in Unicode encoding (\texttt{TU}) as `|<|' and `|>|' characters in 7-bit
% Cyrillic font encodings (\texttt{OT2} and \texttt{LWN}).
%
% In Unicode encoding \texttt{TU} cyrdashes and quotes
% can be typed as single character if your text editor allows
% inserting characters which absent of standard keyboard. This method works
% as well for 8-bit fonts encoded according to \texttt{T2A} if source file
% is encoded with \texttt{cp1251} or {utf8}.
%
% By default, active double quote is switched on. It can be switched off
% any time using |\shorthandoff{"}| and the switched on again using
% |\shorthandon{"}|. The aliases |\mdqoff| and |\mdqon| for these two macros
% has been removed from \file{russianb.ldf} starting from version 1.3 in favour of
% the macros |\shorthandon| and |\shorthandoff| provided in the \pkg{babel} core.
%
%
% \subsection{Math commands}
%
% \file{\filename} defines few macros than can be used independently
% of current language. These are 9 macros to be used in math mode to type
% the names of trigonometric functions common for Russian documents:
% |\sh|, |\ch|, |\tg|, |\ctg|, |\arctg|, |\arcctg|, |\th|, |\cth|, and
% |\cosec|. Cyrillic letters in math mode can be typed with the aid of
% text commands such as |\textbf|, |\textsf|, |\textit|, |\texttt|, e.t.c.
%
% The macros |\Prob|, |\Variance|, |\NOD|, |\nod|, |\NOK|, |\nok|, |\Proj|
% print  some rare Russian mathematical symbols.
%
%
% \section{Customisation}
%
%   Starting with the version 1.3m, the definition of the |\cyrdash| command has
%   been changed. Recall that |\cyrdash| prints the Cyrillic dash and is called
%   by the shorthands listed above in the table. Now |\cyrdash| is defined as
%   an alias of the |\textemdash| vommand, which is available in all font
%   encodings.  If you agree with some modern tendencies that the length of
%   the |\textemdash| dash is too long, change the |\cyrdash| command at your
%   choice. Recommended method is shown in the example below:
%\begin{verbatim}
%\usepackage{graphicx}
%\usepackage[english,russian]{babel}
%\renewcommand{\cyrdash}{\scalebox{0.75}[1]{\textemdash}}
%\end{verbatim}
%   Note that such a definition assumes that the package |graphicx| is also
%   loaded. The shown above definition partially mimics the state of arts
%   which has been existed for many years for 8-bit engines but it ensure
%   that the Cyrillic dash is 25\% shorter than the em-dash for any family
%   of fonts, not only CM fonts especially designed for legacy \LaTeX.
%
%   As explaned in the Implementation section, the |\@Bcdash| command invoked
%   ny the shorthand |"--~| prints the Cyrillic dash in compound names
%   of theorems, laws, equations, companies, e.t.c.  composed of the names of
%   two or more people. By default, |\@Bcdash| adds no spaces around the dash.
%   Some publishers recommend to add |2pt| spaces on both sides of the dash in
%   compound names. If you wish to follow such an advice, redefine the
%   |\@Bcdash| command as shown below:
%\begin{verbatim}
%\usepackage[english,russian]{babel}
%\makeatletter
%\def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
% \nobreak\kern2\p@\cyrdash\penalty\exhyphenpenalty\hskip2\p@\ignorespaces}%
%\makeatother
%\end{verbatim}
%   Note that there is no consensus on what should be the spaces around the
%   dash in compound names. Although |2pt| spaces are recommended by many
%   publishers, they make the dash in compound names hardly distinguishable
%   from regular dash is other parts of the text. As a palliative solution, you
%   can limit yourself to |1pt| spaces:
%\begin{verbatim}
%\usepackage[english,russian]{babel}
%\makeatletter
%\def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
% \nobreak\kern\p@\cyrdash\penalty\exhyphenpenalty\hskip\p@\ignorespaces}%
%\makeatother
%\end{verbatim}
%   Compound names composed of names of two or more people should be
%   distinguished from double names of single person such as
%   Jean-Jacques Rousseau or Nemirovich-Danchenko, which instead of a dash
%   should be written with a hyphen without spaces around it.
%
%   See discussion at \href{https://ru.wikipedia.org/wiki/Обсуждение:Тире#Тире_между_фамилиями_людей}
%   {Тире между фамилиями людей}.
%
%
% \section{\TeX{}nical details}
%
%   The packages \pkg{inputenc} and  \pkg{luainputenc}
%   make Cyrillic letters active so that a compiler converts them into
%   corresponding |\cyr...| macro at compilation time.
%   For example, Russian letter `a' matches
%   macro |\cyra|, and capital Russian letter `A' matches |\CYRA|. The
%   package \pkg{fontenc} then matches every macro |\cyr...| to corresponding
%   glyph in a font file depending on a declared font encoding.
%
%   Nowadays, Unicode makes |\cyr...| macros outdated since both source
%   file and font file are encoded consistently. These macros
%   should therefore be removed because mixing them with Unicode characters
%   breaks sorting mechanism of such utilities as \file{bibtex} and
%   \file{makeindex}. For the sake of backward compatibility, |\cyr...| are
%   still kept for \LaTeX, but they are bypassed if Lua\LaTeX\ or  Xe\LaTeX\
%   are detected.
%
%   Some inconsistences of prior versions of \file{\filename} was also
%   overcame in the version 1.2. Those users who used |\selectlanguage| macro,
%   defined in the core \pkg{babel} system, to switch between
%   different languages should not worry. However, the macros
%   |\Russian|, |\Englsih| and their aliases |\Rus|, |\cyr|,
%   |\Eng| are modified or removed as they did not
%   conform the mechanism of language switching encoded into the
%   core of \pkg{babel} and therefore can mess it.
%
%
% \section{Known problems}
%
%    Before switching from a legacy 8-bit engine (|latex|, |pdflatex|) to an
%    Unicode engine (|xelatex|, |lualstex|) and vise versa delete all |.aux|,
%    |.toc|, |.lot|, |.lof| files as they might have stored incompatible
%    internal encodings.
%
%    |T2*| font encodings do not have old Slavonic letter `yat' (Ѣ, ѣ), which is
%    hard-coded in ancient caption names. Be sure to use an Unicode engine
%    or borrow |\cyryat| and |\CYRYAT| commands from X2 font encoding when setting
%    the language attribute to ``ancient'', for example:
%
%\begin{verbatim}
%\usepackage[X2,T2A]{fontenc}
%\usepackage[utf8]{inputenc}
%\DeclareUnicodeCharacter{0462}{\CYRYAT}
%\DeclareTextSymbolDefault{\CYRYAT}{X2}
%\DeclareUnicodeCharacter{0463}{\cyryat}
%\DeclareTextSymbolDefault{\cyryat}{X2}
%\usepackage[english,russian.ancient]{babel}
%\end{verbatim}
%
%    None of Cyrillic font encoding has `iotated E' (Ѥ, ѥ). When running legacy
%    engines you are advised to substitute it with |\CYRIE|, |\cyrie| (Є, є):
%
%\begin{verbatim}
%\DeclareUnicodeCharacter{0464}{\CYRIE}
%\DeclareUnicodeCharacter{0465}{\cyrie}
%\end{verbatim}
%
%    The dash might change its length after switching the current language
%    with |\selectlanguage|. Legacy engines (\texttt{latex.exe},
%    \texttt{pdflatex.exe}) take the dash symbol (---) from same code
%    point 22 of a font file but from different fonts for Cyrillic and Latin
%    languages. Cyrillic fonts take care that Cyrillic dash is 20\% shorter than
%    Latin one. Unicode engines (\texttt{xelatex.exe}, \texttt{lualatex.exe})
%    take the dash from the code point x2022, but may substitute the font dash
%    with fake symbol which is shorter. See discussion at
%    \href{https://tex.stackexchange.com/questions/294178/what-about-cyrdash-in-eu1-and-eu2-encodings}
%    {https://tex.stackexchange.com/questions/294178/what-about-cyrdash-in-eu1-and-eu2-encodings}.
%
%
% \StopEventually{
%   \IndexPrologue{\section{Index}
%       Numbers written in dark blue refer to the page where the corresponding
%       entry is described; numbers in black roman refer to the code lines where
%       the entry is used.
%   }
%   \GlossaryPrologue{\section{Change History}}
%   \PrintChanges
%   \PrintIndex
% }
%
%\iffalse
%<*code>
%\fi
%
%
%    \section{Implementation}
%
% \changes{1.3m}{2021/01/10}{\cs{cyrdash} is now alias to \cs{textemdash}}
% \changes{1.3l}{2020/10/16}{Added support to hyperref package}
% \changes{1.3k}{2020/09/06}{Bug in definition of \cs{Russian} fixed}
% \changes{1.3h}{2016/02/18}{\cs{cyrdash} is redefined}
% \changes{1.3h}{2016/02/18}{Bugs fixed in captions for revtex4 and revtex4-1}
% \changes{1.3g}{2015/05/01}{Added support for revtex4 and revtex4-1 classes}
% \changes{1.3f}{2014/10/21}{Update documentation for generating by pdflatex.exe}
% \changes{1.3e}{2014/10/14}{Update documentation}
% \changes{1.3d}{2014/10/02}{Fix bug in \cs{Proj}}
% \changes{1.3c}{2014/06/02}{Fix bug in \cs{daterussian}}
% \changes{1.3b}{2013/04/06}{Renamed to russianb to work with babel 3.9}
% \changes{1.2b}{2013/01/08}{Renamed to russianu to work with babel-beta 3.9}
% \changes{1.2a}{2012/06/06}{Indentation of 1st paragraph removed}
% \changes{1.1c}{1996/07/11}{Replaced \cs{undefined} with
%    \cs{@undefined} and \cs{empty} with \cs{@empty} for consistency
%    with \LaTeX}
% \changes{1.1d}{1996/10/10}{Moved the definition of
%    \cs{atcatcode} right to the beginning.}
% \changes{1.1k}{1999/08/19}{replaced all \cs{penalty}\cs{@M}
%    with \cs{nobreak}}
% \changes{1.1f}{1998/06/26}{%
%    Added definitions of Cyrillic emdash stuff and thinspace}
% \changes{1.1f}{1998/06/26}{%
%    Added definitions of Cyrillic emdash stuff and thinspace}
%
%
%    \subsection{Initial setup}
%
%    The macro |\LdfInit| performs a couple of standard checks that
%    must be made at the beginning of a language definition file,
%    such as checking the category code of the \texttt{@}-sign, preventing
%    the \file{.ldf} file from being processed twice, etc.
%
% \changes{1.1d}{1996/11/03}{Now use \cs{LdfInit} to perform
%    initial checks}
% \changes{1.1e}{1996/12/29}{Added closing brace to second
%    argument of \cs{LdfInit}}
%    \begin{macrocode}
\ProvidesLanguage{russian}
    [2020/09/09 1.3k Russian support for the Babel system]
\LdfInit{russian}{captionsrussian}
%    \end{macrocode}
%
%    First, we check if Lua\LaTeX\ or Xe\LaTeX\ is running. If so, we set
%    boolean key |\if@uni@ode| to true. It will be used to eliminate |\cyr...|
%    commands, which were introduced in \LaTeX2e\ to handle various
%    Cyrillic input encoding. With the advent of Unicode \LaTeX\ is
%    moving to universal input encoding, so we consider these |\cyr...|
%    commands as obsolete. They are preserved though for backward
%    compatibility in case if \LaTeX\ or PDF\LaTeX\ are running.
%
%    We don't load the \pkg{ifluatex} or \pkg{ifxetex} package because
%    |\RequirePackage| is not allowed at the stage of processing options
%    (note that babel loads this file right when it processes its own options)
%    but we borrow code from these packages.
%
% \changes{1.2}{2011/10/20}{Check for LuaTeX}
%    \begin{macrocode}
\ifdefined\if@uni@ode
  \PackageError{babel}{if@uni@ode already defined.\MessageBreak
    Please contact author of russianb.ldf}
  \relax
\fi
\newif\if@uni@ode
\ifdefined\luatexversion \@uni@odetrue \else
\ifdefined\XeTeXrevision \@uni@odetrue \fi\fi
%    \end{macrocode}
%
%    Check if hyphenation patterns for the Russian language have been
%    loaded in \file{language.dat}. Namely, we check for the existence of
%    |\l@russian|. If it is not defined, we declare Russian as dialect
%    for the default language number 0 which almost for sure is English.
%
%    \begin{macrocode}
\ifx\l@russian\@undefined
  \@nopatterns{Russian}
  \adddialect\l@russian0
\fi
%    \end{macrocode}
%    Now |\l@russian| is always defined.
%
%    \subsection{Output encoding}
%
%    We need to know font encoding that is supposed to be
%    active at the end of the \babel\ package. Default font encoding, set by
%    \LaTeX\ core, is \texttt{OT1}. This can be changed by the \pkg{fontenc}
%    package in case of \LaTeX\ and by \pkg{fontspec} package in case of
%    Lua\LaTeX. It matters weather these packages are loaded before of after
%    \pkg{babel}. In the latter case or if these packages are not loaded at all,
%    \file{russianb.ldf} ignores their effect and tries to provide some
%    reasonable settings. In particular, \texttt{T2A} will be selected for
%    Russian language if \LaTeX\ is running but \texttt{TU} in case of
%    Xe\LaTeX\ or Lua\LaTeX.
%
%  \begin{macro}{\latinencoding}
% \changes{1.2}{2011/10/20}{Removed \cs{latinencoding}}
%
%    The macro |\latinencoding| keeps the name of Latin encoding. It is
%    defined in \file{babel.def} and is wrapped into |\AtBeginDocument| to allow
%    for late loading \pkg{fontenc}. Therefore it does not matter
%    whether \pkg{babel} is loaded before or after the \pkg{fontenc}.
%    As of version 1.2, definition of |\latinencoding| was removed from
%    \file{russianb.ldf} since it is overruled in \file{babel.def}.
%    For example, after
%\begin{verbatim}
%\usepackage[T1,T2A]{fontenc}
%\usepackage[english,russian]{babel}
%\end{verbatim}%
%    as well as after
%\begin{verbatim}
%\usepackage[english,russian]{babel}
%\usepackage[T1,T2A]{fontenc}
%\end{verbatim}%
%    |\latinencoding| will be set to \texttt{T1}.
%    After
%\begin{verbatim}
%\usepackage[english,russian]{babel}
%\end{verbatim}%
%    |\latinencoding| will be \texttt{OT1}.
%
%    In Unicode mode, the package \pkg{fontspec} should be loaded instead of
%    \pkg{fontenc} to make font preparation; \pkg{fontspec} sets current encoding
%    (kept in |\cf@encoding|) to \texttt{TU}, and the \pkg{babel} package sets the
%    macro |\latinencoding| to |\cf@encoding|. Since \pkg{babel} scan for value
%    |\cf@encoding| within |\AtBeginDocument|, |\latinencoding| will
%    be set to \texttt{TU} for Xe\LaTeX\ or Lua\LaTeX\ no matter which of the
%    packages, \pkg{babel} or \pkg{fontspec} is loaded first.
%
%  \end{macro}
%
%  \Describe\cyrillicencoding{}
%    There is a limited list of encodings appropriate for Cyrillic text. We
%    will look which of them is declared and keep its name in the macro
%    |\cyrillicencoding|.
%    Correct (but obsolete and now deleted) 7-bit Cyrillic encoding is
%    \texttt{LWN}.
%    Correct 8-bit Cyrillic encodings are
%    \texttt{T2A} (default for 8-bit compilers), \texttt{T2B}, \texttt{T2C},
%    \texttt{LCY} and \texttt{X2}.
%    Correct utf8 encodings are
%    \texttt{TU}  (default for Xe\LaTeX\ and Lua\LaTeX),
%    \texttt{EU1} (obsolete, formerly used for Xe\LaTeX),
%    \texttt{EU2} (obsolete, formerly used for Lua\LaTeX).
%
%    In 8-bit (\LaTeX) mode, user may choose between different non-unicode Cyrillic
%    encodings---e.g., \texttt{X2} or \texttt{LCY}.\@ If user wants
%    to use another font encoding rather than default (\texttt{T2A}),
%    he has to load the corresponding file \emph{before} \file{babel.sty}.
%
%    Remember that for the Russian language, the \texttt{T2A} encoding is
%    better than \texttt{X2}, because \texttt{X2} does not contain Latin
%    letters, and users should be very careful to switch the language
%    every time they want to typeset a Latin word inside a Russian phrase
%    or vice versa.
%
%    We parse the |\cdp@list| containing encodings known to \LaTeX\
%    in the order they have been loaded by the time \pkg{babel} is called.
%    We set the |\cyrillicencoding| to the \emph{last} loaded encoding in the
%    list of supported Cyrillic encodings: \texttt{OT2}, \texttt{LCY},
%    \texttt{X2}, \texttt{T2C}, \texttt{T2B}, \texttt{T2A}. In Unicode mode,
%    |\cyrillicencoding| is set to \texttt{TU} by \pkg{fontspec}. Nevertheless
%    here we provide similar definitions; 8-bit encodings are kept for Unicode
%    compilers (Lua\LaTeX\ and Xe\LaTeX) since they can run in compatibility
%    (8-bit) mode.
%
% \changes{1.2}{2011/10/20}{EU1 and EU2  encodings added}
% \changes{1.3j}{2017/08/07}{TU encoding added}
%    \begin{macrocode}
\def\@setcyrillicencoding{%
  \def\sce@a##1##2{%
    \edef\sce@b{##1}%
    \edef\sce@c{##2}%
    \ifx\sce@b\sce@c
      \let\cyrillicencoding\sce@c
    \fi}%
  \def\cdp@elt##1##2##3##4{%
    \sce@a{##1}{OT2}%
    \sce@a{##1}{LCY}%
    \sce@a{##1}{X2}%
    \sce@a{##1}{T2C}%
    \sce@a{##1}{T2B}%
    \sce@a{##1}{T2A}%
    \if@uni@ode
      %\sce@a{##1}{EU1}%
      %\sce@a{##1}{EU2}%
      \sce@a{##1}{TU}%
    \fi}%
  \cdp@list
}
\ifx\cyrillicencoding\undefined
  \@setcyrillicencoding
\fi
\@onlypreamble\@setcyrillicencoding
\@onlypreamble\sce@a
\@onlypreamble\sce@b
\@onlypreamble\sce@c
%    \end{macrocode}
%    The last lines are to free the memory occupied by the macros
%    |\@setcyrillicencoding| and |\sce@x| that are useless in the document.
%    The contents of |\@begindocumenthook| is cleared automatically.
%
%    If |\cyrillicencoding| is still undefined, we issue warning and provide
%    reasonable default value for |\cyrillicencoding|. We then load default
%    encoding definitions; we use the lowercase names (i.e.,
%    \texttt{lcyenc.def} instead of \texttt{LCYenc.def}) when we do that.
%
% \changes{1.2}{2011/10/20}{Removed test for present of
%    encoding files}
%    \begin{macrocode}
\ifx\cyrillicencoding\undefined
  \if@uni@ode
    %\ifdefined\XeTeXrevision
    %  \edef\cyrillicencoding{EU1}
    %\else\ifdefined\luatexversion
    %  \edef\cyrillicencoding{EU2}
    %\fi\fi
    \edef\cyrillicencoding{TU}
  \else
    \edef\cyrillicencoding{T2A}
  \fi
  \PackageWarning{babel}%
    {No Cyrillic font encoding has been loaded so far.\MessageBreak
     A font encoding should be declared before babel.\MessageBreak
     Default `\cyrillicencoding' encoding will be loaded
    }%
  \lowercase\expandafter{\expandafter\input\cyrillicencoding enc.def\relax}%
%    \end{macrocode}
%    As a final wisdom, we repeat |\@setcyrillicencoding| at |\begin{document}|
%    time. We could not avoid previous call to |\@setcyrillicencoding| since
%    compiler scan \file{.aux} file before it executes delayed code, and
%    \file{.aux} may contain |\set@langauge{russian}|; the latter rises an
%    error if |\cyrillicencoding| would not be defined by that time.
%    \begin{macrocode}
  \AtBeginDocument{\@setcyrillicencoding}
\fi
%    \end{macrocode}
%
%  \Describe\Russian{}
%    For the sake of backward compatibility we keep the macro |\Russian|
%    but redefine its meaning; now  |\Russian| is simply an alias for
%    |\selectlanguage{russian}|.
%    \begin{macrocode}
\DeclareRobustCommand{\Russian}{\selectlanguage{russian}}
%    \end{macrocode}
%
%  \Describe\cyrillictext{}
%  \DescribeOther\cyr{}
%    We define |\cyrillictext| and its alias |\cyr| but remove another alias
%    |\Rus|; these macros are intended for use within \texttt{babel} macros and
%    do not perform complete switch of the language.
%
%    In particular, they to do no switch captions and the name of current
%    language stored in the macro |\languagename|. This inconsistency might
%    break some assumptions embedded into \pkg{babel}'s.
%    For example, the |\iflanguage| macro will fail.
%
%    Second, |\cyrillictext| does
%    not activate shorthands, so that |"<|, |">|, |"`|, |"'|,
%    |"---|, e.t.c. will not work.
%
%    And third, |\cyrillictext| does not write its trace
%    to \file{.aux} file, which might result in wrong typesetting of
%    table of content, list of table and list of figures in multilingual
%    documents.
%
%    Due to any of these reasons the use of the declaration |\cyrillictext| and
%    its aliases in ordinary text is strongly discouraged. Instead of the
%    declaration |\cyrillictext| it is recommended to use |\Russian| or the
%    command |\foreignlanguage| defined in the \pkg{babel} core; their
%    functionality is similar to |\selectlanguage{russian}| but they did not
%    switch caption names, dates and shorthands.
%
%    \begin{macrocode}
\DeclareRobustCommand{\cyrillictext}{%
  \fontencoding\cyrillicencoding\selectfont
  \let\encodingdefault\cyrillicencoding
  \expandafter\set@hyphenmins\russianhyphenmins
  \language\l@russian}%
\let\cyr\cyrillictext
%    \end{macrocode}
%
%    Since version v.1.2, the |\English| macro and its alias |\Eng| were removed
%    as a reasonable place for defining these macros would be \file{englishb.ldf}.
%    Note also that these macros are absent from \file{russianb.ldf}'s counterpart
%    of the package \pkg{polyglossia}, analog of \pkg{babel} for Xe\LaTeX.
%
% \changes{1.2}{2011/10/20}{Removed \cs{English} and \cs{Eng} macros}
%    \begin{macrocode}
%%\DeclareRobustCommand{\English}{%
%%  \fontencoding\latinencoding\selectfont
%%  \let\encodingdefault\latinencoding
%%  \expandafter\set@hyphenmins\englishhyphenmins
%%  \language\l@english}%
%%\let\Eng\English
%    \end{macrocode}
%   The macro |\cyrillictext| switches current (e.g., Latin) font encoding
%   to a Cyrillic font encoding stored in |\cyrillicencoding|. The macro
%   |\latintext| switches back. This method assumes that main font
%   encoding is a Latin one. But, in fact, the latter assumption does not matter
%   if any other language is switched on using same method, i.e.
%   if corresponding \file{.ldf} file defines required macros to switch that
%   language on from same standard (Latin) state.
%   Since |\latintext| is defined by the core of babel we do not repeat its
%   definition here.
%
% \changes{1.1o}{2003/10/12}{\cs{latintext} is already
%    defined by the core of babel}
% \changes{1.2}{2011/10/20}{\cs{lat} removed}
%    \begin{macrocode}
%%\DeclareRobustCommand{\latintext}{%
%%  \fontencoding{\latinencoding}\selectfont
%%  \def\encodingdefault{\latinencoding}}
%%\let\lat\latintext
%    \end{macrocode}
%
%  \Describe\textcyrillic{\marg{text}}
%    The macro |\textcyrillic| takes an argument which is then typeset using the
%    |\cyrillictext| declaration.
% \changes{1.1o}{2003/10/12}{\cs{textlatin} already defined
%    by the core of babel}
%    \begin{macrocode}
\DeclareTextFontCommand{\textcyrillic}{\cyrillictext}
%    \end{macrocode}
%
%
%    \textsc{Next chunk of code should be moved to \texttt{X2enc.def},
%    \texttt{X2enc.dfu}, if needed.}
%
%    Since the \texttt{X2} encoding does not contain Latin letters, we
%    should make some redefinitions of \LaTeX\ macros which implicitly
%    produce Latin letters.  Unfortunately, the commands |\AA| and |\aa| are not
%    encoding dependent in \LaTeX\ (unlike e.g., |\oe| or |\DH|). They are defined
%    as |\r{A}| and |\r{a}|. This leads to unpredictable results when the font
%    encoding does not contain the Latin letters `A' and `a' (like \texttt{X2}).
%    \begin{macrocode}
%%\expandafter\ifx\csname T@X2\endcsname\relax\else
%%  \DeclareTextSymbolDefault{\AA}{OT1}
%%  \DeclareTextSymbolDefault{\aa}{OT1}
%%  \DeclareTextCommand{\aa}{OT1}{\r a}
%%  \DeclareTextCommand{\AA}{OT1}{\r A}
%%\fi
%    \end{macrocode}
%
%
%    \subsection{Input encoding}
%
%    We do not assume any default input encoding of the source file,
%    so the \pkg{inputenc} package should be explicitly loaded by
%    |\usepackage[...]{inputenc}| \emph{before} \pkg{babel}.
%    Note that default font encoding \texttt{T2A} for legacy 8-bit latex
%    engines fits well enough to Russian version of Windows ANSI encoding which
%    is almost equivalent to \texttt{cp1251} input encoding.
%
%    \textsc{Should we wrap this chunk into AtBeginDocument? Note also that
%    \pkg{inputenc} has its own check whether it is correctly called. Also,
%    it is difficult to imagine that TU encoding is not declared in case of
%    unicode engines. Hence, we remove this check in babel starting since
%    version 1.3j.}
%
% \changes{1.1l}{1999/08/27}{Made not using inputenc a
%    warning instead of an error}
% \changes{1.2}{2011/10/11}{Added EU1 and EU2 encodings}
% \changes{1.2}{2011/10/11}{Removed LWN encoding}
% \changes{1.3j}{2017/08/08}{Removed check if inputenc is loaded}
%    \begin{macrocode}
%%\@ifpackageloaded{inputenc}{%
%%% \if@uni@ode
%%%   \PackageWarning{babel}{inputenc should not be used with LuaTeX or XeTeX}
%%% \fi
%% \ifdefined\luatexversion
%%   \PackageWarning{babel}{inputenc should not be used with LuaTeX}
%% \fi}{%
%%  %\def\reserved@a{LWN}%
%%  %\ifx\reserved@a\cyrillicencoding\else
%%    \def\reserved@a{OT2}%
%%    \ifx\reserved@a\cyrillicencoding\else
%%       \def\reserved@a{TU}%
%%       \ifx\reserved@a\cyrillicencoding\else
%%         \PackageWarning{babel}%
%%           {No input encoding specified for Russian language}
%%    \fi\fi
%%  %\fi
%%}
%    \end{macrocode}
%
%
%    \subsection{Shorthands}
%
%    The double quote  character \texttt{"} is declared to be active in
%    Russian language.
%
% \changes{1.1a}{1995/03/07}{Use the new mechanism for dealing
%    with active characters}
%    \begin{macrocode}
\initiate@active@char{"}
%    \end{macrocode}
%
% \changes{1.1f}{1998/06/26}{Added switch for
%    doublequote shorthands}
% \changes{1.3}{2013/01/10}{Removed switch for
%    doublequote shorthands}
%
%  \begin{macro}{\mdqon}
%  \begin{macro}{\mdqoff}
%    Obsolete: Active double quote can be both activated and deactivated at any time
%    using the macros |\mdqon| and  |\mdqoff|.
%    \begin{macrocode}
%%\def\mdqon{\bbl@activate{"}}
%%\def\mdqoff{\bbl@deactivate{"}}
%    \end{macrocode}
%    Initial activation state is set in section \ref{sss:extra}.
%  \end{macro}
%  \end{macro}
%
%  \Describe\dq{}
%    The active character |"| is used as indicated in
%    table~\ref{tab:russian-quote}. We save the original double quote
%    character in the |\dq| macro to keep it available.
%    The math accent |\"| can now be typed as `|"|'.
%
%    \begin{macrocode}
\begingroup \catcode`\"12
\def\reserved@a{\endgroup
  \def\@SS{\mathchar"7019 }
  \def\dq{"}}
\reserved@a
%    \end{macrocode}
%
%    \subsubsection{Quotes}
%
%    We set |"`| and |"'| as shorthands for |\quotedblbase| and
%    |\textquotedblleft|, respectively. Prior to ver.1.2, these shorthands
%    were defined through German quotes |\glqq| and |\grqq|, which in their turn
%    are defined in \pkg{babel.def} via |\quotedblbase| and |\textquotedblleft|,
%    respectively. It occurred, that old definition caused errors in Unicode
%    mode if \pkg{fontspec} is loaded.
%
%    Prior to version 1.2, the shorthands |"<| and |">| had been
%    declared to be equivalents for the French quotes |\flqq| and |\frqq|,
%    respectively. They are defined in \pkg{babel.def} via |\guillemotleft| and
%    |\guillemotright|. However, |\flqq| and |\guillemotleft| (and their right
%    counterparts) are typeset differently if current encoding is not
%    \texttt{T1}. Therefore, since v.1.2, we define |"<| and |">|  directly
%    through |\guillemotleft| and |\guillemotright|.
%
%    \begin{macrocode}
\declare@shorthand{russian}{"`}{\quotedblbase}
\declare@shorthand{russian}{"'}{\textquotedblleft}
\declare@shorthand{russian}{"<}{\guillemotleft}
\declare@shorthand{russian}{">}{\guillemotright}
%    \end{macrocode}
%
%    Next set of shorthands is intended for variations of standard macro |\-|
%    which indicates explicitly breakpoint for hyphenation in a word. Meaning
%    of these shorthands is explained in table~\ref{tab:russian-quote}.
%
%    Some of this definitions need a alternative definitions for the booksmarks.
% \changes{1.3l}{2020/10/16}{Modified shorthands}
%    \begin{macrocode}
\providecommand\texorpdfstring[2]{#1}
\declare@shorthand{russian}{""}{\hskip\z@skip}
\declare@shorthand{russian}{"~}{\texorpdfstring{\textormath{\leavevmode\hbox{-}}{-}}{-}}
\declare@shorthand{russian}{"=}{\nobreak-\hskip\z@skip}
\declare@shorthand{russian}{"|}{%
  \texorpdfstring{%
   \textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}{}}
%    \end{macrocode}
%
%    \subsubsection{Emdash, endash and hyphenation sign}
%
%    To distinguish between |"-| and |"---| we must check whether the next token
%    after |-| is a hyphen character.
%    If it is, we output an emdash, otherwise a hyphen sign. Therefor
%    \TeX\ looks for the next token after the first `|-|', writes
%    its meaning to |\russian@sh@next| and finally call for |\russian@sh@tmp|.
% \changes{1.3l}{2020/10/16}{Modified shorthands}
%    \begin{macrocode}
\declare@shorthand{russian}{"-}{%
  \texorpdfstring{\def\russian@sh@tmp{%
    \if\russian@sh@next-\expandafter\russian@sh@emdash
    \else\expandafter\russian@sh@hyphen\fi}%
  \futurelet\russian@sh@next\russian@sh@tmp}{-}}
%    \end{macrocode}
%    Two macros |\russian@sh@hyphen| and |\russian@sh@emdash| called by
%    |\russian@sh@tmp|  are defined below. The second of
%    them has two parameters since it must gobble next two hyphen signs.
%    \begin{macrocode}
\def\russian@sh@hyphen{\nobreak\-\bbl@allowhyphens}
\def\russian@sh@emdash#1#2{\cdash-#1#2}
%    \end{macrocode}
%
%  \Describe\cdash{}
%    In its turn, |\russian@sh@emdash| simply calls for |\cdash| which has
%    rich use. It analyses 3rd of 3 characters and calls for one of few
%    predefined macros |\@Acdash|, |\@Bcdash|, |\@Ccdash|.
%    \begin{macrocode}
\def\cdash#1#2#3{\def\tempx@{#3}%
\def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
 \ifx\tempx@\tempa@\@Acdash\else
  \ifx\tempx@\tempb@\@Bcdash\else
   \ifx\tempx@\tempc@\@Ccdash\else
    \errmessage{Wrong usage of cdash}\fi\fi\fi}
%    \end{macrocode}
%
%   All these 3 internal macros call for |\cyrdash|, which types Cyrillic
%   emdash, but put different spaces around the dash.
%
%   |\@Acdash| is invoked by |"---|. It types Cyrillic emdash to be used
%   inside a text and puts an unbreakable thin space before the dash if a
%   \textit{space} is placed before |"---| in the source file;
%   can be used after display maths formulae, formatted lists, enumerations, etc.
%    \begin{macrocode}
\def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
  \cyrdash\hskip.2em\ignorespaces}%
%    \end{macrocode}
%
%   |\@Bcdash| is invoked by |"--~|. It types Cyrillic emdash in compound
%   terms (like law of Mendeleev---Klapeiron). Compound names composed
%   of names of two or more people should be distinguished from double names of
%   single person (Jean-Jacques Rousseau, Nemirovich-Danchenko), in which
%   words are separated by a hyphen. There is no consensus on how the dashes
%   should be used in compound names. Some editors advise that no spaces should
%   be inserted around the dash. However, most editors require you to insert
%   |2pt|-spaces on both sides of the dash. The first option is implemented in
%   this package since the very old versions. The second option can be
%   implemented as described in the Customisation section.
%    \begin{macrocode}
\def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
 \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
%\def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
% \nobreak\kern2\p@\cyrdash\penalty\exhyphenpenalty\hskip2\p@\ignorespaces}%
%    \end{macrocode}
%
%   |\@Ccdash| is invoked by |"--*|. It denotes direct speech and adds small
%   space after the dash.
% \changes{1.3m}{2021/01/10}{\cs{@Bcdash} redefined to add 1pt space on both sides}
%    \begin{macrocode}
\def\@Ccdash{\leavevmode
 \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
%    \end{macrocode}
%
% \changes{1.1f}{1998/06/26}{%
%    Add macro for thin space between initials}
%
%    Finally, we define a shorthand thin space to be placed between initials
%    as in |D.",Mendeleev|. When used instead of |\,| as in |D.\,Mendeleev|
%    it allows hyphenation in the next word.
%
%    \begin{macrocode}
\declare@shorthand{russian}{",}{\nobreak\hskip.2em\ignorespaces}
%    \end{macrocode}
%
%
%  \Describe\cyrdash{}
%    The |\cyrdash| macro is defined in Cyrillic font encodings (LCY, T2*, OT2,
%    and |X2|) by means of |\DeclareTextSymbol|. In T2* encodings |\cyrdash|
%    refers to same code point 22 as |\textemdash| does so that these two macros
%    are equivalent. However the dash at the code point 22 have different length
%    in different fonts. The dash in Cyrillic fonts LH is 20\% shorter as
%    compared to Latin fonts such as CM (Computer Modern).  As a result, the dash
%    typed by the ligature |---| or its variations mentioned in Table
%    \ref{tab:russian-quote} might change its length after |\selectlanguage|.
%
%    The |\cyrdash| macro is not available in Latin encodings, such as |T1|, or
%    in the Unicode |TU| encoding intended for the |xelatex| and |lualatex|
%    engines. Therefore, an explicit or implicit call to the command |\cyrdash|
%    in a situation when the current language differs from Russian, causes an
%    error. For such cases, we provide a fake default using the
%    |\ProvideTextCommandDefault| method.
%
%    Prior to version 1.3l inclusive, the fake for |\cyrdash| was defined as
%    a compound character |{\hbox to.8em {--\hss--}}| in the case when the
%    current language is Russian; in other cases, |\cyrdash| is equated to
%    |\textemdash|. Thus, for the Russian language, the command |\cyrdash|
%    prints a dash |0.8em| wide. With the variety of fonts that the |xelatex|
%    and |lualatex| compilers allow, the usual dash that the |\textemdash| command
%    prints can have a width of either more than |1em| or less than |1em|.
%    Consequently, the statement that the Cyrillic dash is 20 percent shorter
%    than the Latin one loses its meaning. In addition, this statement does not
%    find convincing confirmation in the specialized literature for editors
%    of publishing houses. In this regard, it was decided to equate |\cyrdash|
%    with |\textemdash|.
% \changes{1.3j}{2017/08/08}{Default for \cs{cyrdash} is provided}
% \changes{1.3m}{2021/01/10}{\cs{cyrdash} defaults to \cs{textemdash}}
%    \begin{macrocode}
\PackageInfo{babel}{Default for \string\cyrdash\space is provided}
%%\ProvideTextCommandDefault{\cyrdash}{\iflanguage{russian}%
%%  {\hbox to.8em{--\hss--}}{\textemdash}}
\ProvideTextCommandDefault{\cyrdash}{\textemdash}
%    \end{macrocode}%
%    With this definition of |\cyrdash|, the dash width is entirely determined
%    by the selected font. However, it is believed that the dash length in many
%    fonts is too large. Those who adhere to such a bud of vision can change
%    the definition of the |\cyrdash| command by placing the declaration
%    |\renewcommand{\cyrdash}| |{\scalebox{0.75}[1]{\textemdash}}|
%    somewhere after the call to the |babel| package. Unfortunately, such a
%    definition of the |\cyirdash| command cannot be used inside current
%    package, since the command |\scalebox| is defined in the |graphicx| package.
%
%   \subsection{Switching to/from Russian}
%
%   Now we define additional macros used to reset current language to
%   Russian and back
%   to some original state. The package \pkg{babel} based on the assumption
%   that original state is characterized by a Latin encoding. Previously,
%   for back reset the macro |\OriginalTeX| was used, but now use |\latintext|
%   for the same purpose.
%
%
%    \subsubsection{Caption names}
%
%    First, we define Russian equivalents for Russian caption names.
%
% \Describe\captionsrussian{}
%    The macro |\captionsrussian| defines caption names used in the
%    four standard document classes provided with \LaTeX. The macro |\cyr|
%    activates Cyrillic encoding. It could be dropped if we would be sure
%    that Russian captions are called only if current language is Russian.
%    However, the macros such as |\Russian| do not conform to strict rules
%    of the package \pkg{babel} as explained in the above.
%
%    As of version v.1.2 we eliminate |\cyr...| macros from caption names
%    if Unicode engine is running. In the latter case, Cyrillic letters are typed
%    in by their Unicode code-points, the |^^^^abcd| notation is not used
%    since it causes error at compilation time in case if \LaTeX\ is running
%    and \texttt{utf8} input encoding is not declared.
%
% \changes{1.2}{2011/10/20}{Unicode code-points added for LuaLaTeX}
%    \begin{macrocode}
\if@uni@ode
  %\captionsrussian@modern
  \addto\captionsrussian{%
    \def\prefacename{Предисловие}%   [babel]
    \def\refname{Список литературы}% [only article]
    \def\abstractname{Аннотация}%    [only article, report]
    \def\bibname{Литература}%        [only book, report]
    \def\chaptername{Глава}%         [only book, report]
    \def\appendixname{Приложение}%
%    \end{macrocode}
%    Note that two names for the Table of Contents can be used in Russian
%    publications. For books (and reports) the second variant is
%    appropriate, but for proceedings the first variant is preferred:
%    \begin{macrocode}
    \@ifundefined{thechapter}
      {\def\contentsname{Содержание}}%
      {\def\contentsname{Оглавление}}%
    \let\tocname=\contentsname
    \def\listfigurename{Список иллюстраций}%
    \def\listtablename{Список таблиц}%
    \def\indexname{Предметный указатель}%
    \def\authorname{Именной указатель}%
    \def\figurename{Рис.}%
    \def\tablename{Таблица}%
    \def\partname{Часть}%
    \def\enclname{вкл.}%
    \def\ccname{исх.}%
    \def\headtoname{вх.}%
    \def\pagename{с.}%               [letter]
    \def\seename{см.}%
    \def\alsoname{см.\ также}%
    \def\proofname{Доказательство}%  [amsthm]
    \def\glossaryname{Словарь терминов}%
    \def\acronymname{Аббревиатуры}%  [glossaries] {Acronyms}
    \def\lstlistingname{Листинг}%    [listings]  (the environment) {Listing}
    \def\lstlistlistingname{Листинги}% [listings]  (the "List of") {Listings}
    \def\notesname{Заметки}%         [endnotes] {Notes}
  }%
%    \end{macrocode}
%    Additional definitions for the package \pkg{nomencl}:
%    \begin{macrocode}
  %% =========================================
  %% nomencl
  \ifdefined\nomname
    \addto\captionsrussian{%
        \def\nomname{Обозначения}%
        \def\eqdeclaration#1{, см.\nobreakspace(#1)}%
        \def\pagedeclaration#1{, стр.\nobreakspace#1}%
    }%
  \fi
%    \end{macrocode}
%    Additional captions for the \cls{revtex} class.
%    \begin{macrocode}
  %% =========================================
  %% RevTeX4 & RevTeX4-1
  %%\@ifclassloaded{revtex4-1}
  %%{<true code>}
  %%{<false coode>}%
  %\@ifclassloaded{revtex4-1}
  %{%
  \ifnum\@ifclassloaded{revtex4}{1}{\@ifclassloaded{revtex4-1}{1}{0}}>0
    \addto\captionsrussian{%
    \def\lofname{\listfigurename}
    \def\lotname{\listtablename}
    \def\figuresname{Рисунки}%{Figures}%
    \def\tablesname{Таблицы}%{Tables}%
    \def\appendixesname{Приложения}%{Appendixes}%
    \def\acknowledgmentsname{Благодарности}%{Acknowledgments}
    \def\andname{и}%{and}
    \def\@pacs@name{PACS коды: }%{PACS numbers: }%
    \def\@keys@name{Ключевые слова: }%{Keywords: }%
    \def\Dated@name{Дата: }%{Dated: }%
    \def\Received@name{Получено }%{Received }%
    \def\Revised@name{Исправленная версия }%{Revised }%
    \def\Accepted@name{Принято }%{Accepted }%
    \def\Published@name{Опубликовано }%{Published }%
    }%
  %}{}%
  \fi
%    \end{macrocode}
%
% \changes{1.3h}{2016/02/18}{Revtex captions fixed}
%    Now we proceed to the ancient version in Unicode encoding.
%    \begin{macrocode}
  \addto\captionsrussian@ancient{%
    \def\prefacename{Предисловіе}%
    \def\refname{Примѣчанія}%
    \def\abstractname{Аннотація}%
    \def\bibname{Библіографія}%
    \def\chaptername{Глава}%
    \def\appendixname{Приложеніе}%
    \@ifundefined{thechapter}
      {\def\contentsname{Содержаніе}}%
      {\def\contentsname{Оглавленіе}}%
    \let\tocname=\contentsname
    \def\listfigurename{Списокъ иллюстрацій}%
    \def\listtablename{Списокъ таблицъ}%
    \def\indexname{Предмѣтный указатель}%
    \def\authorname{Именной указатель}%
    \def\figurename{Рис.}%
    \def\tablename{Таблица}%
    \def\partname{Часть}%
    \def\enclname{вкл.}%
    \def\ccname{исх.}%
    \def\headtoname{вх.}%
    \def\pagename{с.}%
    \def\seename{см.}%
    \def\alsoname{см.~также}%
    \def\proofname{Доказательство}%
    \def\glossaryname{Словарь терминов}%
    \def\acronymname{Аббревиатуры}%
    \def\lstlistingname{Листинг}%
    \def\lstlistlistingname{Листинги}%
    %\ifdefined\nomname
    % see http://old_russian.academic.ru/8433/%D0%BE%D0%B1%D1%8A%CB%AB%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D1%A5
      \def\nomname{Обозначенія}%{Объавлениѥ}% <-- #0465
    %\fi
    \def\notesname{Заметки}%
  }
  %% =========================================
  %% RevTeX4 & RevTeX4-1
  %\@ifclassloaded{revtex4-1}
  %{%
  \ifnum\@ifclassloaded{revtex4}{1}{\@ifclassloaded{revtex4-1}{1}{0}}>0
    \addto\captionsrussian@ancient{%
    \def\lofname{\listfigurename}
    \def\lotname{\listtablename}
    \def\figuresname{Рисунки}%{Figures}%
    \def\tablesname{Таблицы}%{Tables}%
    \def\appendixesname{Приложения}%{Appendixes}%
    \def\acknowledgmentsname{Благодарности}%{Acknowledgments}
    \def\andname{и}%{and}
    \def\@pacs@name{PACS коды: }%{PACS numbers: }%
    \def\@keys@name{Ключевые слова: }%{Keywords: }%
    \def\Dated@name{Дата: }%{Dated: }%
    \def\Received@name{Получено }%{Received }%
    \def\Revised@name{Исправленная версия }%{Revised }%
    \def\Accepted@name{Принято }%{Accepted }%
    \def\Published@name{Опубликовано }%{Published }%
    }%
  %}{}%
  \fi
  %% =========================================
\else
  %\def\captionsrussian@modern{%
  \addto\captionsrussian{%
    \def\prefacename{%
      {\cyr\CYRP\cyrr\cyre\cyrd\cyri\cyrs\cyrl\cyro\cyrv\cyri\cyre}}%
    \def\refname{%
      {\cyr\CYRS\cyrp\cyri\cyrs\cyro\cyrk\
      \cyrl\cyri\cyrt\cyre\cyrr\cyra\cyrt\cyru\cyrr\cyrery}}%
    \def\abstractname{%
      {\cyr\CYRA\cyrn\cyrn\cyro\cyrt\cyra\cyrc\cyri\cyrya}}%
      \def\bibname{%
        {\cyr\CYRL\cyri\cyrt\cyre\cyrr\cyra\cyrt\cyru\cyrr\cyra}}%
    \def\chaptername{{\cyr\CYRG\cyrl\cyra\cyrv\cyra}}%
    \def\appendixname{%
      {\cyr\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}}%
    \@ifundefined{thechapter}%
      {\def\contentsname{%
        {\cyr\CYRS\cyro\cyrd\cyre\cyrr\cyrzh\cyra\cyrn\cyri\cyre}}}%
      {\def\contentsname{%
        {\cyr\CYRO\cyrg\cyrl\cyra\cyrv\cyrl\cyre\cyrn\cyri\cyre}}}%
    \let\tocname=\contentsname
    \def\listfigurename{%
      {\cyr\CYRS\cyrp\cyri\cyrs\cyro\cyrk
        \ \cyri\cyrl\cyrl\cyryu\cyrs\cyrt\cyrr\cyra\cyrc\cyri\cyrishrt}}%
    \def\listtablename{%
      {\cyr\CYRS\cyrp\cyri\cyrs\cyro\cyrk
        \ \cyrt\cyra\cyrb\cyrl\cyri\cyrc}}%
    \def\indexname{%
      {\cyr\CYRP\cyrr\cyre\cyrd\cyrm\cyre\cyrt\cyrn\cyrery\cyrishrt
        \ \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl\cyrsftsn}}%
    \def\authorname{%
      {\cyr\CYRI\cyrm\cyre\cyrn\cyrn\cyro\cyrishrt
        \ \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl\cyrsftsn}}%
    \def\figurename{{\cyr\CYRR\cyri\cyrs.}}%
    \def\tablename{{\cyr\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}}%
    \def\partname{{\cyr\CYRCH\cyra\cyrs\cyrt\cyrsftsn}}%
    \def\enclname{{\cyr\cyrv\cyrk\cyrl.}}%
    \def\ccname{{\cyr\cyri\cyrs\cyrh.}}%
    \def\headtoname{{\cyr\cyrv\cyrh.}}%
    \def\pagename{{\cyr\cyrs.}}%
    \def\seename{{\cyr\cyrs\cyrm.}}%
    \def\alsoname{{\cyr\cyrs\cyrm.\ \cyrt\cyra\cyrk\cyrzh\cyre}}%
    \def\proofname{{\cyr\CYRD\cyro\cyrk\cyra\cyrz\cyra\cyrt
       \cyre\cyrl\cyrsftsn\cyrs\cyrt\cyrv\cyro}}%
    \def\glossaryname{{\cyr\CYRS\cyrl\cyro\cyrv\cyra\cyrr\cyrsftsn\
       \cyrt\cyre\cyrr\cyrm\cyri\cyrn\cyro\cyrv}}%
    \def\acronymname{\CYRA\cyrb\cyrb\cyrr\cyre\cyrv\cyri\cyra\cyrt\cyru\cyrr\cyrery}%
    \def\lstlistingname{\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}%
    \def\lstlistlistingname{\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
    \def\nomname{\CYRO\cyrb\cyro\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyri\cyrya}%
    \def\notesname{\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}%
  }%
  %% =========================================
  %% RevTeX4 & RevTeX4-1
  \ifnum \@ifclassloaded{revtex4}{1}{\@ifclassloaded{revtex4-1}{1}{0}}>0
    \addto\captionsrussian{%
    \def\lofname{\listfigurename}
    \def\lotname{\listtablename}
    \def\figuresname{\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}%{Figures}%
    \def\tablesname{\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}%{Tables}%
    \def\appendixesname{\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}%{Appendixes}%
    \def\acknowledgmentsname{\CYRB\cyrl\cyra\cyrg\cyro\cyrd\cyra\cyrr\cyrn\cyro\cyrs\cyrt\cyri}%{Acknowledgments}
    \def\andname{\cyri}%{and}
    \def\@pacs@name{PACS \cyrk\cyro\cyrd\cyrery: }%{PACS numbers: }%
    \def\@keys@name{\CYRK\cyrl\cyryu\cyrch\cyre\cyrv\cyrery\cyre \cyrs\cyrl\cyro\cyrv\cyra: }%{Keywords: }%
    \def\Dated@name{\CYRD\cyra\cyrt\cyra: }%{Dated: }%
    \def\Received@name{\CYRP\cyro\cyrl\cyru\cyrch\cyre\cyrn\cyro }%{Received }%
    \def\Revised@name{\CYRI\cyrs\cyrp\cyrr\cyra\cyrv\cyrl\cyre\cyrn\cyrn\cyra\cyrya \cyrv\cyre\cyrr\cyrs\cyri\cyrya }%{Revised }%
    \def\Accepted@name{\CYRP\cyrr\cyri\cyrn\cyrya\cyrt\cyro }%{Accepted }%
    \def\Published@name{\CYRO\cyrp\cyru\cyrb\cyrl\cyri\cyrk\cyro\cyrv\cyra\cyrn\cyro }%{Published }%
    }%
  \fi
  %% =========================================
  \addto\captionsrussian@ancient{%
    \def\prefacename{%
      {\cyr\CYRP\cyrr\cyre\cyrd\cyri\cyrs\cyrl\cyro\cyrv\cyrii\cyre}}%
    \def\refname{%
      {\cyr\CYRP\cyrr\cyri\cyrm\cyryat\cyrch\cyra\cyrn\cyrii\cyrya}}%          <-- Примѣчанія, нет \cyryat в кодировке T2*
    \def\abstractname{%
      {\cyr\CYRA\cyrn\cyrn\cyro\cyrt\cyra\cyrc\cyrii\cyrya}}%
    \def\bibname{%
      {\cyr\CYRB\cyri\cyrb\cyrl\cyrii\cyro\cyrg\cyrr\cyra\cyrf\cyrii\cyrya}}%  <-- Библіографія
    \def\chaptername{{\cyr\CYRG\cyrl\cyra\cyrv\cyra}}%
    \def\appendixname{%
      {\cyr\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyrii\cyre}}%
    \@ifundefined{thechapter}%
      {\def\contentsname{%
        {\cyr\CYRS\cyro\cyrd\cyre\cyrr\cyrzh\cyra\cyrn\cyrii\cyre}}}%
      {\def\contentsname{%
        {\cyr\CYRO\cyrg\cyrl\cyra\cyrv\cyrl\cyre\cyrn\cyrii\cyre}}}%
    \let\tocname=\contentsname
    % Списокъ иллюстрацій
    \def\listfigurename{%
      {\cyr\CYRS\cyrp\cyri\cyrs\cyro\cyrk\cyrhrdsn\
       \cyri\cyrl\cyrl\cyryu\cyrs\cyrt\cyrr\cyra\cyrc\cyrii\cyrishrt}}
    % Списокъ таблицъ
    \def\listtablename{%
      {\cyr\CYRS\cyrp\cyri\cyrs\cyro\cyrk\cyrhrdsn\
       \cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrhrdsn}}%
    % Предмѣтный указатель, ѣ (\cyryat) in X2 encoding only
    \def\indexname{%
      {\cyr\CYRP\cyrr\cyre\cyrd\cyrm\cyryat\cyrt\cyrn\cyrery\cyrishrt\space
       \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl\cyrsftsn}}%
    \def\authorname{%
      {\cyr\CYRI\cyrm\cyre\cyrn\cyrn\cyro\cyrishrt\
       \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl\cyrsftsn}}%
    \def\figurename{{\cyr\CYRR\cyri\cyrs.}}%
    \def\tablename{{\cyr\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}}%
    \def\partname{{\cyr\CYRCH\cyra\cyrs\cyrt\cyrsftsn}}%
    \def\enclname{{\cyr\cyrv\cyrk\cyrl.}}%
    \def\ccname{{\cyr\cyri\cyrs\cyrh.}}%
    \def\headtoname{{\cyr\cyrv\cyrh.}}%
    \def\pagename{{\cyr\cyrs.}}%
    \def\seename{{\cyr\cyrs\cyrm.}}%
    \def\alsoname{{\cyr\cyrs\cyrm.\ \cyrt\cyra\cyrk\cyrzh\cyre}}%
    \def\proofname{{\cyr\CYRD\cyro\cyrk\cyra\cyrz\cyra\cyrt
      \cyre\cyrl\cyrsftsn\cyrs\cyrt\cyrv\cyro}}%
    \def\glossaryname{{\cyr\CYRS\cyrl\cyro\cyrv\cyra\cyrr\cyrsftsn\
      \cyrt\cyre\cyrr\cyrm\cyri\cyrn\cyro\cyrv}}% <-- Needs translation
    \def\acronymname{\CYRA\cyrb\cyrb\cyrr\cyre\cyrv\cyri\cyra\cyrt\cyru\cyrr\cyrery}%
    \def\lstlistingname{\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}%
    \def\lstlistlistingname{\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
    \def\nomname{\CYRO\cyrb\cyro\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrii\cyrya}%
    \def\notesname{\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}%
  }%
  %% =========================================
  %% RevTeX4 & RevTeX4-1
  \ifnum \@ifclassloaded{revtex4}{1}{\@ifclassloaded{revtex4-1}{1}{0}}>0
    \addto\captionsrussian@ancient{%
    \def\lofname{\listfigurename}
    \def\lotname{\listtablename}
    \def\figuresname{\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}%{Figures}%
    \def\tablesname{\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}%{Tables}%
    \def\appendixesname{\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}%{Appendixes}%
    \def\acknowledgmentsname{\CYRB\cyrl\cyra\cyrg\cyro\cyrd\cyra\cyrr\cyrn\cyro\cyrs\cyrt\cyri}%{Acknowledgments}
    \def\andname{\cyri}%{and}
    \def\@pacs@name{PACS \cyrk\cyro\cyrd\cyrery: }%{PACS numbers: }%
    \def\@keys@name{\CYRK\cyrl\cyryu\cyrch\cyre\cyrv\cyrery\cyre \cyrs\cyrl\cyro\cyrv\cyra: }%{Keywords: }%
    \def\Dated@name{\CYRD\cyra\cyrt\cyra: }%{Dated: }%
    \def\Received@name{\CYRP\cyro\cyrl\cyru\cyrch\cyre\cyrn\cyro }%{Received }%
    \def\Revised@name{\CYRI\cyrs\cyrp\cyrr\cyra\cyrv\cyrl\cyre\cyrn\cyrn\cyra\cyrya \cyrv\cyre\cyrr\cyrs\cyri\cyrya }%{Revised }%
    \def\Accepted@name{\CYRP\cyrr\cyri\cyrn\cyrya\cyrt\cyro }%{Accepted }%
    \def\Published@name{\CYRO\cyrp\cyru\cyrb\cyrl\cyri\cyrk\cyro\cyrv\cyra\cyrn\cyro }%{Published }%
    }%
  \fi
  %% =========================================
\fi
%    \end{macrocode}
%
%    \subsubsection{Date in Russian}
%
% \Describe\daterussian{}
%    The macro |\daterussian| is used to reset the macro |\today| in Russian.
%
% \changes{1.2}{2011/10/20}{Unicode code-points added for LuaLaTeX}
%    \begin{macrocode}
\if@uni@ode
  \addto\daterussian{%
   \def\today{\number\day~\ifcase\month\or
    января\or
    февраля\or
    марта\or
    апреля\or
    мая\or
    июня\or
    июля\or
    августа\or
    сентября\or
    октября\or
    ноября\or
    декабря\fi
    \space \number\year~г.}}
  \def\daterussian@ancient{%
   \def\today{\number\day~\ifcase\month\or%
    января\or
    февраля\or
    марта\or
    апреля\or
    мая\or
    іюня\or
    іюля\or
    августа\or
    сентября\or
    октября\or
    ноября\or
    декабря\fi%
    \space \number\year~г.}}
\else
  \def\daterussian{%
   \def\today{\number\day~\ifcase\month\or
    \cyrya\cyrn\cyrv\cyra\cyrr\cyrya\or
    \cyrf\cyre\cyrv\cyrr\cyra\cyrl\cyrya\or
    \cyrm\cyra\cyrr\cyrt\cyra\or
    \cyra\cyrp\cyrr\cyre\cyrl\cyrya\or
    \cyrm\cyra\cyrya\or
    \cyri\cyryu\cyrn\cyrya\or
    \cyri\cyryu\cyrl\cyrya\or
    \cyra\cyrv\cyrg\cyru\cyrs\cyrt\cyra\or
    \cyrs\cyre\cyrn\cyrt\cyrya\cyrb\cyrr\cyrya\or
    \cyro\cyrk\cyrt\cyrya\cyrb\cyrr\cyrya\or
    \cyrn\cyro\cyrya\cyrb\cyrr\cyrya\or
    \cyrd\cyre\cyrk\cyra\cyrb\cyrr\cyrya\fi
    \space \number\year~\cyrg.}}
  \def\daterussian@ancient{%
   \def\today{\number\day~\ifcase\month\or
    \cyrya\cyrn\cyrv\cyra\cyrr\cyrya\or
    \cyrf\cyre\cyrv\cyrr\cyra\cyrl\cyrya\or
    \cyrm\cyra\cyrr\cyrt\cyra\or
    \cyra\cyrp\cyrr\cyre\cyrl\cyrya\or
    \cyrm\cyra\cyrya\or
    \cyrii\cyryu\cyrn\cyrya\or
    \cyrii\cyryu\cyrl\cyrya\or
    \cyra\cyrv\cyrg\cyru\cyrs\cyrt\cyra\or
    \cyrs\cyre\cyrn\cyrt\cyrya\cyrb\cyrr\cyrya\or
    \cyro\cyrk\cyrt\cyrya\cyrb\cyrr\cyrya\or
    \cyrn\cyro\cyrya\cyrb\cyrr\cyrya\or
    \cyrd\cyre\cyrk\cyra\cyrb\cyrr\cyrya\fi
    \space \number\year~\cyrg.}}
\fi
%    \end{macrocode}
%
%    \subsubsection{Hyphenation patterns}
%
%    Russian hyphenation patterns are automatically activated every time
%    Russian language is selected via |\selectlanguage|, |\foreignlanguage|
%    or equivalent command. But we need to declare values of
%    |\lefthyphenmin| and |\righthyphenmin|; both are set to~2.
%
%    As of v.1.2 we removed a definition for |\englishhyphenmins|. It is
%    not deal of \file{russianb.ldf}.
%
% \changes{1.1a}{1995/07/04}{use \cs{russianhyphenmins} to
%    store the correct values}
% \changes{1.1m}{2000/09/22}{Now use \cs{providehyphenmins} to
%    provide a default value}
% \changes{1.2}{2011/10/20}{\cs{englishhyphenmins} is removed}
%    \begin{macrocode}
\providehyphenmins{\CurrentOption}{\tw@\tw@}
\providehyphenmins{russian}{\tw@\tw@}
%    \end{macrocode}
%
%    \subsubsection{Extra definitions}
%    \label{sss:extra}
%
% \Describe\extrasrussian{}
% \DescribeOther\noextrasrussian{}
%    The macro |\extrasrussian| performs extra definitions in addition to
%    resetting the caption names and date.
%    The macro |\noextrasrussian| is used to cancel the actions of
%    |\extrasrussian|.
%
% \changes{1.1b}{1996/02/20}{Added switch to \texttt{LWN}
%    encoding}
%
%    First, we instruct \pkg{babel} to switch font encoding using earlier
%    defined macros |\cyrillictext| and |\latintext|.
%
%    \begin{macrocode}
\addto\extrasrussian{\cyrillictext}
\addto\noextrasrussian{\latintext}
%    \end{macrocode}
%
%    Second, we specify that the Russian group of shorthands should be used.
%
%    \begin{macrocode}
\addto\extrasrussian{\languageshorthands{russian}}
\addto\extrasrussian{\bbl@activate{"}}
\addto\noextrasrussian{\bbl@deactivate{"}}
%    \end{macrocode}
%
%    Now the action |\extrasrussian| has to execute is to make sure that the
%    command |\frenchspacing| is in effect. If this is not the case the
%    execution of |\noextrasrussian| will switch it off again.
%
%    \begin{macrocode}
\addto\extrasrussian{\bbl@frenchspacing}
\addto\noextrasrussian{\bbl@nonfrenchspacing}
%    \end{macrocode}
%
%
%    \subsection{Alphabetic counters}
%
%    Do we need to reset |\@alph| and |\@Alph|? They are used in the
%    \LaTeX\ core to define the macros |\alph| and |\Alph|, respectively, which
%    type a counter with a corresponding letter of Latin alphabet.
%    We just want to make sure that correct |\latinencoding| is used instead of
%    |\latinencoding| to typeset the counter. Starting from v.1.2 we do not
%    reset these macros since all Cyrillic encoding but \texttt{X2} do have
%    Latin letters. When using the \texttt{X2} encoding user must himself
%    take care about selecting correct encoding when he switches his keyboard.
%    Our decision is motivated as follows. If selected Cyrillic font is visually
%    different from Latin font, the macro |\@alph| and |\@Alph| will produce
%    visually different output from surrounding text if they are used with
%    Russian text, which is completely legitimate.
%
%    Notice for commented code:\\
%    We put |\latinencoding| in braces to avoid problems with
%    |\@alph| inside minipages (e.g., footnotes inside minipages) where
%    |\@alph| is expanded and we get for example `|\fontencoding OT1|'
%    (|\fontencoding| is robust).
%
%    Note added on 2013/03/22: |{\fontencoding{\latinencoding}\selectfont|
%    rises an error with recent version of \pkg{microtype} package after the
%    |\appendix| declaration (which resets |\thechapter| to |\@Alph\c@chapter}|).
%    Most languages do not reset |\@alph| and |\@Alph| macros and only
%    \pkg{ukrainian} and \pkg{bulgarian} add |\fontencoding| to |\@alph| and
%    |\@Alph|.
%
%    Since v.1.3 we do not reset |\@alph| and |\@Alph| here.
%    Resetting |\fontencoding| in |\@alph| and |\@Alph| causes an error
%    if the package |smartref| is loaded and a |\sref| occurs after the
%    |\appendix| declaration which resets |\thechapter| to |\@Alph\c@chapter|.
% \changes{1.3}{2013/03/22}{Removed \cs{@alph} and \cs{@Alph}}
%
%    \begin{macrocode}
%\def\@alph#1{{\fontencoding{\latinencoding}\selectfont
%  \ifcase#1\or
%    a\or b\or c\or d\or e\or f\or g\or h\or
%    i\or j\or k\or l\or m\or n\or o\or p\or
%    q\or r\or s\or t\or u\or v\or w\or x\or
%    y\or z\else\@ctrerr\fi}}%
%\def\@Alph#1{{\fontencoding{\latinencoding}\selectfont
%  \ifcase#1\or
%    A\or B\or C\or D\or E\or F\or G\or H\or
%    I\or J\or K\or L\or M\or N\or O\or P\or
%    Q\or R\or S\or T\or U\or V\or W\or X\or
%    Y\or Z\else\@ctrerr\fi}}%
%    \end{macrocode}
%
%    We add new enumeration style for Russian manuscripts with
%    Cyrillic letters.
%
%  \Describe\Asbuk{}
%    We begin by defining |\Asbuk| which works like |\Alph|, but produces
%    (uppercase) Cyrillic letters instead of Latin ones. The letters YO,
%    ISHRT, HRDSN, ERY, and SFTSN are skipped, as usual for such
%    enumeration.
%
%    \begin{macrocode}
\def\Asbuk#1{\expandafter\russian@Alph\csname c@#1\endcsname}
\if@uni@ode
  \def\russian@Alph#1{\ifcase#1\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 Ю\or Я\else\@ctrerr\fi}
\else
  \def\russian@Alph#1{\ifcase#1\or
    \CYRA\or\CYRB\or\CYRV\or\CYRG\or\CYRD\or\CYRE\or\CYRZH\or
    \CYRZ\or\CYRI\or\CYRK\or\CYRL\or\CYRM\or\CYRN\or\CYRO\or
    \CYRP\or\CYRR\or\CYRS\or\CYRT\or\CYRU\or\CYRF\or\CYRH\or
    \CYRC\or\CYRCH\or\CYRSH\or\CYRSHCH\or\CYREREV\or\CYRYU\or
    \CYRYA\else\@ctrerr\fi}
\fi
%    \end{macrocode}
%
%  \Describe\asbuk{}
%    The macro |\asbuk| is similar to |\alph|; it produces lowercase
%    Russian letters.
%
%    \begin{macrocode}
\def\asbuk#1{\expandafter\russian@alph\csname c@#1\endcsname}
\if@uni@ode
  \def\russian@alph#1{\ifcase#1\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 ю\or я\else\@ctrerr\fi}
\else
  \def\russian@alph#1{\ifcase#1\or
    \cyra\or\cyrb\or\cyrv\or\cyrg\or\cyrd\or\cyre\or\cyrzh\or
    \cyrz\or\cyri\or\cyrk\or\cyrl\or\cyrm\or\cyrn\or\cyro\or
    \cyrp\or\cyrr\or\cyrs\or\cyrt\or\cyru\or\cyrf\or\cyrh\or
    \cyrc\or\cyrch\or\cyrsh\or\cyrshch\or\cyrerev\or\cyryu\or
    \cyrya\else\@ctrerr\fi}
\fi
%    \end{macrocode}
%
%    Babel 3.9 has introduced a notion of a language attribute.
%    An \Lopt{ancient} attribute changes default behavior, which
%    uses modern Russian spelling, an activates an alternative set of
%    captions and date macros suitable for typesetting ancient
%    Slavonic and Church books.
%    \begin{macrocode}
\bbl@declare@ttribute{russian}{ancient}{%
 \PackageInfo{babel}{Russian attribute set to ancient}%
 \let\captionsrussian=\captionsrussian@ancient
 \let\daterussian=\daterussian@ancient
}
%    \end{macrocode}
%    We don't want for long internal macros to waste memory. So we declare
%    them to be usable within the preamble only.
%    \begin{macrocode}
\@onlypreamble\captionsrussian@ancient
\@onlypreamble\daterussian@ancient
%    \end{macrocode}
%
%    \subsection{Cyrillic math}
%
%    For compatibility with older Russian packages we could define the |\No|
%    macro. However the Russian number sign is now superseded with |\textnumero|.
%    Moreover, it can be found on the keyboard. Therefore we discard |\No|
%    since v.1.2.
%    \begin{macrocode}
%\DeclareRobustCommand{\No}{%
%   \ifmmode{\nfss@text{\textnumero}}\else\textnumero\fi}
%    \end{macrocode}
%
%
%    As of version 1.2 the macros |\cyrmath..| are not supported any more. They
%    require package \pkg{textmath} which is not available now. Instead of
%    |\cyrmath..| it is advised to use corresponding |\text..| commands; they
%    do work in math mode.
%    \begin{macrocode}
%\RequirePackage{textmath}
%  \@ifundefined{sym\cyrillicencoding letters}{}{%
%  \SetSymbolFont{\cyrillicencoding letters}{bold}\cyrillicencoding
%    \rmdefault\bfdefault\updefault
%  \DeclareSymbolFontAlphabet\cyrmathrm{\cyrillicencoding letters}
%    \end{macrocode}
%    And we need few commands to switch to different variants.
%    \begin{macrocode}
%\DeclareMathAlphabet\cyrmathbf\cyrillicencoding
%  \rmdefault\bfdefault\updefault
%\DeclareMathAlphabet\cyrmathsf\cyrillicencoding
%  \sfdefault\mddefault\updefault
%\DeclareMathAlphabet\cyrmathit\cyrillicencoding
%  \rmdefault\mddefault\itdefault
%\DeclareMathAlphabet\cyrmathtt\cyrillicencoding
%  \ttdefault\mddefault\updefault
%
%\SetMathAlphabet\cyrmathsf{bold}\cyrillicencoding
%  \sfdefault\bfdefault\updefault
%\SetMathAlphabet\cyrmathit{bold}\cyrillicencoding
%  \rmdefault\bfdefault\itdefault
%}
%    \end{macrocode}
%
%    \Describe\sh{}
%    \DescribeOther\ch{}%
%    \DescribeOther\tg{}%
%    \DescribeOther\ctg{}%
%    \DescribeOther\arctg{}%
%    \DescribeOther\arcctg{}%
%    \DescribeOther\th{}%
%    \DescribeOther\cth{}%
%    \DescribeOther\cosec{}%
%    We also define few math operator names according to Russian typesetting
%    traditions. Some math functions in Russian math books have names
%    different from English writings. For example, \texttt{sinh} in
%    Russian is called \texttt{sh}. Special consideration needs the
%    macro |\th| that conflicts with the text symbol |\th|
%    defined in Latin~1 encoding:
%
% \changes{1.2}{2004/05/21}{Change definition of \cs{th}}
% \changes{1.3j}{2017/08/11}{Log-like functions made robust}
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{amsopn}
  {%
    \DeclareMathOperator{\sh}{sh}%\MakeRobust\sh
    \DeclareMathOperator{\ch}{ch}%\MakeRobust\ch
    \DeclareMathOperator{\tg}{tg}%\MakeRobust\tg
    \DeclareMathOperator{\ctg}{ctg}%\MakeRobust\ctg
    \DeclareMathOperator{\arctg}{arctg}%\MakeRobust\arctg%
    \DeclareMathOperator{\arcctg}{arcctg}%\MakeRobust\arcctg%
    \DeclareMathOperator{\cth}{cth}%\MakeRobust\cth%
    \DeclareMathOperator{\cosec}{cosec}%\MakeRobust\cosec%
    \DeclareMathOperator{\math@th}{th}%
  }{%
    \DeclareRobustCommand\sh{\mathop{\operator@font sh}\nolimits}%\MakeRobust\sh%
    \DeclareRobustCommand\ch{\mathop{\operator@font ch}\nolimits}%\MakeRobust\ch%
    \DeclareRobustCommand\tg{\mathop{\operator@font tg}\nolimits}%\MakeRobust\tg%
    \DeclareRobustCommand\ctg{\mathop{\operator@font ctg}\nolimits}%\MakeRobust\ctg%
    \DeclareRobustCommand{\arctg}{\mathop{\operator@font arctg}\nolimits}%
    \DeclareRobustCommand\arcctg{\mathop{\operator@font arcctg}\nolimits}%\MakeRobust\arcctg%
    \DeclareRobustCommand\cth{\mathop{\operator@font cth}\nolimits}%\MakeRobust\cth%
    \DeclareRobustCommand\cosec{\mathop{\operator@font cosec}\nolimits}%\MakeRobust\cosec%
    \DeclareRobustCommand{\math@th}{\mathop{\operator@font arctg}\nolimits}%
  }%
%  \addto\extrasrussian{%
%    \babel@save{\th}%
%    \let\text@th\th
%    %\def\th{\TextOrMath{\text@th}{\math@th}}%
%    \DeclareRobustCommand{\th}{\TextOrMath{\text@th}{\math@th}}
%  }%
  \let\text@th\th
  \DeclareRobustCommand{\th}{\TextOrMath{\text@th}{\math@th}}
}
%    \end{macrocode}
%
%    \Describe\Prob{}%
%    \DescribeOther\Variance{}%
%    \DescribeOther\nod{}%
%    \DescribeOther\nok{}%
%    \DescribeOther\NOD{}%
%    \DescribeOther\NOK{}%
%    \DescribeOther\Proj{}%
%    Finally, we define some rare Russian mathematical symbols:
% \changes{1.3i}{2017/01/04}{\cs{NOD} and similar log-functions fixed}
%    \begin{macrocode}
\def\Prob{\mathop{\kern\z@\mathsf{P}}\nolimits}
\def\Variance{\mathop{\kern\z@\mathsf{D}}\nolimits}
\if@uni@ode
  \def\nod{\mathop{\mathrm{н.о.д.}}\nolimits}
  \def\nok{\mathop{\mathrm{н.о.к.}}\nolimits}
  \def\NOD{\mathop{\mathrm{НОД}}\nolimits}
  \def\NOK{\mathop{\mathrm{НОК}}\nolimits}
  \def\Proj{\mathop{\mathrm{Пр}}\nolimits}
\else
  \def\nod{\mathop{\textnormal{\cyrn.\cyro.\cyrd.}}\nolimits}
  \def\nok{\mathop{\textnormal{\cyrn.\cyro.\cyrk.}}\nolimits}
  \def\NOD{\mathop{\textnormal{\CYRN\CYRO\CYRD}}\nolimits}
  \def\NOK{\mathop{\textnormal{\CYRN\CYRO\CYRK}}\nolimits}
  \def\Proj{\mathop{\textnormal{\CYRP\cyrr}}\nolimits}
\fi
%    \end{macrocode}
%
%    \subsection{Final settings}
%
%    The macro |\ldf@finish| does work needed
%    at the end of each \file{.ldf} file. This
%    includes resetting the category code of the \texttt{@}-sign,
%    loading a local configuration file, and preparing the language
%    to be activated at |\begin{document}| time.
%
% \changes{1.1d}{1996/11/03}{Now use \cs{ldf@finish} to wrap up}
%    \begin{macrocode}
\ldf@finish{russian}
%    \end{macrocode}
%\iffalse
%</code>
%\fi
%\CheckSum{2374}
%\Finale
%
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote \"    Hash (number) \#
%%   Dollar        \$     Percent      \%    Ampersand     \&
%%   Acute accent  \'     Left paren   \(    Right paren   \)
%%   Asterisk      \*     Plus         \+    Comma         \,
%%   Minus         \-     Point        \.    Solidus       \/
%%   Colon         \:     Semicolon    \;    Less than     \<
%%   Equals        \=     Greater than \>    Question mark \?
%%   Commercial at \@     Left bracket \[    Backslash     \\
%%   Right bracket \]     Circumflex   \^    Underscore    \_
%%   Grave accent  \`     Left brace   \{    Vertical bar  \|
%%   Right brace   \}     Tilde        \~}
%%
%\endinput

%% Nonunicode Cyrillic Letters
%% \CYRA=А
%% \CYRB=Б
%% \CYRV=В
%% \CYRG=Г
%% \CYRGUP=Ґ
%% \CYRD=Д
%% \CYRE=Е
%% \CYRIE=Є
%% \CYRZH=Ж
%% \CYRZ=З
%% \CYRI=И
%% \CYRII=I
%% \CYRYI=Ї
%% \CYRISHRT=Й
%% \CYRK=К
%% \CYRL=Л
%% \CYRM=М
%% \CYRN=Н
%% \CYRO=О
%% \CYRP=П
%% \CYRR=Р
%% \CYRS=С
%% \CYRT=Т
%% \CYRU=У
%% \CYRF=Ф
%% \CYRH=Х
%% \CYRC=Ц
%% \CYRCH=Ч
%% \CYRSH=Ш
%% \CYRSHCH=Щ
%% \CYRYU=Ю
%% \CYRYA=Я
%% \CYRSFTSN=Ь
%%
%% \cyra=а
%% \cyrb=б
%% \cyrv=в
%% \cyrg=г
%% \cyrgup=ґ
%% \cyrd=д
%% \cyre=е
%% \cyrie=є
%% \cyrzh=ж
%% \cyrz=з
%% \cyri=и
%% \cyrii=i
%% \cyryi=ї
%% \cyrishrt=й
%% \cyrk=к
%% \cyrl=л
%% \cyrm=м
%% \cyrn=н
%% \cyro=о
%% \cyrp=п
%% \cyrr=р
%% \cyrs=с
%% \cyrt=т
%% \cyru=у
%% \cyrf=ф
%% \cyrh=х
%% \cyrc=ц
%% \cyrch=ч
%% \cyrsh=ш
%% \cyrshch=щ
%% \cyryu=ю
%% \cyrya=я
%% \cyrsftsn=ь