summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/cyrillicnumbers.sty
blob: 171ac4415687b34e4d32e2886c886b6041278308 (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
\ProvidesPackage{cyrillicnumbers}
        [2019/09/13 v0.1 %
         Formatting of Cyrillic alphabetic numbers]

%% This follows https://en.wikipedia.org/wiki/Cyrillic_numerals

% Numbers are often distinguished from text by centered dots.
% The commented code does this. We leave it deactivated until
% we get some expertise.
\newrobustcmd\cnw@print{}
\newrobustcmd\cnw@false{%
  \renewrobustcmd\cnw@print{}}
\newrobustcmd\cnw@true{%
%   \renewrobustcmd\cnw@print{$\cdot$}%
}
\cnw@true

\protected\def\cyr@alph#1{\expandafter\@cyr@alph\expandafter{\number#1}}
\def\@cyr@alph#1{%
  \ifnum#1<\@ne\space\cyr@ill@value{#1}%
  \else
    \cnw@print
    \ifnum#1<10\expandafter\cyr@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\cyr@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\cyr@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\cyr@num@iv\number#1%
          \else
            \ifnum#1<100000\expandafter\cyr@num@v\number#1%
            \else
              \ifnum#1<1000000\expandafter\cyr@num@vi\number#1%
              \else
                \space\cyr@ill@value{#1}%
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}

\protected\def\cyr@Alph#1{\expandafter\@cyr@Alph\expandafter{\number#1}}
\def\@cyr@Alph#1{%
  \ifnum#1<\@ne\space\cyr@ill@value{#1}%
  \else
    \cnw@print
    \ifnum#1<10\expandafter\cyr@Num@i\number#1%
    \else
      \ifnum#1<100\expandafter\cyr@Num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\cyr@Num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\cyr@Num@iv\number#1%
          \else
            \ifnum#1<100000\expandafter\cyr@Num@v\number#1%
            \else
              \ifnum#1<1000000\expandafter\cyr@Num@vi\number#1%
              \else
                \space\cyr@ill@value{#1}%
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}

% Lowercase
\def\cyr@num@i#1{%
  \ifcase#1 \or а\or в\or г\or д\or е\or ѕ\or з\or и\or ѳ\fi
  \ifnum#1=\z@\else\cnw@true\fi\cnw@print}
\def\cyr@num@ii#1{%
  \ifcase#1 \or і\or к\or л\or м\or н\or ѯ\or о\or п\or ч\fi
  \ifnum#1=\z@\else\cnw@true\fi\cyr@num@i}
\def\cyr@num@iii#1{%
  \ifcase#1 \or р\or с\or т\or у\or ф\or х\or ѱ\or ѡ\or ц\fi
  \ifnum#1=\z@\cnw@false\else\cnw@true\fi\cyr@num@ii}
\def\cyr@num@iv#1{%
  \ifnum#1=\z@\else ҂\fi
  \ifcase#1 \or а\or в\or г\or д\or е\or ѕ\or з\or и\or ѳ\fi
  \cyr@num@iii}
\def\cyr@num@v#1{%
  \ifnum#1=\z@\else ҂\fi
  \ifcase#1 \or і\or к\or л\or м\or н\or ѯ\or о\or п\or ч\fi
  \cyr@num@iv}
\def\cyr@Num@vi#1{%
  \ifnum#1=\z@\else ҂\fi
  \ifcase#1 \or р\or с\or т\or у\or ф\or х\or ѱ\or ѡ\or ц\fi
  \cyr@num@v}

% Uppercase
\def\cyr@Num@i#1{%
  \ifcase#1 \or А\or В\or Г\or Д\or Е\or Ѕ\or З\or И\or Ѳ\fi
  \ifnum#1=\z@\else\cnw@true\fi\cnw@print}
\def\cyr@Num@ii#1{%
  \ifcase#1 \or І\or К\or Л\or М\or Н\or Ѯ\or О\or П\or Ч\fi
  \ifnum#1=\z@\else\cnw@true\fi\cyr@Num@i}
\def\cyr@Num@iii#1{%
  \ifcase#1 \or Р\or С\or Т\or У\or Ф\or Х\or Ѱ\or Ѡ\or Ц\fi
  \ifnum#1=\z@\cnw@false\else\cnw@true\fi\cyr@Num@ii}
\def\cyr@Num@iv#1{%
  \ifnum#1=\z@\else ҂\fi
  \ifcase#1 \or А\or В\or Г\or Д\or Е\or Ѕ\or З\or И\or Ѳ\fi
  \cyr@Num@iii}
\def\cyr@Num@v#1{%
  \ifnum#1=\z@\else ҂\fi
  \ifcase#1 \or І\or К\or Л\or М\or Н\or Ѯ\or О\or П\or Ч\fi
  \cyr@Num@iv}
\def\cyr@Num@vi#1{%
  \ifnum#1=\z@\else ҂\fi
  \ifcase#1 \or Р\or С\or Т\or У\or Ф\or Х\or Ѱ\or Ѡ\or Ц\fi
  \cyr@Num@v}
\def\cyr@ill@value#1{\xpg@warning{Illegal value (#1) for cyr numeral}[$#1$]}

\endinput