-
Notifications
You must be signed in to change notification settings - Fork 0
/
gslist.sty
112 lines (108 loc) · 3.16 KB
/
gslist.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
\ProvidesPackage{gslist}[2000/05/24]
% \newlist <name of list>%
% <commands inserted before each item>%
% <commands inserted between items>%
% <characters separating items>%
% <characters terminating the list>%
% <escape character to suppress insertion
% of commands before item>
%
% Example: \newlist\lista{<before>}{<between>}{}{}{}
% \newlist\listb{<before>}{<between>}{;}{}{}
% \newlist\listc{<before>}{<between>}{}{.}{}
% \newlist\listd{<before>}{<between>}{;}{.}{}
% Each of
% \lista{abc}
% \listb{a;b;c}
% \listc abc.
% \listd a;b;c.
% results in
% <before>{a}<between><before>{b}<between><before>{c}
%
% Example: \newlist\lista{<before>}{<between>}{}{}{^}
% \newlist\listb{<before>}{<between>}{;}{}{^}
% \newlist\listc{<before>}{<between>}{}{.}{^}
% \newlist\listd{<before>}{<between>}{;}{.}{^}
% Each of
% \lista{a^bc}
% \listb{a;^b;c}
% \listc a^bc.
% \listd a;^b;c.
% results in
% <before>{a}<between>b<between><before>{c}
%
\newcommand\renewlist[6]{%
\@ifundefined#1
{\@latex@error{\noexpand#1undefined}\@ehc}%
\relax
\providelist{#1}{#2}{#3}{#4}{#5}{#6}}
\newcommand\newlist[6]{\@ifdefinable#1{\providelist{#1}{#2}{#3}{#4}{#5}{#6}}}
\newcommand\providelist[6]%
{\def#1##1#5%
{\def\g@tmpa{##1}%
\ifx\g@tmpa\empty
\let\g@tmpa\ignorespaces
\else
\def\g@sep{\def\g@sep{#3}}%
\def\g@tmpa{\@nameuse{\string#1}##1#4\g@nd}%
\fi
\g@tmpa
}%
\def\g@tmpa{#6}%
\ifx\g@tmpa\empty
\@namedef{\string#1}{\@nameuse{\string#1b}}%
\else
\@namedef{\string#1}%
{\@ifnextchar#6{\@nameuse{\string#1a}}{\@nameuse{\string#1b}}}%
\@namedef{\string#1a}#6##1#4{\g@sep##1\@nameuse{\string#1c}}%
\fi
\@namedef{\string#1b}##1#4{\g@sep#2{##1}\@nameuse{\string#1c}}%
\@namedef{\string#1c}##1\g@nd
{\def\g@tmpa{##1}%
\ifx\g@tmpa\empty
\let\g@tmpa\ignorespaces
\else
\def\g@tmpa{\@nameuse{\string#1}##1\g@nd}%
\fi
\g@tmpa
}%
}
% \add@nd\cmd{arg}
% expands to
% \cmd arg\@nd
\newcommand\add@nd[2]{#1#2\@nd}
% DEK's list macros (The TeXbook, p. 378)
%
% Test for empty list: \ifx\list\empty ... \else ... \fi
%
\newtoks\g@ta
\newtoks\g@tb
\newif\ifmember
\long\def\leftappenditem#1\to#2%
{\g@ta={\\{#1}}%
\g@tb=\expandafter{#2}%
\edef#2{\the\g@ta\the\g@tb}%
}
\long\def\rightappenditem#1\to#2%
{\g@ta={\\{#1}}%
\g@tb=\expandafter{#2}%
\edef#2{\the\g@tb\the\g@ta}%
}
\def\concatenate#1=#2%
{\g@ta=\expandafter{#2}%
\g@tb=\expandafter{#3}%
\edef#1{\the\g@ta\the\g@tb}%
}
\def\lop#1\to#2%
{\expandafter\lopoff#1\lopoff#1#2%
}
\long\def\lopoff\\#1#2\lopoff#3#4%
{\def#4{#1}%
\def#3{#2}%
}
\def\ismember#1\of#2%
{\memberfalse
\def\given{#1}%
\def\\##1{\def\next{##1}\ifx\next\given\membertrue\fi}%
#2%
}