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
|
\ProvidesFile{gloss-serbian.ldf}[polyglossia: module for serbian]
%TODO split into gloss-serbiancyr.ldf and gloss-serbianlat.ldf
%% load these automatically from polyglossia.sty according to the script option ??
%% same thing for all languages that have a "script" key !
%% BETTER APPROACH: see gloss-sanskrit!
\RequirePackage{xpg-cyrillicnumbers}
\PolyglossiaSetup{serbian}{
bcp47=sr-Latn,
langtag=SRB,
hyphennames={serbian},
hyphenmins={2,2},
frenchspacing=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
indentfirst=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
fontsetup=false,
localnumeral=serbiannumerals,
Localnumeral=Serbiannumerals,
babelname=serbian
%TODO localalph
}
% BCP-47 compliant aliases
\setlanguagealias*{serbian}{sr}
\setlanguagealias*[script=Cyrillic]{serbian}{sr-Cyrl}
\setlanguagealias*[script=Latin]{serbian}{sr-Latn}
% Babel aliases
\setlanguagealias[script=Cyrillic]{serbian}{serbianc}
\ifluatex
\RequirePackage{luavlna}
\fi
\newif\if@serbian@cyr
\define@choicekey*+{serbian}{Script}[\xpg@val\xpg@nr]{cyrillic,latin}[cyrillic]{%
\ifcase\xpg@nr\relax
% cyrillic:
\@serbian@cyrtrue
\SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl}
\xpg@fontsetup@nonlatin{serbian}%
\or
% latin:
\@serbian@cyrfalse
\SetLanguageKeys{serbian}{scripttag=latn,script=Latin,babelname=serbian,bcp47=sr-Latn}
\xpg@fontsetup@latin{serbian}%
%TODO \def\serbian@language{\language=\l@serbianlat}%
% or should we use Croatian patterns as a fallback for the time being???
\fi
\xpg@info{Option: Serbian, script=\xpg@val}%
}{\xpg@warning{Unknown Serbian script `#1'}}
\define@key{serbian}{script}[Cyrillic]{\setkeys{serbian}{Script=#1}}
\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals
\define@choicekey*+{serbian}{numerals}[\xpg@val\xpg@nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
\ifcase\xpg@nr\relax
% arabic:
\cyrillic@numeralsfalse%
\cyrillic@asbuk@numeralsfalse%
\or
% cyrillic:
\cyrillic@numeralstrue%
\cyrillic@asbuk@numeralsfalse%
\or
% cyrillic-trad:
\cyrillic@numeralstrue%
\cyrillic@asbuk@numeralsfalse%
\or
% cyrillic-alph:
\cyrillic@numeralstrue%
\cyrillic@asbuk@numeralstrue%
\fi
\xpg@info{Option: Serbian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Serbian numerals value `#1'}}
\define@boolkey{serbian}[serbian@]{splithyphens}[true]{}
\setkeys{serbian}{Script,numerals}
% Register default options
\xpg@initialize@gloss@options{serbian}{script=Cyrillic,numerals=arabic,splithyphens=true}
\def\captionsserbian{%
\if@serbian@cyr\captionsserbian@cyr\else\captionsserbian@lat\fi
}
\def\dateserbian{%
\if@serbian@cyr\dateserbian@cyr\else\dateserbian@lat\fi
}
\def\captionsserbian@lat{%
\def\refname{Bibliografija}%
\def\abstractname{Sažetak}%
\def\bibname{Literatura}%
\def\prefacename{Predgovor}%
\def\chaptername{Glava}%
\def\appendixname{Dodatak}%
\def\contentsname{Sadržaj}%
\def\listfigurename{Spisak slika}%
\def\listtablename{Spisak tabela}%
\def\indexname{Registar}%
\def\figurename{Slika}%
\def\tablename{Tabela}%
\def\partname{Deo}%
\renewcommand\thepart{\ifcase\value{part}\or Prvi\or Drugi\or
Treći\or Četvrti\or Peti\or Šesti\or Sedmi\or Osmi\or
Deveti\or Deseti\or Jedanaesti\or Dvanaesti\or Trinaesti\or
Četrnaesti\or Petnaesti\or Šesnaesti\or Sedamnaesti\or
Osamnaesti\or Devetnaesti\or Dvadeseti\fi}%
\def\pagename{Strana}%
\def\seename{Vidi}%
\def\alsoname{Vidi takođe}%
\def\enclname{Prilozi}%
\def\ccname{Kopije}%
\def\headtoname{Prima}%
\def\proofname{Dokaz}%
\def\glossaryname{Rečnik nepoznatih reči}%
}
\def\dateserbian@lat{%
\def\today{\number\day .~\ifcase\month\or
januar\or februar\or mart\or april\or maj\or
jun\or jul\or avgust\or septembar\or oktobar\or novembar\or
decembar\fi \space \number\year.}%
}
\def\captionsserbian@cyr{%
\def\refname{Библиографија}%
\def\abstractname{Сажетак}%
\def\bibname{Литература}%
\def\prefacename{Предговор}%
\def\chaptername{Глава}%
\def\appendixname{Додатак}%
\def\contentsname{Садржај}%
\def\listfigurename{Списак слика}%
\def\listtablename{Списак табела}%
\def\indexname{Регистар}%
\def\figurename{Слика}%
\def\tablename{Табела}%
\def\partname{Део}%
\renewcommand\thepart{\ifcase\value{part}\or Први\or Други\or Трећи\or
Четврти\or Пети\or Шести\or Седми\or Осми\or Девети\or Десети\or
Једанаести\or Дванаести\or Тринаести\or Четрнаести\or Петнаести\or
Шеснаести\or Седамнаести\or Осамнаести\or Деветнаести\or Двадесети\fi}%
\def\pagename{Страна}%
\def\seename{Види}%
\def\alsoname{Види такође}%
\def\enclname{Прилози}%
\def\ccname{Копије}%
\def\headtoname{Прима}%
\def\proofname{Доказ}%
\def\glossaryname{Речник непознатих речи}%
}
\def\dateserbian@cyr{%
\def\today{\number\day .~\ifcase\month\or
јануар\or фебруар\or март\or април\or мај\or
јун\or јул\or август\or септембар\or октобар\or новембар\or
децембар\fi \space \number\year.}%
}
% Use \providecommand here as the ldf file might
% be reloaded via serbianc.
\providecommand{\serbiannumerals}[2]{\serbiannumber{#2}}
\providecommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}
\def\serbiannumber#1{%
\ifcyrillic@numerals
\ifcyrillic@asbuk@numerals
\serbian@asbuk@alph{#1}%
\else
\cyr@alph{#1}%
\fi
\else
\number#1%
\fi%
}
\def\Serbiannumber#1{%
\ifcyrillic@numerals
\ifcyrillic@asbuk@numerals
\serbian@asbuk@Alph{#1}%
\else
\cyr@Alph{#1}%
\fi
\else
\number#1%
\fi%
}
\let\serbiannumeral=\serbiannumber
\let\Serbiannumeral=\Serbiannumber
\def\serbian@numbers{%
\let\latin@alph\@alph
\let\latin@Alph\@Alph
\ifcyrillic@numerals
\def\serbian@alph##1{\expandafter\serbiannumeral\expandafter{\the##1}}%
\def\serbian@Alph##1{\expandafter\Serbiannumeral\expandafter{\the##1}}%
\let\@alph\serbian@alph%
\let\@Alph\serbian@Alph%
\fi
}
\def\noserbian@numbers{%
\let\@alph\latin@alph
\let\@Alph\latin@Alph
}
\def\serbian@@splhyphen#1{%
\def\serbian@sh@tmp{%
\if\serbian@sh@next-#1%
\else\expandafter\serbian@@@splhyphen{#1}\fi%
}%
\futurelet\serbian@sh@next\serbian@sh@tmp%
}
\def\serbian@@@splhyphen#1{%
\ifnum\hyphenchar \font>0%
\kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
\nobreak\hskip\z@%
\else%
#1%
\fi%
}
\def\serbian@splhyphen{%
\serbian@@splhyphen{-}%
}
\ifxetex
% splithyphens
\newXeTeXintercharclass\serbian@hyphen % -
\newXeTeXintercharclass\serbian@nonsyllabicpreposition%
\fi
\def\serbian@hyphens{%
\ifluatex
\AfterPreamble{\enablesplithyphens{serbian}}%
\else
\XeTeXinterchartokenstate=1
\XeTeXcharclass `\- \serbian@hyphen
\XeTeXinterchartoks \z@ \serbian@hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
% necessary if used together with vlna:
\XeTeXinterchartoks \serbian@nonsyllabicpreposition \serbian@hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
\fi%
}
\def\noserbian@hyphens{%
\ifluatex
\AfterPreamble{\disablesplithyphens{serbian}}%
\else
\XeTeXcharclass `\- \z@
\fi%
}
\def\blockextras@serbian{%
\ifcyrillic@numerals\serbian@numbers\else\noserbian@numbers\fi%
\ifserbian@splithyphens\serbian@hyphens\else\noserbian@hyphens\fi%
}
\def\inlineextras@serbian{%
\ifserbian@splithyphens\serbian@hyphens\else\noserbian@hyphens\fi%
}
\def\noextras@serbian{%
\ifcyrillic@numerals\noserbian@numbers\fi%
\noserbian@hyphens%
}
\def\Asbuk#1{\expandafter\serbian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\serbian@asbuk@alph\csname c@#1\endcsname}
\def\AsbukTrad#1{\expandafter\cyr@Alph\csname c@#1\endcsname}
\def\asbukTrad#1{\expandafter\cyr@alph\csname c@#1\endcsname}
% This is a poor man's cyrillic alphanumeric.
% It just uses the alphabet and thus ends at 30.
\def\serbian@asbuk@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 Ч\or Џ\or Ш%
\else\xpg@ill@value{#1}{serbian@asbuk@Alph}\fi%
}
\def\serbian@asbuk@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 ч\or џ\or ш%
\else\xpg@ill@value{#1}{serbian@asbuk@alph}\fi%
}
\endinput
% TODO ? stuff from babel
% If you implement this, add an option mathfunction as in gloss-russian.ldf
\def\sh{\mathop{\operator@font sh}\nolimits} % same as \sinh
\def\ch{\mathop{\operator@font ch}\nolimits} % same as \cosh
\def\th{\mathop{\operator@font th}\nolimits} % same as \tanh
\def\cth{\mathop{\operator@font cth}\nolimits} % same as \coth
\def\arsh{\mathop{\operator@font arsh}\nolimits}
\def\arch{\mathop{\operator@font arch}\nolimits}
\def\arth{\mathop{\operator@font arth}\nolimits}
\def\arcth{\mathop{\operator@font arcth}\nolimits}
\def\tg{\mathop{\operator@font tg}\nolimits} % same as \tan
\def\ctg{\mathop{\operator@font ctg}\nolimits} % same as \cot
\def\arctg{\mathop{\operator@font arctg}\nolimits} % same as \arctan
\def\arcctg{\mathop{\operator@font arcctg}\nolimits}
\def\Prob{\mathop{\mathsf P\hskip0pt}\nolimits}
\def\Expect{\mathop{\mathsf E\hskip0pt}\nolimits}
\def\Variance{\mathop{\mathsf D\hskip0pt}\nolimits}
|