Debian Codegraph @

texmf-dist/source/latex/mcite/mcite.dtx

raw
1 % \iffalse % mcite.dtx - multiple citations on one key
2 % Copyright (C) 1994 by [email protected]
3 % $Header: /home/sources/ohl/tex/thotex/mcite/mcite.dtx,v 1.6 1996/01/01 23:52:29 ohl Exp $
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 %
6 % Mcite is free software; you can redistribute it and/or modify it
7 % under the terms of the GNU General Public License as published by
8 % the Free Software Foundation; either version 2, or (at your option)
9 % any later version.
10 %
11 % Mcite is distributed in the hope that it will be useful, but
12 % WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with this program; if not, write to the Free Software
18 % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 %
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 %
22 % \fi
23 %
24 %% \CheckSum{212}
25 %% \CharacterTable
26 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
27 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
28 %% Digits \0\1\2\3\4\5\6\7\8\9
29 %% Exclamation \! Double quote \" Hash (number) \#
30 %% Dollar \$ Percent \% Ampersand \&
31 %% Acute accent \' Left paren \( Right paren \)
32 %% Asterisk \* Plus \+ Comma \,
33 %% Minus \- Point \. Solidus \/
34 %% Colon \: Semicolon \; Less than \<
35 %% Equals \= Greater than \> Question mark \?
36 %% Commercial at \@ Left bracket \[ Backslash \\
37 %% Right bracket \] Circumflex \^ Underscore \_
38 %% Grave accent \` Left brace \{ Vertical bar \|
39 %% Right brace \} Tilde \~}
40 %%
41 %
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 %
44 % \MakeShortVerb{\|}
45 %
46 % \title{%
47 % \MCITE/: \\
48 % Multiple Citations on One Key}
49 %
50 % \author{%
51 % Thorsten Ohl\thanks{e-mail:
52 % \texttt{[email protected]}}\\
53 % \hfil \\
54 % Technische Hochschule Darmstadt \\
55 % Schlo\ss gartenstr. 9 \\
56 % D-64289 Darmstadt \\
57 % Germany}
58 %
59 % \maketitle
60 %
61 % \begin{abstract}
62 % This \LaTeXe{} package provides support for collapsing multiple
63 % citations into one, as custumoary in physics journals.
64 % \end{abstract}
65 %
66 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % \tableofcontents
68 % \unitlength=1mm
69 %
70 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 % \section{Introduction}
72 %
73 % Imagine we want to refer to the standard
74 % model~\cite{Glashow,*Salam,*Weinberg} of particle physics. Instead
75 % of the standard \BibTeX{}~\cite{btxdoc,*btxhak} format
76 % \begin{itemize}
77 % \bitem{1} Sheldon Glashow. Partial symmetries of weak interactions.
78 % {\em Nucl.~Phys.}, 22:579, 1961.
79 % \bitem{2} Abdus Salam. Weak and electromagnetic interactions.
80 % In W.~Svartholm, editor, {\em Elementary Particle Theory}, page 367,
81 % Stockholm, 1968. Almquist and Wiksell.
82 % \bitem{3} Steven Weinberg. A model of leptons.
83 % {\em Phys.~Rev.~Lett.}, 19:1264, 1967.
84 % \end{itemize}
85 % it is customary in physics journals to collapse such references into one
86 % \begin{itemize}
87 % \bitem{1} Sheldon Glashow, Nucl.~Phys.~\textbf{22} (1961) 579;
88 % Abdus Salam, in: W.~Svartholm (ed.), \textit{Elementary
89 % Particle Theory}, p.~367, Stockholm, 1968;
90 % Steven Weinberg, Phys.~Rev.~Lett.~\textbf{19} (1967) 1264.
91 % \end{itemize}
92 % The slight typographyical changes are easily taken care of by
93 % changing the \BibTeX{} style, i.e.~by using |phaip.bst|. The hard
94 % part is to convince \BibTeX{} to collapse the entries. \MCITE/
95 % takes care of that.
96 %
97 % \DescribeMacro{\cite}
98 % This package overloads the \LaTeX{}~\cite{latex,*latex-companion}
99 % |\cite| command. All keys starting with a |*| (which should be
100 % sufficiently unlikely in a \BibTeX{} key) will be added to the
101 % previous item. For example the following
102 % reference~\cite{texbook,latex,*latex-companion,Glashow,*Salam,*Weinberg}
103 % was created by
104 % |\cite{texbook,latex,*latex-companion,Glashow,*Salam,*Weinberg}|.
105 %
106 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 % \subsection*{Hacking the \BibTeX{} Style}
108 %
109 % With the standard \BibTeX{} styles, it is almost impossible to
110 % provide proper punctuation (i.e.~``|;|'' between collapsed items).
111 % In principle one could play tricks with an active ``|.|'', but there
112 % are too many special cases in real life \BibTeX{} entries that can go
113 % wrong. Fortunately, it is fairly easy to customize \BibTeX{} styles
114 % for our purposes.
115 %
116 % Almost all \BibTeX{} styles known to (wo)mankind contain a function
117 % \begin{verbatim}
118 % FUNCTION {fin.entry}
119 % { add.period$
120 % write$
121 % newline$
122 % }
123 % \end{verbatim}
124 % removing the |add.period$| and escaping the |newline$| with |\relax|
125 % will take care of the paragraph breaks and allow \MCITE/ to provide
126 % the proper punctuation:
127 % \begin{verbatim}
128 % FUNCTION {fin.entry}
129 % { write$
130 % "\relax" write$
131 % newline$
132 % "\relax" write$
133 % }
134 % \end{verbatim}
135 % Note that |%| would be almost as good as |\relax| but the latter
136 % also works if the |\catcode| of |%| has been changed.
137 %
138 % In the function |begin.bib|, the |\begin{thebibliography}| should be
139 % replaced by |\begin{mcbibliography}|. Similary, in |end.bib| the
140 % |\end{thebibliography}| by |\end{mcbibliography}|. The
141 % |mcbibliography| environment will inform \MCITE/ that it has to
142 % provide the punctuation.
143 %
144 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 % \subsection*{Bugs and Deficiencies}
146 %
147 % The following bugs and deficiencies are known:
148 % \begin{enumerate}
149 % \item{} \MCITE/ only works with unsorted bibliography styles.
150 % Without modifications to \BibTeX, it seems impossible to support
151 % sorted bibliography styles.
152 % \item{} \MCITE/'s |\cite| is less forgiving about bogus spaces.
153 % This can be fixed.
154 % \end{enumerate}
155 %
156 % \StopEventually{}
157 %
158 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 % \section{Implementation}
160 %
161 % It's is good practice to identify this version of this package.
162 % We do this by parsing an RCS |Id| string and storing the
163 % result in the conventional \TeX{} control sequences:
164 % \begin{macrocode}
165 %<*package>
166 \def\fileversion{v0.04}
167 \NeedsTeXFormat{LaTeX2e}
168 {\def\RCS#1#2\endRCS{%
169 \ifx$#1%
170 \@RCS $#2 \endRCS
171 \else
172 \@RCS $*: #1#2$ \endRCS
173 \fi}%
174 \def\@RCS $#1: #2,v #3 #4 #5 #6$ \endRCS{%
175 \gdef\filename{#2}%
176 \gdef\filerevision{v#3}%
177 \gdef\filedate{#4}%
178 \gdef\docdate{#4}}%
179 \RCS $Id: mcite.dtx,v 1.6 1996/01/01 23:52:29 ohl Exp $ \endRCS}%
180 % \end{macrocode}
181 %
182 % And now the standard procedure:
183 % \begin{macrocode}
184 \ProvidesPackage{mcite}[\filedate\space multiple citations]
185 \typeout{Package: `mcite'
186 \fileversion\space <\filedate> (tho) PRELIMINARY TEST RELEASE}
187 \wlog{English documentation \@spaces<\docdate> (tho)}
188 % \end{macrocode}
189 %
190 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 % \subsection{Collecting Information}
192 %
193 % \begin{macrocode}
194 \def\@enamedef#1{\expandafter\edef\csname #1\endcsname}
195 % \end{macrocode}
196 %
197 % \begin{macrocode}
198 \def\mc@single#1{\global\@enamedef{mc*sg*#1}{}}
199 \def\mc@head#1#2{\global\@enamedef{mc*hd*#1}{#2}}
200 \def\mc@tail#1#2{\global\@enamedef{mc*tl*#1}{#2}}
201 % \end{macrocode}
202 %
203 % \begin{macrocode}
204 \def\mc@ifsingle#1#2#3{\@ifundefined{mc*sg*#1}{#3}{#2}}
205 \def\mc@ifhead#1#2#3{\@ifundefined{mc*hd*#1}{#3}{#2}}
206 \def\mc@iftail#1#2#3{\@ifundefined{mc*tl*#1}{#3}{#2}}
207 % \end{macrocode}
208 %
209 % \begin{macrocode}
210 \def\mc@thehead#1{\@nameuse{mc*tl*#1}}
211 \def\mc@thetail#1{\@nameuse{mc*hd*#1}}
212 % \end{macrocode}
213 %
214 % \begin{macro}{\mcite}
215 % We are overloading the original |\cite| command such that
216 % |\cite{latex,*latex-companion,texbook}| will give
217 % ``\cite{latex,*latex-companion,texbook}''.
218 % \begin{macrocode}
219 \let\orig@cite\cite
220 \def\mcite{%
221 \@ifnextchar[%
222 {\PackageWarning{mcite}%
223 {optional argument to \protect\cite\space not supported}%
224 \@tempswatrue
225 \expandafter\mc@citex\mc@gobbleopt}%
226 {\@tempswatrue
227 \mc@cite}}
228 % \end{macrocode}
229 % \end{macro}
230 % Gobble up all optional arguments
231 % \begin{macrocode}
232 \def\mc@gobbleopt[#1]{}
233 % \end{macrocode}
234 % \begin{macro}{\cite}
235 % \changes{v0.04}{1996/01/01}{%
236 % Better coexistence with \texttt{cite.sty}: overload
237 % later, \texttt{AtBeginDocument}.}
238 % If we postpone the overloading of |\cite| until the
239 % |\begin{document}|, we can coexist with |cite.sty|. If we were to
240 % do it now, we would have to demand that |cite.sty| is loaded
241 % \emph{before} |mcite.sty|.
242 % \begin{macrocode}
243 \AtBeginDocument{\let\cite\mcite}
244 % \end{macrocode}
245 % \end{macro}
246 %
247 % \begin{macro}{\mc@cite}
248 % First of all: expand the argument:
249 % \begin{macrocode}
250 \def\mc@cite#1{%
251 \edef\mc@temp{#1}%
252 \expandafter\mc@cite@\expandafter{\mc@temp}}
253 % \end{macrocode}
254 % Here we do the actual ``preprocessing'' of the |\cite| keys.
255 % \begin{macrocode}
256 \def\mc@cite@#1{%
257 \mc@firsttrue
258 \@for\mc@@@:=#1\do{%
259 % \end{macrocode}
260 % It the key starts with a |*|, mark it as tail. Otherwise mark it as
261 % head.
262 % \begin{macrocode}
263 \expandafter\mc@ifstar\mc@@@\sentinel%
264 {\ifmc@first
265 \PackageWarning{mcite}%
266 {tail `\mc@key' appears as first item in \protect\cite}%
267 \mc@dohead
268 \else
269 \mc@dotail
270 \fi}%
271 {\mc@dohead}%
272 % \end{macrocode}
273 % Write a |\citation| command to the |.aux| file in any case. This
274 % gives some duplication but keeps things in order.
275 % \begin{macrocode}
276 \if@filesw
277 \immediate\write\@auxout{\string\citation{\mc@key}}%
278 \fi}%
279 \expandafter\orig@cite\expandafter{\mc@list}}
280 % \end{macrocode}
281 % \end{macro}
282 % \begin{macrocode}
283 \def\mc@dohead{%
284 \mc@iftail{\mc@key}%
285 {\PackageWarning{mcite}%
286 {head `\mc@key' already used as tail of `\mc@thehead{\mc@key}'}}%
287 {}%
288 \mc@head{\mc@key}{}%
289 \edef\mc@curhead{\mc@key}%
290 \ifmc@first
291 \mc@firstfalse
292 \edef\mc@list{\mc@key}%
293 \else
294 \edef\mc@list{\mc@list,\mc@key}%
295 \fi}
296 % \end{macrocode}
297 % \begin{macrocode}
298 \def\mc@dotail{%
299 \mc@ifhead{\mc@key}%
300 {\PackageWarning{mcite}%
301 {tail `\mc@key' already used as head}}%
302 {}%
303 \mc@tail{\mc@key}{\mc@curhead}}
304 % \end{macrocode}
305 % \begin{macrocode}
306 \def\mc@ifstar#1#2\sentinel#3#4{%
307 \ifx*#1%
308 \def\mc@key{#2}%
309 #3%
310 \else
311 \def\mc@key{#1#2}%
312 #4%
313 \fi}
314 % \end{macrocode}
315 % \begin{macrocode}
316 \newif\ifmc@first
317 % \end{macrocode}
318 %
319 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320 % \subsection{Producing the Output}
321 %
322 % The simplest approach is to just drop the |\@bibitem| if we're
323 % processing a continuation (it is just an |\item| with associated
324 % |.aux| file action):
325 % \begin{macrocode}
326 \let\orig@bibitem\@bibitem
327 \def\@bibitem#1{%
328 % \end{macrocode}
329 % If the \BibTeX{} style supports \MCITE/, we have to provide
330 % punctuation ourselves.
331 % \begin{macrocode}
332 \ifmc@bstsupport
333 \mc@iftail{#1}%
334 {;\space\ignorespaces}%
335 {\ifmc@first\else.\fi\orig@bibitem{#1}}
336 \mc@firstfalse
337 \else
338 \mc@iftail{#1}%
339 {\ignorespaces}%
340 {\orig@bibitem{#1}}%
341 \fi}%
342 % \end{macrocode}
343 % \begin{macrocode}
344 \newif\ifmc@bstsupport
345 \mc@bstsupportfalse
346 % \end{macrocode}
347 % We can't handle |\bibitem|s with an optional argument; tell the user.
348 % \begin{macrocode}
349 \def\@lbibitem[#1]#2{%
350 \PackageError{mcite}%
351 {You can't use the optional argument of \protect\bibitem}%
352 {Hey, *I* have to fool around with the labels!}%
353 \@bibitem{#2}}
354 % \end{macrocode}
355 % The |mcbibliography| environment instructs \MCITE/ to provide its
356 % own punctuation.
357 % \begin{macrocode}
358 \def\mcbibliography{%
359 \mc@bstsupporttrue
360 \mc@firsttrue
361 \thebibliography}
362 \def\endmcbibliography{%
363 .%
364 \endthebibliography}
365 % \end{macrocode}
366 %
367 % That's it!
368 % \begin{macrocode}
369 %</package>
370 % \end{macrocode}
371 %
372 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
373 % \Finale
374 %
375 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 % \bibliography{mcite}
377 %
378 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379 % \PrintIndex
380 % \PrintChanges
381 %
382 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 % \appendix
384 % \section{Driver File}
385 %
386 % In general we will of course format this documentation with itself.
387 % \begin{macrocode}
388 %<*driver>
389 \documentclass[a4paper]{article}
390 \usepackage{doc}
391 \usepackage{mcite}
392 \EnableCrossrefs
393 \RecordChanges
394 \CodelineIndex
395 \makeatletter
396 \def\bitem#1{\item[\@biblabel{#1}]}
397 \makeatother
398 \def\MCITE/{\texttt{mcite}}
399 \DoNotIndex{\\,\advance,\baselineskip,\batchmode,\begin,\catcode,\char}
400 \DoNotIndex{\CodelineIndex,\csname,\def,\divide,\docdate,\DocInput}
401 \DoNotIndex{\documentclass,\else,\emph,\EnableCrossrefs,\end,\endcsname}
402 \DoNotIndex{\errmessage,\errorstopmode,\expandafter,\fbox,\fi,\filedate}
403 \DoNotIndex{\filename,\fileversion,\font,\fontencoding,\fontfamily}
404 \DoNotIndex{\fontseries,\fontshape,\fontsize,\gdef,\goodbreak,\hfil}
405 \DoNotIndex{\hoffset,\hskip,\ifcase,\ifx,\InputIfFileExists,\item,\let}
406 \DoNotIndex{\line,\LoadClass,\makebox,\mbox,\multiply,\NeedsTeXFormat}
407 \DoNotIndex{\newdimen,\newenvironment,\newif,\nobreak,\normalfont}
408 \DoNotIndex{\normalsize,\nullfont,\or,\oval,\pagestyle,\par,\parbox}
409 \DoNotIndex{\parindent,\parskip,\PassOptionsToClass,\ProcessOptions}
410 \DoNotIndex{\ProvidesClass,\put,\quad,\raisebox,\RecordChanges,\relax,\rule}
411 \DoNotIndex{\selectfont,\space,\ss,\texttt,\textwidth,\the,\thispagestyle}
412 \DoNotIndex{\topmargin,\usepackage,\voffset,\vskip,\vspace,\wlog}
413 \begin{document}
414 \bibliographystyle{unsrt}%%%{physics}
415 \DocInput{mcite.dtx}
416 \end{document}
417 %</driver>
418 % \end{macrocode}
419 %
420 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
421 % \section{Copying}
422 % \label{sec:GPL}
423 %
424 % \MCITE/ is free software; you can redistribute it and/or modify it
425 % under the terms of the GNU General Public License as published by
426 % the Free Software Foundation; either version 2, or (at your option)
427 % any later version.
428 %
429 % \MCITE/ is distributed in the hope that it will be useful, but
430 % \emph{without any warranty}; without even the implied warranty of
431 % \emph{merchantability} or \emph{fitness for a particular purpose}.
432 % See the GNU General Public License for more details.
433 %
434 % You should have received a copy of the GNU General Public License
435 % along with this program; if not, write to the Free Software
436 % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
437 %
438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439 \endinput
440 Local Variables:
441 mode:LaTeX
442 fill-prefix:"% "
443 page-delimiter:"^%%%%%%%%%%%*\n"
444 End: