-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgb4e-emulate.sty
158 lines (147 loc) · 4.65 KB
/
gb4e-emulate.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
% gb4e-emulate.sty --
% emulation of gb4e using enumitem for increased flexibility of formatting
% Copyright 2010 by Alan Munn <[email protected]>
% based on code in gb4e.sty by
% Craig Thiersch, Hans-Peter Kolb and Alexis Dimitriadis
%
%
% This package may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or 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 package has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this package is Alan Munn.
%
% This package consists of the file gb4e-emulate.sty
%
% Version 1.0 2010/07/31
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gb4e-emulate}[2010/07/31 gb4e-emulate Package version 1.0]
\RequirePackage{enumitem}
\RequirePackage{cgloss4e}
% Set up equivalent lists
\newlist{exe}{enumerate}{1}
\setlist[exe]{
resume=exe@series,
label={(\arabic*)},
widest=888,
align=left,
topsep=7\p@ plus 2\p@ minus 3\p@,
itemsep=3\p@ plus 2\p@,
ref=\arabic*,
leftmargin=*}
\newlist{xlist}{enumerate}{3}
\setlist[xlist]{
topsep=1.5\p@ plus \p@,
itemsep=1.5\p@ plus \p@,
labelsep=*,
parsep=\p@ plus .5\p@ minus .5\p@,
itemindent=0em,
align=left,
leftmargin=*}
\setlist[xlist,1]{
label={\alph*.},
ref={\arabic{exei}\alph*},
widest=a.}
\setlist[xlist,2]{
label={\roman*.},
ref={\thexlisti.\roman*},
widest=iv.}
\setlist[xlist,3]{
label={\arabic*.},
ref={\thexlistii.\arabic*},
widest=9.}
% emulate specific lists
\newenvironment{xlisti}{%
\begin{xlist}[label={\roman*.},
ref={\arabic{exei}\roman*},
widest=iv.]}{\end{xlist}}
\newenvironment{xlista}{%
\begin{xlist}[label={\alph*.},
ref={\arabic{exei}\alph*},
widest=a.]}{\end{xlist}}
\newenvironment{xlistn}{%
\begin{xlist}[label={\arabic*.},
ref={\arabic{exei}\arabic*},
widest=9.]}{\end{xlist}}
\newenvironment{xlistI}{%
\begin{xlist}[label={\Roman*.},
ref={\arabic{exei}\Roman*},
widest=IV.]}{\end{xlist}}
\newenvironment{xlistA}{%
\begin{xlist}[label={\Alph*.},
ref={\arabic{exei}\Alph*},
widest=M.]}{\end{xlist}}
%%% subeex macro without vertical spacing code from gb4e
\def\@subex#1#2{%
\settowidth{\labelwidth}{#1}%
\itemindent\z@\labelsep#2%
\parsep\p@ plus .5\p@ minus .5\p@%
\leftmargin\labelwidth%
\advance\leftmargin#2\relax
}
%%% the example-items from gb4e
\def\ex{\@ifnextchar [{\@ex}{\item}}
\def\@ex[#1]#2{\item\@exj[#1]{#2}}
\def\@exj[#1]#2{\@exjbg{#1} #2 \end{list}}
\def\exi#1{\item[#1]\@ifnextchar [{\@exj}{}}
\def\judgewidth#1{\def\@jwidth{#1}}
\judgewidth{?}
\def\@exjbg#1{\begin{list}{#1}{\@subex{\@jwidth}{0ex}}\item}
\def\exr#1{\exi{{(\ref{#1})}}}
\def\exp#1{\exi{{(\ref{#1}$'$)}}}
\def\sn{\exi{}}
%%%%%%%%%%% PRIMEBARS
\let\prmbrs=0
\def\primebars{\let\prmbrs=1}
\def\obar#1{\ifmmode#1^{0}\else#1$^{0}$\fi} %% FIX
\def\mbar#1{\ifmmode#1^{\mathrm{max}}\else#1$^{\mathrm{max}}$\fi}
\def\ibar#1{\ifx\prmbrs0%
\ifmmode\overline{\mathrm{#1}}\else$\overline{\mbox{#1}}$\fi%
\else\ifmmode#1^{'}\else#1$^{'}$\fi\fi}
\def\iibar#1{\ifx\prmbrs0%
\ifmmode\overline{\overline{\mathrm{#1}}}%
\else$\overline{\overline{\mbox{#1}}}$\fi%
\else #1P\fi}
%%%%%%%%%%% AUTOMATH
% this allows _ to be used in horizontal mode (from J.Frampton):
% Reimplemented to allow this feature to be turned on and off.
% The new version also combines sub- and superscripts properly.
% -Alexis
% \automath Make _ and ^ work outside math mode
% \noautomath Restore normal sub/superscript behavior
{ % Temporarily change catcodes
\catcode`\_=\active
\catcode`\^=\active
\global\def\automath{%
\catcode`\_=\active
\catcode`\^=\active
\def_##1{\gb@ifnextchar^{\automath@two_{##1}}{\ensuremath{\sb{##1}}}}%
\def^##1{\gb@ifnextchar_{\automath@two^{##1}}{\ensuremath{\sp{##1}}}}}
}
\def\automath@two#1#2#3#4{\ensuremath{#1{#2}\relax #3{#4}}}
% Restore default catcodes for ^, _
\def\noautomath{\catcode`\_=8 \catcode`\^=7 }
% The original \@ifnextchar discards spaces when looking for the next
% ``character''. This variant accepts any token.
\long\def\gb@ifnextchar#1#2#3{%
\let\reserved@d=#1%
\def\reserved@a{#2}%
\def\reserved@b{#3}%
\futurelet\@let@token\@gbifnch}
\def\@gbifnch{%
\ifx\@let@token\reserved@d
\let\reserved@c\reserved@a
\else
\let\reserved@c\reserved@b
\fi
\reserved@c}
\automath % On by default, for backward compatibility
%%%%%%%%%
\endinput