diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/babel-contrib/serbian/serbian.dtx |
Initial commit
Diffstat (limited to 'macros/latex/contrib/babel-contrib/serbian/serbian.dtx')
-rw-r--r-- | macros/latex/contrib/babel-contrib/serbian/serbian.dtx | 407 |
1 files changed, 407 insertions, 0 deletions
diff --git a/macros/latex/contrib/babel-contrib/serbian/serbian.dtx b/macros/latex/contrib/babel-contrib/serbian/serbian.dtx new file mode 100644 index 0000000000..a9dee24bf4 --- /dev/null +++ b/macros/latex/contrib/babel-contrib/serbian/serbian.dtx @@ -0,0 +1,407 @@ +% \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/07/16 2.0 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} +\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
\ No newline at end of file |