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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
%%
%% This is file `refstyle.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% refstyle.dtx (with options: `pkg')
%%
%% -------------------------------------------------------------------
%% Refstyle package to format references
%% -------------------------------------------------------------------
%%
%% Author: Danie Els
%%
%% Copyright (C) 2002--2006 Danie Els
%% All rights reserved.
%%
%% 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
%% 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% This Current Maintainer of this work is Danie Els (dnjels@sun.ac.za)
%% -------------------------------------------------------------------
%%
\newcommand*{\RefstyleFileDate}{2006/09/09}
\newcommand*{\RefstyleFileVersion}{v0.3}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{refstyle}[\RefstyleFileDate\space
\RefstyleFileVersion\space
Reference formatting (DNJ Els)]
\newcommand*{\RS@pkgname}{refstyle}
\RequirePackage{keyval}
\def\RS@setkeys#1#2{%
\def\KV@prefix{KV@#1@}%
\let\@tempc\relax
\KV@do#2,\relax,}
\@ifundefined{vref@space}{\let\vref@space\space}{}
\newcommand*{\RS@namelet}[1]{\expandafter\let\csname #1\endcsname}
\newcommand*{\RS@nameuse}[1]{\csname #1\endcsname}
\newcommand*{\RS@namedef}[1]{\expandafter\def\csname #1\endcsname}
\newcommand*{\RS@robustnamedef}[1]{%
\expandafter\edef\csname #1\endcsname{%
\noexpand\protect\RS@nameuse{#1 }}%
\RS@namedef{#1 }}
\def\RS@ifundefined#1{%
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname#1\endcsname\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\newcommand*{\RS@removedef}[1]{%
\RS@namelet{#1}\@undefined%
\RS@ifundefined{#1 }{}{\RS@namelet{#1 }\@undefined}}
\newcommand*{\RS@testednamedef}[1]{%
\RS@ifnamedefinable{#1}\RS@namedef{#1}}
\newcommand*{\RS@testedrobustnamedef}[1]{%
\RS@ifnamedefinable{#1}\RS@robustnamedef{#1}}
\long\def\RS@ifnamedefinable #1{%
\edef\reserved@a{#1}%
\RS@ifundefined\reserved@a
{\edef\reserved@b{\expandafter\@carcube \reserved@a xxx\@nil}%
\ifx \reserved@b\@qend \RS@notdefinable\else
\ifx \reserved@a\@qrelax \RS@notdefinable\else
\PackageInfo{\RS@pkgname}{\@backslashchar\reserved@a\space created}%
\fi
\fi}%
\RS@notdefinable}
\gdef\RS@notdefinable{%
\PackageError{\RS@pkgname}{%
Command \@backslashchar\reserved@a\space
already defined.\MessageBreak
Or name \@backslashchar\@qend... illegal.\MessageBreak
It can not be redefined by the \@backslashchar newref%
}{%
If \@backslashchar\reserved@a\space is not important\MessageBreak
then \protect\let\@backslashchar\reserved@a%
=\protect\relax,\MessageBreak
else use a different \@backslashchar newref.}%
}
\newcommand*{\RS@setbool}[2]{%
\lowercase{\def\@tempa{#2}}%
\@ifundefined{@tempswa\@tempa}%
{\PackageError{\RS@pkgname}%
{You can only set the option to `true' or `false'}\@ehc}%
{\csname#1\@tempa\endcsname}}
\def\RS@firstcap#1#2\@nil{%
\iffalse{\fi
\uppercase{\edef\RS@cap{\iffalse}\fi#1}#2}}%
\newif\ifRSstar\RSstarfalse
\newif\ifRSnameon\RSnameontrue
\newif\ifRScapname\RScapnamefalse
\newif\ifRSplural\RSpluralfalse
\newcommand*{\newref}[1]{%
\lowercase{\def\RS@tempa{#1}}%
\expandafter\RS@newref\expandafter{\RS@tempa}}
\newcommand*{\RS@newref}[2]{%
\RS@clearref{#1}%
\define@key{RS@#1}{key}[#1:]{\RS@namedef{RS@#1@key}{##1}}%
\define@key{RS@#1}{s}[true]{\RS@setbool{RSplural}{##1}}%
\define@key{RS@#1}{name}[]{\RS@namedef{RS@#1@name}{##1}}%
\define@key{RS@#1}{names}[]{\RS@namedef{RS@#1@names}{##1}}%
\define@key{RS@#1}{Name}[]{\RS@namedef{RS@#1@Name}{##1}}%
\define@key{RS@#1}{Names}[]{\RS@namedef{RS@#1@Names}{##1}}%
\define@key{RS@#1}{rngtxt}[\space to~]{\RS@namedef{RS@#1@rngtxt}{##1}}%
\define@key{RS@#1}{lsttxt}[\space and~]{\RS@namedef{RS@#1@lsttxt}{##1}}%
\define@key{RS@#1}{refcmd}[\ref{####1}]{\RS@namedef{RS@#1@rcmd}####1{##1}}%
\define@key{RS@#1}{xr}[]{\RS@namedef{RS@#1@xr}{##1}}%
\define@key{RS@#1}{vref}[true]{\RS@namedef{RS@#1vref}{##1}}%
\RS@setkeys{RS@#1}{key,
s=false,
name,names,Name,Names,
rngtxt,lsttxt,
refcmd,
xr,
vref=false}%
\RS@setkeys{RS@#1}{#2}%
\RS@buildref{#1}%
}
\newcommand*{\RS@clearref}[1]{%
\RS@ifundefined{RS@#1@template}
{\RS@namedef{RS@#1@template}{#1}%
\PackageInfo{\RS@pkgname}%
{New reference template \protect\newref{#1}}{}}
{\PackageInfo{\RS@pkgname}%
{Reference template \protect\newref{#1} redefined}{}
\RS@firstcap#1\@nil
\RS@removedef{#1key}%
\RS@removedef{#1label}%
\RS@removedef{#1ref}%
\RS@removedef{\RS@cap ref}%
\RS@removedef{#1rangeref}%
\RS@removedef{\RS@cap rangeref}%
\RS@removedef{#1pageref}%
}%
}
\newcommand*{\RS@buildref}[1]{%
\RS@firstcap#1\@nil
\RS@testednamedef{#1key}{\RS@nameuse{RS@#1@key}}
\RS@testednamedef{#1label}##1{\label{\RS@nameuse{RS@#1@key}##1}}
\RS@testedrobustnamedef{#1ref}{\RScapnamefalse\RS@cmd{ref}{#1}}
\RS@testedrobustnamedef{\RS@cap ref}{\RScapnametrue\RS@cmd{ref}{#1}}
\RS@testedrobustnamedef{#1rangeref}{\RScapnamefalse\RS@cmd{rangeref}{#1}}
\RS@testedrobustnamedef{\RS@cap rangeref}{\RScapnametrue\RS@cmd{rangeref}{#1}}
\RS@testedrobustnamedef{#1pageref}{\RScapnamefalse\RS@cmd{pageref}{#1}}
}
\newcommand*{\RS@cmd}[2]{%
\@ifstar{\RSstartrue\RSnameonfalse\RS@@cmd{#1}{#2}}%
{\RSstarfalse\RSnameontrue\RS@@cmd{#1}{#2}}}
\newcommand*{\RS@@cmd}[2]{%
\@ifnextchar[%
{\RS@nameuse{RS@#1}{#2}}%
{\RS@nameuse{RS@#1}{#2}[]}}
\def\RS@ref#1[#2]#3{%
\begingroup
\RS@setkeys{RS@#1}{#2}%
\edef\RS@tmpa{\zap@space#3 \@empty}%
\edef\RS@tmpa{\noexpand\RS@@ref{#1} \RS@tmpa,\relax\noexpand\@eolst}%
\RS@tmpa%
\endgroup}
\def\RS@@ref#1 #2,#3\@eolst{%
\ifx\relax#3\relax
\RS@makename{#1}%
\RS@makeref{#1}{#2}%
\RS@makevpageref{#1}{#2}%
\else
\RSpluraltrue%
\RS@makename{#1}%
\RS@makeref{#1}{#2}%
\RS@makevpageref{#1}{#2}%
\RSnameonfalse%
\RS@@@ref{#1} #3\@eolst%
\fi}
\def\RS@@@ref#1 #2,#3\@eolst{%
\ifx\relax#3\relax
\RS@nameuse{RS@#1@lsttxt}%
\RS@makeref{#1}{#2}%
\RS@makevpageref{#1}{#2}%
\else
\unskip,\space%
\RS@makeref{#1}{#2}%
\RS@makevpageref{#1}{#2}%
\RS@@@ref{#1} #3\@eolst%
\fi}
\def\RS@rangeref#1[#2]#3#4{%
\begingroup
\RS@setkeys{RS@#1}{#2}%
\RSpluraltrue%
\RS@makename{#1}%
\RS@makeref{#1}{#3}%
\RS@nameuse{RS@#1@rngtxt}%
\RSnameonfalse%
\RS@makeref{#1}{#4}%
\RS@makevpagerefrange{#1}{#3}{#4}%
\endgroup}
\def\RS@pageref#1[#2]#3{%
\begingroup%
\RS@setkeys{RS@#1}{#2}%
\RS@ifvref{#1}%
{\mbox{}\vpageref*{\RS@lbl{#1}{#3}}}%
{\reftextfaraway{\RS@lbl{#1}{#3}}}%
{\pageref{\RS@lbl{#1}{#3}}}%
\endgroup}
\newcommand*{\RS@true}{true}
\newcommand*{\RS@false}{false}
\newcommand*{\RS@far}{far}
\newcommand{\RS@ifvref}[4]{%
\edef\RS@tempa{\RS@nameuse{RS@#1vref}}%
\ifx\RS@tempa\RS@true\relax
#2%
\else\ifx\RS@tempa\RS@far\relax
#3%
\else\ifx\RS@tempa\RS@false\relax
#4%
\else
\PackageError{\RS@pkgname}%
{You can only set the vref option to `true', `far' or `false'}\@ehc
\fi\fi\fi}
\newcommand{\RS@makename}[1]{%
\ifRSstar\else\ifRSnameon
\ifRSplural
\ifRScapname
\RS@nameuse{RS@#1@Names}%
\else
\RS@nameuse{RS@#1@names}%
\fi
\else
\ifRScapname
\RS@nameuse{RS@#1@Name}%
\else
\RS@nameuse{RS@#1@name}%
\fi
\fi
\fi\fi
}
\newcommand*{\RS@lbl}[2]{%
\RS@nameuse{RS@#1@xr}\RS@nameuse{RS@#1@key}#2%
}
\newcommand{\RS@makeref}[2]{%
\RS@nameuse{RS@#1@rcmd}{\RS@lbl{#1}{#2}}%
}
\newcommand{\RS@makevpageref}[2]{%
\RS@ifvref{#1}%
{\vpageref[\unskip]{\RS@lbl{#1}{#2}}}%
{ \reftextfaraway{\RS@lbl{#1}{#2}}}%
{}%
}
\newcommand{\RS@makevpagerefrange}[3]{%
\RS@ifvref{#1}%
{\space\vpagerefrange[\unskip]{\RS@lbl{#1}{#2}}{\RS@lbl{#1}{#3}}}%
{\space\vpagerefrange[\unskip]{\RS@lbl{#1}{#2}}{\RS@lbl{#1}{#3}}}%
{}%
}
\AtBeginDocument{%
\providecommand{\vpageref}{%
\PackageError{\RS@pkgname}%
{The vref option used, but varioref.sty not loaded.}%
{Load varioref.sty}}
\providecommand{\reftextfaraway}{%
\PackageError{\RS@pkgname}%
{The vref=far option used, but varioref.sty not loaded.}%
{Load varioref.sty}}
\providecommand{\vpagerefrange}{%
\PackageError{\RS@pkgname}%
{The vref option used, but varioref.sty not loaded.}%
{Load varioref.sty}}
}
\def\RSaddto#1#2{%
#2%
\@temptokena{#2}%
\ifx#1\relax
\let#1\@empty
\fi
\ifx#1\undefined
\edef#1{\the\@temptokena}%
\else
\toks@\expandafter{#1}%
\edef#1{\the\toks@\the\@temptokena}%
\fi
\@temptokena{}\toks@\@temptokena}
\def\DeclareLangOpt#1#2{%
\edef\RS@tempa{\expandafter\@gobble\string#2}%
\RS@ifundefined{\RS@tempa}%
{\PackageError{\RS@pkgname}%
{Unknown definitions \@backslashchar\RS@tempa\MessageBreak
for language option `#1'}{}}%
{\DeclareOption{#1}{\expandafter\RSaddto\csname extras#1\endcsname #2}}%
}
\newcommand*{\RS@cfgfile}{refstyle.cfg}
\@ifpackagewith{\@currname}{noconfig}
{\PackageInfo{\RS@pkgname}{No config file loaded}}%
{\InputIfFileExists{\RS@cfgfile}%
{\PackageInfo{\RS@pkgname}{Config file \RS@cfgfile\space used}}%
{\PackageInfo{\RS@pkgname}{Config file \RS@cfgfile\space not found}}%
}
\DeclareOption{noconfig}{\OptionNotUsed}
\ProcessOptions*\relax
\endinput
%%
%% End of file `refstyle.sty'.
|