summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/fixlatvian/fixlatvian.sty
blob: 8a53df5302c2001652b1685d73a0921303361016 (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
%%
%% This is file `fixlatvian.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fixlatvian.dtx  (with options: `package')
%% 
%% Copyright (C) Andrey Vihrov <andrey.vihrov@gmail.com>, 2010-2011
%%
%% This work 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 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% See the README for a list of files that constitute this work.
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{svn-prov}
\ProvidesPackageSVN
  {$Id: fixlatvian.dtx 163 2011-02-05 18:51:11Z andrey.vihrov $}
  [v1a Improved Latvian support]
\DefineFileInfoSVN\relax
\RequirePackage{caption}
\RequirePackage{etoolbox}
\RequirePackage{perpage}
\RequirePackage{polyglossia}
\RequirePackage{xstring}
\RequirePackage{indentfirst}
\RequirePackage{icomma}
\ProcessOptions\relax
\@ifundefined{latvian@loaded}{\setdefaultlanguage{latvian}}{}
\frenchspacing
\newcommand{\FixL@warning}[1]{\PackageWarning{fixlatvian}{#1}}
\newcommand{\FixL@warning@noline}[1]{%
  \PackageWarningNoLine{fixlatvian}{#1}}
\newcommand{\FixL@info}[1]{\PackageInfo{fixlatvian}{#1}}
\newcommand{\FixL@alnum}{%
  ABCDEFGHIJKLMNOPQRSTUVWXYZ%
  abcdefghijklmnopqrstuvwxyz%
  0123456789%
}
\newcommand{\FixL@patchfailed}[1]{%
  \FixL@info{Could not change the definition of the \protect #1 command}}
\newcommand{\FixL@checkbefore}[1]{%
  \expandafter\newif\csname ifFixL@#1@before\endcsname
  \@ifpackageloaded{#1}{\csname FixL@#1@beforetrue\endcsname}{}%
  \AtBeginDocument{%
    \@ifpackageloaded{#1}{%
      \csname ifFixL@#1@before\endcsname\else
        \FixL@warning@noline{This package should be loaded after #1}%
      \fi
    }{}}}
\FixL@checkbefore{hyperref}
\FixL@checkbefore{amsthm}
\newcommand{\FixL@p}{.\@\nobreak}
\newcommand{\FixL@bigspace}{\hspace{.66667em}}
\CheckCommand*{\@seccntformat}[1]{\csname the#1\endcsname\quad}
\renewcommand{\@seccntformat}[1]{%
  \csname the#1\endcsname\FixL@p\FixL@bigspace}
\let\FixL@old@numberline\numberline
\renewcommand{\numberline}[1]{%
  \StrRight{#1}{1}[\FixL@tempa]%
  \FixL@old@numberline{#1%
    \IfSubStr{\FixL@alnum}{\FixL@tempa}{\FixL@p}{}%
  }}
\AtBeginDocument{%
  \let\nref\ref
  \let\npageref\pageref
}
\newcommand{\FixL@ref@base}[4]{%
  \begingroup
    \newcommand{\FixL@tempb}{\csname n#1\endcsname #2{#4}\FixL@p}%
    \IfStrEq{#3}{hyper}{\hyperref[#4]{\FixL@tempb}}{\FixL@tempb}%
  \endgroup
  \nobreak % Extra \nobreak
}
\AtBeginDocument{%
  \@ifpackageloaded{hyperref}{%
    \newcommand{\FixL@ref}[1]{\FixL@ref@base{ref}{*}{hyper}{#1}}%
    \newcommand{\FixL@ref@star}[1]{\FixL@ref@base{ref}{*}{}{#1}}%
    \renewcommand{\ref}{\@ifstar\FixL@ref@star\FixL@ref}%
    \newcommand{\FixL@pageref}[1]{\FixL@ref@base{pageref}{*}{hyper}{#1}}%
    \newcommand{\FixL@pageref@star}[1]{\FixL@ref@base{pageref}{*}{}{#1}}%
    \renewcommand{\pageref}{\@ifstar\FixL@pageref@star\FixL@pageref}%
  }{%
    \renewcommand{\ref}[1]{\FixL@ref@base{ref}{}{}{#1}}%
    \renewcommand{\pageref}[1]{\FixL@ref@base{pageref}{}{}{#1}}%
  }%
  \robustify{\ref}%
  \robustify{\pageref}%
}
\gappto\captionslatvian{%
  \renewcommand{\alsoname}{sk.~arī}%
  \renewcommand{\chaptername}{nodaļa}%
  \renewcommand{\figurename}{att}%
  \renewcommand{\indexname}{Rādītājs}%
  \renewcommand{\partname}{daļa}%
  \renewcommand{\tablename}{tabula}%
  \renewcommand{\seename}{sk.\@}%
}
\renewcommand{\@alph}[1]{%
  \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 r\or s\or t\or u\or v\or z\else\@ctrerr\fi}
\renewcommand{\@Alph}[1]{%
  \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 R\or S\or T\or U\or V\or Z\else\@ctrerr\fi}
\@ifundefined{@makechapterhead}{}{%
  \patchcmd{\@makechapterhead}{\@chapapp\space \thechapter}{%
    \IfStrEq{\@chapapp}{\appendixname}{\@chapapp\space\thechapter}{%
      \thechapter\FixL@p\space\@chapapp}%
  }{}{\FixL@patchfailed{\chapter}}%
}
\newcommand{\FixL@fix@part}[1]{%
  \@ifundefined{#1}{}{%
    \renewcommand{\thepart}{\arabic{part}}%
    \expandafter\patchcmd\csname #1\endcsname{%
      \partname\nobreakspace\thepart}{\thepart\FixL@p\space\partname}{}{%
      \FixL@patchfailed{\part}}%
  }}
\AtBeginDocument{\FixL@fix@part{%
  \@ifpackageloaded{hyperref}{H@old@part}{@part}}}
\patchcmd{\ps@headings}{\@chapapp\ \thechapter}{%
  \thechapter\FixL@p\space\@chapapp}{}{\FixL@patchfailed{\chaptermark}}
\patchcmd{\ps@headings}{\thesection\quad}{%
  \thesection\FixL@p\FixL@bigspace}{}{\FixL@patchfailed{\sectionmark}}
\patchcmd{\ps@headings}{\thesubsection\quad}{%
  \thesubsection\FixL@p\FixL@bigspace}{}{%
  \FixL@patchfailed{\subsectionmark}}
\DeclareCaptionLabelSeparator{period@}{.\@\space}
\captionsetup{labelsep=period@}
\DeclareCaptionLabelFormat{latvian}{#2\FixL@p\space #1}
\captionsetup{labelformat=latvian}
\newif\ifFixL@amsthm@loaded
\@ifpackageloaded{amsthm}{\FixL@amsthm@loadedtrue}{}
\ifFixL@amsthm@loaded
  \swapnumbers
  \newcommand{\FixL@thmnumber}[1]{\@ifempty{#1}{}{#1\FixL@p}}
  \patchcmd{\swappedhead}{\thmnumber}{\FixL@thmnumber}{}{%
    \FixL@patchfailed{\swappedhead}}
\else
  \patchcmd{\@begintheorem}{#1\ #2}{#2\FixL@p\space #1}{}{%
    \FixL@patchfailed{\@begintheorem}}
  \patchcmd{\@opargbegintheorem}{#1\ #2}{#2\FixL@p\space #1}{}{%
    \FixL@patchfailed{\@opargbegintheorem}}
\fi
\MakePerPage{footnote}
\newcommand{\FixL@inpackage}[2]{%
  \AtBeginDocument{\@ifpackageloaded{#1}{#2}{}}}
\newcommand{\FixL@translate}[3]{%
  \FixL@inpackage{#1}{%
    \expandafter\renewcommand\csname #2\endcsname{#3}%
  }}
\FixL@inpackage{float}{\captionsetup[ruled]{labelformat=latvian}}
\FixL@inpackage{float}{\renewcommand{\floatname}[2]{%
  \expandafter\def\csname #1name\endcsname{#2}}}
\FixL@translate{algorithm}{listalgorithmname}{Algoritmu saraksts}
\FixL@inpackage{algorithm}{\floatname{algorithm}{algoritms}}
\FixL@translate{amsthm}{proofname}{Pierādījums}
\FixL@translate{appendix}{appendixtocname}{Pielikumi}
\newcommand{\FixL@doc@glossaryname}{Izmaiņu saraksts}
\FixL@inpackage{doc}{\GlossaryPrologue{%
  \section*{\FixL@doc@glossaryname}%
  \markboth{\FixL@doc@glossaryname}{\FixL@doc@glossaryname}%
}}
\FixL@inpackage{doc}{\IndexPrologue{%
  \section*{\indexname}%
  \markboth{\indexname}{\indexname}%
  Numuri kursīvā apzīmē lappusi, kurā aprakstīta attiecīgā komanda;
  pasvītrotie numuri norāda uz komandas \ifcodeline@index definīcijas
  pirmkoda rindu\else definīciju\fi; numuri parastajā rakstā apzīmē
  \ifcodeline@index pirmkoda rindu\else lappusi\fi, kurā komanda tiek
  izmantota.%
}}
\FixL@translate{doc}{generalname}{Vispārīgi}
\FixL@translate{listings}{lstlistlistingname}{Pirmkoda tekstu saraksts}
\FixL@translate{listings}{lstlistingname}{%
  \ifx\lst@@caption\@empty P\else p\fi irmkods}
\endinput
%%
%% End of file `fixlatvian.sty'.