summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/leipzig/leipzig.sty
blob: 4dd8d510df869650a0437326f70fadf0624e97b5 (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
%%
%% This is file `leipzig.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% leipzig.dtx  (with options: `package')
%% This is a generated file.
%% 
%% ----------------------------------------------------------------
%% leipzig --- A package to typeset and index linguistic gloss abbreviations.
%% E-mail: natalie.a.weber@gmail.com
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
%% 
%% Copyright (C) 2013 by Natalie Weber
%% 
%% 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'.
%% 
%% The Current Maintainer of this work is Natalie Weber.
%% 
%% This work consists of the files leipzig.dtx,
%%                                 leipzig.ins
%%                                 leipzig.tex
%% 
%% and the derived files leipzig.sty and leipzig.pdf.
%% 
\NeedsTeXFormat{LaTeX2e}[1996/10/24]%
\ProvidesPackage{leipzig}%
    [2013/05/26 v1.0 Leipzig package for linguistic abbreviations]%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  This is a simple list of newcommands which create shortcuts for   %%
%%  standard linguistic glosses (see the Leipzig Glossing rules,      %%
%%  http://www.eva.mpg.de/lingua/resources/glossing-rules.php         %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\long\def\tlist@if@empty@nTF #1{%
  \expandafter\ifx\expandafter\\\detokenize{#1}\\%
  \expandafter\@firstoftwo%
  \else%
  \expandafter\@secondoftwo%
  \fi%
}%
\newif\ifleipzig@glossaries\leipzig@glossariesfalse
\newif\ifleipzig@noglossaries\leipzig@noglossariesfalse
\newif\ifleipzig@donotindex\leipzig@donotindexfalse
\DeclareOption{glossaries}{\leipzig@glossariestrue}
\DeclareOption{noglossaries}{\leipzig@noglossariestrue}
\DeclareOption{nostandards}{\leipzig@donotindextrue}
\DeclareOption*{%
  \PassOptionsToPackage{\CurrentOption}{glossaries}%
}%
\ProcessOptions\relax
\@ifpackageloaded{glossaries}{% true text
  \ifleipzig@noglossaries\leipzig@glossariesfalse\relax
  \else\leipzig@glossariestrue\relax\fi
}{% false text
  \ifleipzig@glossaries\PackageWarning{leipzig}{%
    glossaries package not loaded. Load glossaries
    package at some point.}%
  \else\leipzig@glossariesfalse\relax\fi
}%
\@ifpackageloaded{glossary-inline}{% renew inline
\renewglossarystyle{inline}{%
  \renewenvironment{theglossary}%
    {%
      \def\gls@inlinesep{}%
      \def\gls@inlinesubsep{}%
      \def\gls@inlineshortlongsep{%
          \glsinlineshortlongseparator}% added this
    }%
    {\glspostinline}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glossaryentryfield}[5]{%
    \gls@inlinesep
    \glsentryitem{##1}\glstarget{##1}{##2}%
    \def\glo@desc{##3}%
    \def\@no@post@desc{\nopostdesc}%
    \ifx\glo@desc\@no@post@desc
    \else
      \ifstrempty{##3}{}{\gls@inlineshortlongsep##3}%
    \fi
    \ifglshaschildren{##1}%
    {%
       \glsresetsubentrycounter
       \glsinlineparentchildseparator
       \def\gls@inlinesubsep{}%
    }%
    {}%
    \def\gls@inlinesep{\glsinlineseparator}%
  }%
  \renewcommand*{\glossarysubentryfield}[6]{%
    \gls@inlinesubsep%
    \glstarget{##2}{}%
    \glssubentryitem{##2}##4%
    \def\gls@inlinesubsep{\glsinlinesubseparator}%
  }%
  \renewcommand*{\glsgroupskip}{}%
}
\newcommand*{\glsinlineshortlongseparator}{\,=\,\linebreak[1]}% added this
\renewcommand*{\glsinlineseparator}{,\space}% changed from ;\space
\renewcommand*{\glsinlinesubseparator}{,\space}
\renewcommand*{\glsinlineparentchildseparator}{:\space}
\renewcommand*{\glspostinline}{.\space}% changed from .
\renewcommand{\glsnamefont}[1]{\textsc{#1}}% abbrv in glossary are \sc
\renewcommand*{\glossarysection}[2][]{}% no section name
}{\relax}% if glossary-inline not loaded
\newcommand{\leipzigfont}[1]{\textsc{#1}}%
\newcommand{\firstleipzigfont}[1]{\leipzigfont{#1}}%
\ifleipzig@glossaries %if glossaries package loaded
  \renewcommand*{\acrpluralsuffix}{\textup{\glspluralsuffix}}%
  \newcommand{\leipzigname}{Abbreviations}
  \newglossary{leipzig}{lzs}{lzo}{\leipzigname}
  \newcommand{\leipzigtype}{leipzig}
%% The following commands are based on the Custom Acronym commands in the glossaries package.
\newcommand*{\SetLeipzigDisplayStyle}[1]{%
  \defglsdisplay[#1]{\leipzigfont{##1}##4}%
  \defglsdisplayfirst[#1]{\firstleipzigfont{##1}##4}%
}
\newcommand*{\CustomLeipzigFields}{%
  name={\the\glsshorttok},%
  description={\the\glslongtok},%
  symbol={\the\glsshorttok},%
  first={\firstleipzigfont{\the\glsshorttok}},%
  firstplural={\firstleipzigfont{\the\glsshorttok}\noexpand\acrpluralsuffix},%
  text={\leipzigfont{\the\glsshorttok}},%
  plural={\leipzigfont{\the\glsshorttok}\noexpand\acrpluralsuffix}%
}
\newcommand*{\LeipzigAcronymDef}{%
  \protected@edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\leipzigtype,%
      short={\leipzigfont{\the\glsshorttok}},% used in e.g. \acrshort
      shortplural={\leipzigfont{\the\glsshorttok}\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      user1={\the\glsshorttok},%
      user2={\the\glsshorttok\noexpand\acrpluralsuffix},%
      user3={\the\glslongtok},%
      user4={\the\glslongtok\noexpand\acrpluralsuffix},%
      \CustomLeipzigFields,%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
\newcommand*{\SetLeipzigStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\leipzigtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetLeipzigDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \LeipzigAcronymDef
  }%
%%  \@for\@gls@type:=\@glsacronymlists\do{% sets style for all acronymlists?
%%%%    \SetCustomDisplayStyle{\@gls@type}%
%%    \SetLeipzigDisplayStyle{\@gls@type}%
%%  }%
}%
\SetLeipzigStyle
%%Normally would have |\leipzigfont{#2}|, but I coded the leipzigfont directly into the short form. How else to do it?
\renewcommand{\acrfullformat}[2]{#1\space(#2)}
\newcommand{\newleipzig}[4][]{%
  \bgroup
    \tlist@if@empty@nTF{#1}%
      {\newacronym[type=\leipzigtype]{#2}{#3}{#4}}%
      {\newacronym[type=\leipzigtype,#1]{#2}{#3}{#4}}%
 %   \newacronym[type=\leipzigtype][#1]{n#2}{n#3}{Non-#4}
    \@newleipzig(#3)#2\@nil}%
  \def\@newleipzig(#1)#2#3\@nil{%
      \ifleipzig@donotindex
        \uppercase{\expandafter\gdef\csname #2}#3\endcsname{\leipzigfont{#1}}
      \else
        \uppercase{\expandafter\gdef\csname #2}#3\endcsname{\gls{#2#3}}
      \fi
      \egroup
    }% end if glossaries loaded
\else % if glossaries not loaded
  \newcommand{\newleipzig}[4][]{\@newleipzig(#3)#2\@nil}%
  \def\@newleipzig(#1)#2#3\@nil{%
    \uppercase{\expandafter\gdef\csname #2}#3\endcsname{\leipzigfont{#1}}
  }%
\fi
\input{leipzig.tex}
\ifleipzig@donotindex\leipzig@donotindexfalse\fi