-
Notifications
You must be signed in to change notification settings - Fork 1
/
slgloss.sty
217 lines (204 loc) · 5.51 KB
/
slgloss.sty
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
%%
%% file: slgloss.sty
%% authors: Itamar Kastner (NYU) and Jonathan Keane (UChicago), January 2013
%% update (October 2019): Fabian Bross (Uni Stuttgart) and Itamar Kastner (HU Berlin)
%% update (June 2020): Itamar Kastner (U Edinburgh), based on a suggestion by Kate Davidson (Harvard)
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{slgloss}
\RequirePackage{substr}
%% no lowercase option for scripts if they fail with lowercase
\newcommand{\lwr}[1]{\lowercase{#1}}
\DeclareOption{nolowercase}{
\renewcommand{\lwr}[1]{#1}
}
\ExecuteOptions{}
\ProcessOptions\relax
%
%% Helper methods for \slgdash
\newcommand{\dashover}[2][\mathop]{#1{\mathpalette\df@over{{\dashfill}{#2}}}}
%\newcommand{\fillover}[2][\mathop]{#1{\mathpalette\df@over{{\solidfill}{#2}}}}
\newcommand{\df@over}[2]{\df@@over#1#2}
\newcommand\df@@over[3]{%
\vbox{
\offinterlineskip
\ialign{##\cr
#2{#1}\cr
\noalign{\kern1.2pt}
$\m@th#1#3$\cr
}
}%
}
\newcommand{\dashfill}[1]{%
\kern-.5pt
\xleaders\hbox{\kern.5pt\vrule height.4pt width \dash@width{#1}\kern.5pt}\hfill
\kern-.5pt
}
\newcommand{\dash@width}[1]{%
\ifx#1\displaystyle
2pt
\else
\ifx#1\textstyle
1.5pt
\else
\ifx#1\scriptstyle
1.25pt
\else
\ifx#1\scriptscriptstyle
1pt
\fi
\fi
\fi
\fi
}
\newcommand{\solidfill}[1]{\leaders\hrule\hfill}
%% \fs{} takes a word and outputs it as a fingerspelled word
%
\DeclareRobustCommand*\fs[2][]{%
\let\@tempa\relax%
\def\@tempb{-}%
\@tfor\@tempc:=#2\do{%
\textsc{\@tempa \@tempc}\let\@tempa\@tempb%
}%
}
%% \slg[nmm]{text} typesets input in small caps, with the optional nonmanual
%% marker denoted above the text. Scope is marked by an overline.
%% \slgl[nmm]{text} typesets input in small caps, with the optional nonmanual
%% marker denoted above the text, but left-aligned. Scope is marked by an overline
%% \slgdash[nmm]{text} typesets input in small caps, with the optional nonmanual
%% marker denoted above the text. Scope is marked by a dashed overline.
% setup a group where _ and ^ are activated, and then defined as ensuring mathmode, and then sub or super scripting
\begingroup
\catcode`_=\active%
\gdef_#1{\ensuremath{{}\sb{#1}}}%
\catcode`^=\active%
\gdef^#1{\ensuremath{{}\sp{#1}}}%
\endgroup
\makeatletter%
\DeclareRobustCommand*\slg[2][\null]{%
% these two functions are necessary to parse a string in text mode and use the new definitions of _ and ^ the ensures math mode, and sets as sub or super script.
\def\subsup{%
\begingroup%
\catcode`_=\active%
\catcode`^=\active%
\Xsubsup%
}%
\def\Xsubsup##1{%
\scantokens{##1\noexpand}%
\endgroup%
}%
\ifx#1\null%
\subsup{\textsc{\lwr{#2}}}%
\else%
$\stackrel{\hfill \subsup{{\textrm{#1}}}}{\overline{\subsup{\textsc{\lwr{#2}}}}}$%
\fi%
}%
\DeclareRobustCommand*\slgbig[3][\null]{%
% these two functions are necessary to parse a string in text mode and use the new definitions of _ and ^ the ensures math mode, and sets as sub or super script.
\def\subsup{%
\begingroup%
\catcode`_=\active%
\catcode`^=\active%
\Xsubsup%
}%
\def\Xsubsup##1{%
\scantokens{##1\noexpand}%
\endgroup%
}%
\ifx#1\null%
\subsup{\textsc{\lwr{#2}}}%
\else%
$\stackrel{\stackrel{\subsup{\textrm{#1}}}{\subsup{\textrm{#2}}}}
{\overline{\subsup{\textsc{\lwr{#3}}}}}$%
\fi%
}%
\DeclareRobustCommand*\slgl[2][\null]{%
% these two functions are necessary to parse a string in text mode and use the new definitions of _ and ^ the ensures math mode, and sets as sub or super script.
\def\subsup{%
\begingroup%
\catcode`_=\active%
\catcode`^=\active%
\Xsubsup%
}%
\def\Xsubsup##1{%
\scantokens{##1\noexpand}%
\endgroup%
}%
\ifx#1\null%
\subsup{\textsc{\lwr{#2}}}%
\else%
$\stackrel{\subsup{{\textrm{#1}}}\hfill}{\overline{\subsup{\textsc{\lwr{#2}}}}}$%
\fi%
}%
\DeclareRobustCommand*\slgdash[2][\null]{%
% these two functions are necessary to parse a string in text mode and use the new definitions of _ and ^ the ensures math mode, and sets as sub or super script.
\def\subsup{%
\begingroup%
\catcode`_=\active%
\catcode`^=\active%
\Xsubsup%
}%
\def\Xsubsup##1{%
\scantokens{##1\noexpand}%
\endgroup%
}%
\ifx#1\null%
\subsup{\textsc{\lwr{#2}}}%
\else%
$\stackrel{\hfill \subsup{\raisebox{0.03em}{\textrm{#1}}}}{\dashover{\subsup{\textsc{\lwr{#2}}}}}$%
\fi%
}%
\makeatother%
%
%% \fslist{} takes a string of letters and outputs each as a fingerspelled
%% individual letter, if that string contains commas the output is separated at the commas, allowing for arbitrary length units.
%
\newcounter{@tempe}
\makeatletter%
\DeclareRobustCommand*\fslist[2][and]{%
\let\last@item\relax%
\let\last@sep\relax%
\def\@nlast{, }%
\setcounter{@tempe}{0}%
\IfSubStringInString{,}{#2}{
%%% if there are commas in the string, separate by commas
\@for\@ii:=#2\do{%
\ifx\last@item\relax\else%
\ifx\last@sep\relax%
\else\@nlast\fi%
\ifnum\value{@tempe}>0\relax%
\def\last@sep{, #1 }%
\else%
\def\last@sep{ #1 }%
\fi%
\textsc{\mbox{{-\last@item-}}}%
\addtocounter{@tempe}{1}%
\fi
\let\last@item\@ii
}%
\ifx\last@item\relax\else
\last@sep \textsc{\mbox{{-\last@item-}}}%
\fi
}{%%%% if there are no commas, separate by character.
\@tfor\@ii:=#2\do{%
\ifx\last@item\relax\else%
\ifx\last@sep\relax%
\else\@nlast\fi%
\ifnum\value{@tempe}>0\relax%
\def\last@sep{, #1 }%
\else%
\def\last@sep{ #1 }%
\fi%
\textsc{\mbox{{-\last@item-}}}%
\addtocounter{@tempe}{1}%
\fi
\let\last@item\@ii
}%
\ifx\last@item\relax\else
\last@sep \textsc{\mbox{{-\last@item-}}}%
\fi
}%%%
}
\makeatother%
%%
%% End of slgloss.sty