summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cite/drftcite.sty
blob: 21b557efbd5fd23cdca5e69910958033ed81f064 (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
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
%     D R F T C I T E . S T Y
%
%     version 3.5  (Jan 1995)
%
%     Print the tags instead of the numbers for \cite.
%     See also CITE.STY and OVERCITE.STY.
%
%     Copyright (C) 1989,1991-1995 by Donald Arseneau
%     These macros may be freely transmitted, reproduced, or modified
%     provided that this notice is left intact.
%
%     Instructions are below, after \endinput.
% ........................
%
%   Handle formatting hooks:
%   \citeform,\citeleft,\citeright,\citemid,\citepunct
%
%   Set defaults:

%   [ on the left.
\@ifundefined{citeleft}{\let\citeleft=[}{}

%   ] on the right:
\@ifundefined{citeright}{\let\citeright=]}{}

%   , (comma space) before note
\@ifundefined{citemid}{\def\citemid{,\penalty\@lowpenalty\ }}{}

%   , (comma space) between entries
\@ifundefined{citepunct}{
% Default: To put space after the comma.  [nospace] eliminates the space
   \def\citepunct{,\penalty\@lowpenalty\ }%
  }{}

%   Each citation tag left as-is:
\@ifundefined{citeform}{\def\citeform{}}{}

%   Do not repeat warnings.  [verbose] reverses
\let\oc@verbo\relax

%  \citen gives the citation tag in the text and writes the aux file entry.
%  Use \citen to give citation name without the other formatting; e.g.,
%  "See also ref.~\citen{junk}" gives "See also ref. junk".
%
\edef\citen{\noexpand\protect \expandafter\noexpand\csname citen \endcsname}

\@namedef{citen }#1{%
\edef\@tempa{\@ignspaftercomma,#1, \@end, }% ignore spaces in parameter list.
\edef\@tempa{\expandafter\@ignendcommas\@tempa\@end}%
\if@filesw \immediate\write \@auxout {\string\citation {\@tempa}}\fi
\def\@citea{}%
\@for \@citeb:=\@tempa\do {\@citea
  \@ifundefined {b@\@citeb\@extra@b@citeb}%
    {{\bf \@citeverb{\@citeb}?}%% issue warning only for first mis-use:
     \@dftc@ifund {DCN@\@citeb\@extra@b@citeb}{% delete to warn always
     \@warning {Citation `\@citeb' on page \thepage\space undefined}%
     }{}% delete to warn always
    }% else, defined
    {\@dftc@hbox{\@citeverb{\@citeb}}}%
  \let\@citea\citepunct\@advancecitecount
  }}

% for ignoring spaces in the input:
\def\@ignspaftercomma#1, {\ifx\@end#1\@empty\else
   #1,\expandafter\@ignspaftercomma\fi}
\def\@ignendcommas,#1,\@end{#1}

% Make \cite robust.
%
\edef\cite{\noexpand\protect\expandafter\noexpand\csname cite \endcsname}

\@namedef{cite }{\@ifnextchar [{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}

%  Make \@citex refer to \citen:
%  (Put a single space before the output)
%
\def\@citex[#1]#2{\@cite{\citen{#2}}{#1}}%

%  Replacement for \@cite which defines the formatting normally done
%  around the citation list.  Adjust the spacing before the citation:
%  if no space or if there is extra space due to some punctuation, then
%  change to one inter-word space.  The way to change this is by changing
%  \citeleft, \citemid, and \citeright; but in extreme cases it might be
%  necessary to redefine the whole macro.
%
\def\@cite#1#2{\leavevmode
  \@tempskipa\lastskip \edef\@tempa{\the\@tempskipa}\unskip
  \ifx\@tempa\@zero@skip \spacefactor1001 \fi % if no space before, set flag
  \ifnum\spacefactor>\@m \ \else \hskip\@tempskipa \fi
  \citeleft{#1\if@tempswa \citemid #2\fi}\citeright
  \spacefactor\@m % punctuation in note doesn't affect outside
}
\edef\@zero@skip{\the\z@skip}
%
%  Give the citation tag as the label (even if another label is specified)
%
\def\@lbibitem[#1]#2{\global\@HighCite\z@
  \item[\@biblabel{\@ifundefined{DCN@#2\@extra@b@citeb}{\@warning
    {Reference `#2' on page \thepage\space was never cited}}{}%
   \DC@llap{$^{\@nameuse{DCN@#2\@extra@b@citeb}}$\ \ }%%o
   \@citeverb{#2}}\hfil]\if@filesw{\def\protect##1{\string ##1\space}%
   \immediate\write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}

\def\@bibitem#1{\refstepcounter{\@listctr}\@lbibitem[\the\value{\@listctr}]{#1}}

%  make the special characters in the citation tag printable
%
\def\@citeverb#1{%
 {\citeform{% to get characters <>_|{}: \citeform->\tt
   \expandafter \expandafter \expandafter \@gobblethree %  do \csname, \string,
   \expandafter \string\csname b@#1\endcsname}%     %  \@gobble, in that order.
}}%

\def\@gobblethree#1#2#3{}

%   \@extra@b@citeb is a hook for other style files to further specify
%   citations; for example, to number by chapter.
%   In case no fancy bib package (chapterbib) defines it:

\@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{}

%------------------------------------
%   Handle optional variations:

\def\nocitecount{%
  \def\@advancecitecount{\global\@namedef{DCN@\@citeb\@extra@b@citeb}{}}%
  \let\DC@llap\@gobble}
\nocitecount % in case what follows gets removed

\newcount\@HighCite \global\@HighCite\z@
\let\@dftc@ifund\@ifundefined
\let\@dftc@hbox\hbox

\@ifundefined{DeclareOption}{}%
{ \DeclareOption{nocitecount}{\endinput}
  \toks@={\def\@dftc@ifund#1#2#3{#2}}
  \DeclareOption{verbose}{\the\toks@}
  \DeclareOption{tt}{\def\citeform{\tt}}
  \DeclareOption{nospace}{\def\citepunct{,\penalty\z@}}
  \DeclareOption{space}{\def\citepunct{,\ }}
  \DeclareOption{breakcites}{\let\@dftc@hbox\relax}
  \ProvidesPackage{drftcite}[1995/01/23 \space  v 3.5]
  \ProcessOptions }

% The rest deals only with counting, and can be removed if counting is never
% desired.

\let\DC@llap=\llap
%
%     count the citations as they appear in the text
%
\def\@advancecitecount{\@ifundefined {DCN@\@citeb\@extra@b@citeb}%
{\global\advance\@HighCite\@ne
\expandafter\xdef\csname DCN@\@citeb\@extra@b@citeb\endcsname{\the\@HighCite}}%
{}}
%
%  The remainder handles (counting over) input files skipped by \includeonly.
%  It adds code to LaTeX's \include to re-read the .aux file checking the
%  \citation commands.
%
%  For included files that are skipped (not listed by \includeonly)
%  input the .aux file ignoring all commands but \citation, which
%  does \@advancecitecount (keeps count of the citations).  This adds
%  a requirement for other style files that add commands to the .aux
%  file:  the commands must be safe to execute an extra time.
%
\let\@dftc@include\include
\def\include#1{\relax
 \ifx\DC@llap\llap \begingroup % do counting only if wanted
  \@ifundefined{cp@#1}{}% don't do if .aux file not there!
   {\toks@\expandafter\expandafter\expandafter{\csname cp@#1\endcsname}%
   \expandafter\xdef\csname cp@#1\endcsname{\the\toks@
    \noexpand\@dftc@auxcite{#1}}}%
 \endgroup\fi \@dftc@include{#1}}
%
\def\@dftc@auxcite#1{\begingroup % disable everything but \citation
  \let\bibcite\@gobbletwo \let\newlabel\@gobbletwo \let\@writefile\@gobbletwo
  \let\bibdata\@gobble \let\bibstyle\@gobble % already \@gobble normally
  \def\citation##1{\@for\@citeb:=##1\do {\@advancecitecount}}%
  \makeatletter\@input{#1.aux}\endgroup
}
\endinput


%     D R F T C I T E . S T Y
%
%     version 3.5  (Jan 1995)
%
%  This package makes LaTeX use the identifying label instead of the number
%  for citations, as if the bibliography had entries like \bibitem[name]{name}
%  but LaTeX writes the proper citation number to the aux file for later runs.
%  Spaces before the \cite command are ignored, and an ordinary interword
%  space is used.  This package is particularly useful for draft (draught)
%  versions of documents.
%
%  The \citen command is provided, as in cite.sty, to print just the citation
%  or list of citations without the brackets and other formatting.
%
%  Drftcite keeps track of which references were cited, and issues warnings
%  for bibliography items that were never cited in the text.
%
%  This package also keeps track of the order of first-citations in the text
%  for easy sorting (in lieu of BibTeX).  To omit this counting...
%  LaTeX 2.09: declare \nocitecount before the first \cite; or, for
%     a more permanent removal, comment-out the lines ending with %%o
%     below, and omit everything following the line that begins with %%o.
%  LaTeX2e: specify \usepackage[nocitecount]{drftcite}, or perform the
%     editing described above.
%
%  The characters <>|_{}\ are not present in the cm roman fonts, so if you use
%  them in identifiers, they will have to be typeset in typewriter style.
%  To do this,...
%  LaTeX 2.09: insert \renewcommand\citeform{\tt} in your preamble
%  LaTeX2e: specify \usepackage[tt]{drftcite}
%
%  `Citation...undefined' warnings are only given once per undefined
%  citation name.  In the text, missing numbers are represented with a
%  bold `name?'.   To restore multiple warnings...
%  LaTex 2.09: edit this file, removing the lines with the comments:
%      "delete to warn always"
%  LaTeX2e: specify \usepackage[verbose]{drftcite}
%
%  Other options for \usepackage are:
%  [space]    -  Separate printed names with comma-space (Default).
%  [nospace]  -  Print just a comma (not comma-space) after each name.
%  [breakcites]  - Allow each printed name to be broken (hyphenated).
%
%  There are several commands that you may redefine (using \renewcommand)
%  to change the formatting of citation lists:
%
%   command       function                   default
%  ----------    -----------------------    ----------------------------
%  \citeform     reformats every entry      nothing
%  \citepunct    printed between numbers    comma + space
%  \citeleft     left delimiter of list     [
%  \citeright    right delimeter of list    ]
%  \citemid      printed before note        comma + space
%
%  This version of drftcite can co-exist with chapterbib.sty (version 1.4
%  or later).
%
%  [This file is named "drftcite" because "draftcite" is too long a name for
%   some computers.  Sorry to those who use the spelling "draught."  I could
%   have abbreviated the name by selecting the shared letters in "draft" and
%   "draught," but "dratcite" somehow conveys the wrong meaning.]
%
% Version 1991: Ignore spaces after commas in the parameter list. Create
%    \nocitecount to turn off counting the order of citations.
% Version 3.1 (1992): protect \cite and \citen. (There is no version 3.0)
% Version 3.2 (1993): Supress repetitions of warning messages.  Include
%    \@extra@b@citeb hook for chapterbib.sty.  Make \include handle case that
%    \cp@FOO was not defined.
% Version 3.3 (1993): Fix \nocitecount. Change printing of undefined refs.
% Version 3.4 (1994): LaTex2e support, including spaces in protected command
%    names; better chapterbib support.
% Version 3.5 (1995): Add tests before removing space + options from cite.sty.
%    change \@citeverb to not eat hash space.
%
% Send problem reports to asnd@Reg.triumf.ca
%
% Test integrity of file:
% brackets:  round, square, curly, angle:   () [] {} <>
% backslash, slash, vertical, at, dollar, and: \ / | @ $ &
% hat, grave, acute (apostrophe), quote, tilde, under:   ^ ` ' " ~ _