summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/cites.sty
blob: 8e2ed5eacd4753833ee937a1e4713843e7c9ebde (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
%
% CITES (style option to DARTICLE) is an extracted and changed
% part of the AIP style written by Charles Karney (Karney@PPC.MFEnet).
% CITES DOCUMENT SUBSTYLE -- released 15 March 1988
%
% To use this give CITES as an optional argument to \documentstyle.  The
% main style should be DARTICLE.  E.g.,
%     \documentstyle[12pt,german,cites]{darticle}
 
% This provides
% (1) Superscript reference numbers in citation and bibliography.
%     This is done by calling  \numcite  after \begin{document}.
%     You should put the references in the logically correct place, e.g.
%     "...  as is given by Landau \cite{landau}.  Next sentence ..."
%     \cite takes care of removing the preceding spaces and putting the
%     reference after the punctuation (e.g, "...  Landau.$~7$ ...").
 
% (2) Three or more consecutive reference numbers are represented as a
%     range.  Thus 1,3,4,5,6,8,9 is printed as 1,3--6,8,9.  No sorting is
%     performed; i.e., 1,3,2 is printed as such.
%     The cites style does this by default.
 
% (3) \citenum and \citea give you more control over the appearance of
%     the citations.  \citenum emits the plain citation number without
%     ornament as in "...  as shown in Ref.~\citenum{foo}.".  \citea puts
%     it's argument into the ornamentation for citations.
%     Thus \cite{foo} is equivalent to \citea{\citenum{foo}}.
 
% (4) \bibnum{p} prints entries of the thebibliography environment in the
%     form     #.
%     \bibnum{k} prints entries of the thebibliography environment in the
%     form    [#]
%     \bibnum{h} prints entries of the thebibliography environment in the
%     form    $^{#1}$
%     Default is \bibnum{k}.
%     If \numcite is used, \bibnum should appear after it.
%     G. Kruljac,  MPI Stuttgart, kruljac@ds0mpi11,   13.03.89
 
%   CHANGES
%  06.04.89  G. Kruljac, kruljac@ds0mpi11
%            - inserted commands \refincount and \@refincount to
%              offer a possibility for citation numbering inside
%              chapters, sections,...
%              Initially it is empty. The user can define it by i.e.
%              \refincount{\thechapter.} or \refincount{\thesubsection.}
%
%            - corrections inside thebibliography for leftmargin
%              evaluations
%
%
 
%\typeout{Document Substyle 'CITES'.  Released 15 March 1988}
\typeout{Document Substyle `CITES' modified by MPI FKF, Version 1.1, 06.04.89}
 
% here we define the counter which should preceed the reference number
\def\@refincount{}
\def\refincount#1{\gdef\@refincount{#1}}
 
% Superscript citations -- skip optional arg to \cite
% Move citation after period and comma.
\def\@cite#1#2{[{\@refincount#1\if@tempswa , #2\fi}]}
 
\gdef\numcite{\bibnum{h}
              \def\@cite##1##2{\unskip\nobreak\relax
              \def\@tempa{$\m@th^{\hbox{\the\scriptfont0
                                        \@refincount##1}}$}%
              \futurelet\@tempc\@citexx}
              \def\@citexx{\ifx.\@tempc\let\@tempd=\@citepunct\else
                           \ifx,\@tempc\let\@tempd=\@citepunct\else
                           \let\@tempd=\@tempa\fi\fi\@tempd}
              \def\@citepunct{\@tempc%
                           \edef\@sf{\spacefactor=\the\spacefactor\relax}
                           \@tempa\@sf\@gobble}}
 
\def\bibnumh{\hfil$\m@th^{\@refincount\arabic{enumi}}$}
\def\bibnump{\hfil\@refincount\arabic{enumi}.}
\def\bibnumk{\hfil[\@refincount\arabic{enumi}]}
\def\bibnum#1{\if\string#1h \global\let\@bibnum=\bibnumh\else
              \if\string#1k \global\let\@bibnum=\bibnumk\else
              \if\string#1p \global\let\@bibnum=\bibnump\else
              \global\let\@bibnum=\bibnumh%
              \fi\fi\fi}
\let\@bibnum=\bibnumk
 
\def\thebibliography#1{\par%\clearpage%
             \section*{\refname\@mkboth
                       {\uppercase{\refname}}{\uppercase{\refname}}}%
             \list
%            {\@bibnum}{\settowidth\labelwidth{$\m@th{##1}$}
             {\@bibnum}%
            {\ifx\@bibnum\bibnumk%
                  \settowidth\labelwidth{[\@refincount#1]}
              \else\ifx\@bibnum\bibnumh
                        \settowidth\labelwidth{$\m@th^{\@refincount#1}$}
                        \labelsep0pt\itemindent\labelwidth
                   \else\settowidth\labelwidth{\@refincount#1.}
              \fi\fi
             \leftmargin\labelwidth
             \advance\leftmargin\labelsep
             \ifnum\itemindent=0\else\advance\itemindent-\leftmargin\fi
             \usecounter{enumi}}
             \def\newblock{\hskip .11em plus .33em minus -.07em}
             \sloppy
             \sfcode`\.=1000\relax}
 
% \citenum emits the plain citation number without ornament
% \citea puts it's argument into the ornamentation for citations
% thus \cite{foo} is equivalent to \citea{\citenum{foo}}
\def\citenum#1{{\def\@cite##1##2{##1}\cite{#1}}}
\def\citea#1{\@cite{#1}{}}
 
% Collapse citation numbers to ranges.  Non-numeric and undefined labels
% are handled.  No sorting is done.  E.g., 1,3,2,3,4,5,foo,1,2,3,?,4,5
% gives 1,3,2-5,foo,1-3,?,4,5
\newcount\@tempcntc
\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \@tempcnta\z@\@tempcntb\m@ne\def\@citea{}\@cite{\@for\@citeb:=#2\do
    {\@ifundefined
       {b@\@citeb}{\@citeo\@tempcntb\m@ne\@citea\def\@citea{,}{\bf ?}\@warning
       {Citation `\@citeb' on page \thepage \space undefined}}%
    {\setbox\z@\hbox{\global\@tempcntc0\csname b@\@citeb\endcsname\relax}%
     \ifnum\@tempcntc=\z@ \@citeo\@tempcntb\m@ne
       \@citea\def\@citea{,}\hbox{\csname b@\@citeb\endcsname}%
     \else
      \advance\@tempcntb\@ne
      \ifnum\@tempcntb=\@tempcntc
      \else\advance\@tempcntb\m@ne\@citeo
      \@tempcnta\@tempcntc\@tempcntb\@tempcntc\fi\fi}}\@citeo}{#1}}
\def\@citeo{\ifnum\@tempcnta>\@tempcntb\else\@citea%
            \def\@citea{,\@refincount}%
            \ifnum\@tempcnta=\@tempcntb\the\@tempcnta\else
            {\advance\@tempcnta\@ne%
            \ifnum\@tempcnta=\@tempcntb
            \else \def\@citea{--\@refincount}\fi
    \advance\@tempcnta\m@ne\the\@tempcnta\@citea\the\@tempcntb}\fi\fi}