summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/babel-serbian/serbian.dtx
blob: dd46341dfc8dcbaa3a3ae28f68475e77c0153ac3 (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
% \iffalse meta-comment
%
% Copyright 2019 Uroš Stefanović and any individual authors
% listed elsewhere in this file.  All rights reserved.
% 
% This file is intended to be used with the Babel system.
% ------------------------------------------------------
% 
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% The Current Maintainer of this work is Uroš Stefanović.
% 
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
% \fi
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{serbian.dtx}
%</dtx>
%<code>\ProvidesLanguage{serbian}
%\fi
%\ProvidesFile{serbian.dtx}
        [2019/12/15 2.0a Serbian Latin support for the Babel system]
%\iffalse
%% File `serbian.dtx'
%
%    This file is part of the babel system, it provides the source
%    code for the Serbian Latin language definition file.
%<*filedriver>
\documentclass{ltxdoc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,top=2.0cm,left=3cm,right=2.5cm,bottom=2cm,includefoot,includehead]{geometry}
\title{The Serbian Latin Language in the \babel\ system}
\author{Uroš Stefanović\footnote{\texttt{urostajms@gmail.com}}} 
\newcommand*\babel{\textsf{babel}}
\newcommand*\langvar{$\langle \it lang \rangle$}
\newcommand*\note[1]{}
\newcommand*\Lopt[1]{\textsf{#1}}
\newcommand*\file[1]{\texttt{#1}}
\begin{document}
 \maketitle
 \DocInput{serbian.dtx}
\end{document}
%</filedriver>
%\fi
% \GetFileInfo{serbian.dtx}
%
%  \section*{The Serbian Latin Language}
%
%    The file \file{\filename} defines all the language definition
%    macros for the Serbian language, typeset in a Latin script.
%
%    For this language the character |"| is made active. In
%    table~\ref{tab:serbian-quote} an overview is given of its
%    purpose. One of the reasons for this is that in the Serbian
%    language some special characters are used.
%
%    \begin{table}[htb]
%     \begin{center}
%     \begin{tabular}{lp{8cm}}
%      |"c| & |\v c|, also implemented for the lowercase and uppercase s and z.                \\
%      |"d| & |\dj|, also implemented for |"D|.                     \\
%      |"-| & An explicit hyphen sign, allowing hyphenation
%             in the rest of the word; inserts a hyphen which is repeated at the beginning of the
%             next line (recommended to use for compound words with hyphen).                \\
%      \verb="|= & Disables ligature at this position.                   \\
%      |""| & Similar to |"-| but prints no hyphen sign. 			   \\
%      |"~| & Compound word mark without a breakpoint, prints hyphen
%            prohibiting hyphenation at the point.		                \\
%      |"=| & A compound word mark with a breakpoint, prints hyphen
%            allowing hyphenation in the composing words.               \\
%      |"`| & German opening double quote (looks like ,\kern-0.08em,).      \\
%      |"'| & German closing double quote (looks like ``).                    \\
%      |"'| & (if the \Lopt{quotes} attribute is used) Closing double quote (looks like '').                    \\
%      |"<| & French opening double quote (looks like $<\!\!<$).     \\
%      |">| & French closing double quote (looks like $>\!\!>$).    \\
%     \end{tabular}
%     \caption{The extra definitions made
%              by \file{serbian.ldf}}\label{tab:serbian-quote}
%     \end{center}
%    \end{table}
%
%    Macro |\today| prints the date in Serbian. Alternatively, if attribute \Lopt{datei} is used,
%    |\today| prints the current date, but prints `juni' and `juli' for `June' and `July'.
%    If you prefer to use `juni' and `juli' instead of default `jun' and `jul',
%    use the \Lopt{datei} attribute. Also, the |\today*| macro prints the date without dot after the year
%    (used when after the date is the punctuation mark, such as comma).
%     Alternatively, the commands |\todayRoman| and |\todayRoman*| prints the current date using Roman numerals for months.
%
%    Apart from defining shorthands we need to make sure that the
%    first paragraph of each section is indented. Furthermore the
%    following new math operators are defined: |\sh|, |\ch|, |\tg|, |\ctg|,
%    |\arctg|, |\arcctg|, |\th|, |\cth|, |\arsh|,
%    |\arch|, |\arth|, |\arcth|, |\cosec|, |\Prob|, |\Expect|, |\Variance|,
%    |\arcsec|, |\arccosec|, |\sech|, |\cosech|, |\arsech|, |\arcosech|,
%    |\NZD|, |\nzd|, |\NZS|, |\nzs|.
%
% By default, a ekavian spelling is enabled. For ijekavian
% spelling can be enabled by setting the attribute to \Lopt{ijekav}. To set
% an attribute, put the |\languageattribute| macro within a document preamble after
% \babel, for example,
%\begin{verbatim}
%    \usepackage[english,serbian]{babel}
%    \languageattribute{serbian}{ijekav}
%\end{verbatim}
% Setting the \Lopt{ijekav} attribute changes the built-in strings (caption names).
% For example, the part will be entitled as
% `Deo' by default and as `Dio' if the
% Serbian language attribute is set to \Lopt{ijekav}.
% Same result can be achieved using a modifier as follows:
%\begin{verbatim}
%    \usepackage[english,serbian.ijekav]{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).
% Also, it's possible to use more than one attribute:
%\begin{verbatim}
%    \usepackage[english,serbian.ijekav.datei.quotes]{babel}
%\end{verbatim}
%
% The file \file{serbian.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).
%
% \StopEventually{}
%
%  \section*{The code}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
%
%    \begin{macrocode}
%<*code>
\LdfInit{serbian}{captionsserbian}
%    \end{macrocode}
%
%    First, we check if Lua\LaTeX\ or Xe\LaTeX\ is running. If so, we set
%    boolean key |\if@srb@uni@ode| to true.
%
%    \begin{macrocode}
\ifdefined\if@srb@uni@ode
  \PackageError{babel}{if@srb@uni@ode already defined.}
  \relax
\fi
\newif\if@srb@uni@ode
\ifdefined\luatexversion \@srb@uni@odetrue \else
\ifdefined\XeTeXrevision \@srb@uni@odetrue \fi\fi
%    \end{macrocode}
%
%    Check if hyphenation patterns for the Serbian language have been
%    loaded in \file{language.dat}. Namely, we check for the existence of
%    |\l@serbian|. If it is not defined, we declare Serbian as dialect
%    for the default language number 0 which almost for sure is English.
%
%    \begin{macrocode}
\ifx\l@serbian\@undefined
  \@nopatterns{Serbian}
  \adddialect\l@serbian0
\fi
%    \end{macrocode}
%
%    For Serbian the \texttt{"} character is made active. This is done
%    once, later on its definition may vary. Other languages in the
%    same document may also use the \texttt{"}~character for
%    shorthands; we specify that the Serbian group of shorthands
%    should be used. We save the original double quote character
%    in the |\dq| macro to keep it available. The shorthand \texttt{"-}
%    should be used in places where a word contains an explictit
%    hyphenation character. According to the rules of the Serbian language, when
%    a word break occurs at an explicit hyphen it must appear both at the end of the
%    first line and at the beginning of the second line.
%
%    \begin{macrocode}
\initiate@active@char{"}
\begingroup \catcode`\"12
\def\reserved@a{\endgroup
  \def\@SS{\mathchar"7019 }
  \def\dq{"}}
\reserved@a
\declare@shorthand{serbian}{"c}{\textormath{\v c}{\check c}}
\declare@shorthand{serbian}{"d}{\textormath{\dj}{\textnormal{\dj}}}
\declare@shorthand{serbian}{"s}{\textormath{\v s}{\check s}}
\declare@shorthand{serbian}{"z}{\textormath{\v z}{\check z}}
\declare@shorthand{serbian}{"C}{\textormath{\v C}{\check C}}
\declare@shorthand{serbian}{"D}{\textormath{\DJ}{\textnormal{\DJ}}}
\declare@shorthand{serbian}{"S}{\textormath{\v S}{\check S}}
\declare@shorthand{serbian}{"Z}{\textormath{\v Z}{\check Z}}
\declare@shorthand{serbian}{"`}{\quotedblbase}
\declare@shorthand{serbian}{"'}{\textquotedblleft}
\declare@shorthand{serbian}{"<}{\guillemotleft}
\declare@shorthand{serbian}{">}{\guillemotright}
\declare@shorthand{serbian}{""}{\hskip\z@skip}
\declare@shorthand{serbian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{serbian}{"=}{\nobreak-\hskip\z@skip}
\declare@shorthand{serbian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}
\declare@shorthand{serbian}{"-}{\nobreak\discretionary{-}{-}{-}\bbl@allowhyphens}
%    \end{macrocode}
%
%    The macro |\captionsserbian| defines all strings used in the four
%    standard documentclasses provided with \LaTeX.
%
%    \begin{macrocode}
\addto\captionsserbian{%
  \def\prefacename{Predgovor}%
  \def\refname{Literatura}%
  \def\abstractname{Sa\v zetak}%
  \def\bibname{Bibliografija}%
  \def\chaptername{Glava}%
  \def\appendixname{Dodatak}%
  \def\contentsname{Sadr\v zaj}%
  \def\listfigurename{Spisak slika}%
  \def\listtablename{Spisak tabela}%
  \def\indexname{Indeks}%
  \def\figurename{Slika}%
  \def\tablename{Tabela}%
  \def\partname{Deo}%
  \def\enclname{Prilozi}%
  \def\ccname{Kopije}%
  \def\headtoname{Prima}%
  \def\pagename{strana}%
  \def\seename{vidi}%
  \def\alsoname{vidi tako\dj e}%
  \def\proofname{Dokaz}%
  \def\glossaryname{Re\v cnik}%
}%
\if@srb@uni@ode
  \addto\captionsserbian{%
    \def\abstractname{Sažetak}%
    \def\contentsname{Sadržaj}%
    \def\alsoname{vidi takođe}%
    \def\glossaryname{Rečnik}%
  }%
\fi
\let\captionsserbian@ijekav=\captionsserbian
\addto\captionsserbian@ijekav{%
  \def\partname{Dio}%
  \def\glossaryname{Rje\v cnik}%
}
\if@srb@uni@ode
  \addto\captionsserbian@ijekav{%
    \def\glossaryname{Rječnik}%
  }
\fi
%    \end{macrocode}
%
%    The macro |\dateserbian| redefines the commands |\today|, |\today*|, |\todayRoman| and |\todayRoman*| to produce Serbian dates.
%
%    \begin{macrocode}
  \def\dateserbian{%
   \def\month@serbian{\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}%
    \def\today{\number\day.~\month@serbian\ \number\year\@ifstar{}{.}}%
    \def\todayRoman{\number\day.~\@Roman\month~\number\year\@ifstar{}{.}}}
  \let\dateserbian@datei=\dateserbian
  \addto\dateserbian@datei{
    \def\month@serbian@datei{\ifnum\month=6 juni%
    \else\ifnum\month=7 juli\else\month@serbian\fi\fi}%
    \def\today{\number\day.~\month@serbian@datei\ \number\year\@ifstar{}{.}}
}
%    \end{macrocode}
%
%    The Serbian hyphenation patterns can be used with |\lefthyphenmin| and
%    |\righthyphenmin| set to 2. (Actually, the “official” definition allows even one character for |lefthyphen|,
%    but it is recommended to use value two for better results.)
%
%    \begin{macrocode}
\providehyphenmins{\CurrentOption}{\tw@\tw@}
\providehyphenmins{serbian}{\tw@\tw@}
%    \end{macrocode}
%
%    We specify that the Serbian group of shorthands should be used.
%
%    \begin{macrocode}
\addto\extrasserbian{\languageshorthands{serbian}}
\addto\extrasserbian{\bbl@activate{"}}
\addto\noextrasserbian{\bbl@deactivate{"}}
%    \end{macrocode}
%
%    Serbian typesetting requires |frenchspacing|. So, we add commands to
%	 |\extrasserbian| and |\noextrasserbian| to turn it on and off, respectively.
%
%    \begin{macrocode}
\addto\extrasserbian{\bbl@frenchspacing}
\addto\noextrasserbian{\bbl@nonfrenchspacing}
%    \end{macrocode}
%
%    In Serbian the first paragraph of each section should be indented.
%
%    \begin{macrocode}
\let\@aifORI\@afterindentfalse
\def\bbl@serbianindent{\let\@afterindentfalse\@afterindenttrue\@afterindenttrue}
\def\bbl@nonserbianindent{\let\@afterindentfalse\@aifORI\@afterindentfalse}
\addto\extrasserbian{\bbl@serbianindent}
\addto\noextrasserbian{\bbl@nonserbianindent}
%    \end{macrocode}
%
%    An |ijekav| attribute changes default behavior and activates an
%    alternative set of captions suitable for typesetting in ijekavian dialect.
%    The |quotes| attribute changes the |"'| shorthand to produce '' as closing quote,
%    instead the traditional `` quote of Serbian language.
%    Also, the |datei| attribute will produce `juni' and `juli' instead `jun' and `jul'
%    for date.
%
%    \begin{macrocode}
\bbl@declare@ttribute{serbian}{ijekav}{%
 \PackageInfo{babel}{Serbian attribute set to ijekav}%
 \let\captionsserbian=\captionsserbian@ijekav }
\@onlypreamble\captionsserbian@ijekav
\bbl@declare@ttribute{serbian}{quotes}{%
 \PackageInfo{babel}{Serbian attribute set to quotes}%
 \declare@shorthand{serbian}{"'}{\textquotedblright} }
\bbl@declare@ttribute{serbian}{datei}{%
 \PackageInfo{babel}{Serbian attribute set to datei}%
 \let\dateserbian=\dateserbian@datei }
\@onlypreamble\dateserbian@datei
%    \end{macrocode}
%
%    Some math functions in Serbian math books have other names:
%    e.g. |sinh| in Serbian is written as |sh| etc. So we define a
%    number of new math operators.
%
%    \begin{macrocode}
\def\sh{\mathop{\operator@font sh}\nolimits}
\def\ch{\mathop{\operator@font ch}\nolimits}
\def\tg{\mathop{\operator@font tg}\nolimits}
\def\ctg{\mathop{\operator@font ctg}\nolimits}
\def\arctg{\mathop{\operator@font arctg}\nolimits}
\def\arcctg{\mathop{\operator@font arcctg}\nolimits}
\addto\extrasserbian{%
  \babel@save{\th}%
  \let\ltx@th\th
  \def\th{\textormath{\ltx@th}%
                     {\mathop{\operator@font th}\nolimits}}%
  }
\def\cth{\mathop{\operator@font cth}\nolimits}
\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\cosec{\mathop{\operator@font cosec}\nolimits}
\def\arcsec{\mathop{\operator@font arcsec}\nolimits}
\def\arccosec{\mathop{\operator@font arccosec}\nolimits}
\def\sech{\mathop{\operator@font sech}\nolimits}
\def\cosech{\mathop{\operator@font cosech}\nolimits}
\def\arsech{\mathop{\operator@font arsech}\nolimits}
\def\arcosech{\mathop{\operator@font arcosech}\nolimits}
\def\Prob{\mathop{\kern\z@\mathsf{P}}\nolimits}
\def\Expect{\mathop{\kern\z@\mathsf{E}}\nolimits}
\def\Variance{\mathop{\kern\z@\mathsf{D}}\nolimits}
\def\nzs{\mathop{\operator@font nzs}\nolimits}
\def\nzd{\mathop{\operator@font nzd}\nolimits}
\def\NZS{\mathop{\operator@font NZS}\nolimits}
\def\NZD{\mathop{\operator@font NZD}\nolimits}
%    \end{macrocode}
%
%    The macro |\ldf@finish| takes care of looking for a
%    configuration file, setting the main language to be switched on
%    at |\begin{document}| and resetting the category code of
%    \texttt{@} to its original value.
%
%    \begin{macrocode}
\ldf@finish{serbian}
%</code>
%    \end{macrocode}
%
% \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