*** empty log message ***
[m17n/m17n-docs.git] / styles / backref.sty
1 %%
2 %% This is file `backref.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% backref.dtx  (with options: `package')
8 %% 
9 \def\fileversion{1.19}
10 \def\filedate{2000/01/19}
11 %% File: backref.dtx Copyright (C) 1995, 1996, 1997, 1999 David Carlisle, Sebastian Rahtz
12 %% This file is part of the `Hyperref Bundle'.
13 %% -------------------------------------------
14 %%
15 %% It may be distributed under the conditions of the LaTeX Project Public
16 %% License, either version 1.2 of this license or (at your option) any
17 %% later version.  The latest version of this license is in
18 %%    http://www.latex-project.org/lppl.txt
19 %% and version 1.2 or later is part of all distributions of LaTeX
20 %% version 1999/12/01 or later.
21 %%
22 %% The list of all files belonging to the `Hyperref Bundle' is
23 %% given in the file `manifest.txt'.
24 \ProvidesPackage{backref}%
25   [\filedate\space v\fileversion\space Bibliographical back referencing]
26 \newif\ifBR@verbose
27 \@ifundefined{ifHy@verbose}{%
28   \BR@verbosefalse
29 }{%
30   \let\ifBR@verbose\ifHy@verbose
31 }
32 \DeclareOption{verbose}{\BR@verbosetrue}
33 \long\def\page@backref#1#2#3{#1}
34 \long\def\section@backref#1#2#3{#2}
35 \long\def\hyper@section@backref#1#2#3{\hyperlink{#3}{#2}}
36 \long\def\hyper@page@backref#1#2#3{\hyperlink{page.#1}{#1}}
37 \def\backrefpagesname{pages}
38 \def\backrefsectionsname{sections}
39 \DeclareOption{pageref}{%
40   \def\backref{\backrefpagesname\ }%
41   \let\backrefxxx\page@backref
42 }
43 \DeclareOption{ref}{%
44   \def\backref{\backrefsectionsname\ }%
45   \let\backrefxxx\section@backref
46 }
47 \DeclareOption{hyperref}{%
48   \def\backref{}\let\backrefxxx\hyper@section@backref
49 }
50 \DeclareOption{hyperpageref}{%
51   \def\backref{}\let\backrefxxx\hyper@page@backref
52 }
53 \ExecuteOptions{pageref}
54 \ProcessOptions
55 \def\BR@bibitem{\@ifnextchar[\BR@@lbibitem\BR@@bibitem}
56 \def\BR@@lbibitem[#1]#2#3\par{%
57   \BRorg@bibitem[#1]{#2}#3
58   \newblock
59   \backref{\csname br@#2\endcsname}%
60   \par
61 }%
62 \def\BR@@bibitem#1#2\par{%
63   \BRorg@bibitem{#1}#2
64   \newblock
65   \backref{\csname br@#1\endcsname}%
66   \par
67 }
68 \@ifundefined{newblock}{\def\newblock{\par}}{}
69 \def\backcite#1#2{%
70   \@for\x:=#1\do{%
71     \edef\x{\expandafter\@firstofone\x\@empty}%
72     \expandafter\ifx\csname br@\x\endcsname\relax
73       \expandafter\protected@xdef\csname br@\x\endcsname{%
74         \protect\backrefxxx#2%
75       }%
76     \else
77       \begingroup
78         \expandafter\def\expandafter\reserved@a\expandafter{%
79           \backrefxxx#2%
80         }%
81         \let\BRorg@backrefxxx\backrefxxx
82         \global\let\BR@found=N%
83         \long\def\backrefxxx##1##2##3{%
84           \expandafter\def\expandafter\reserved@b\expandafter{%
85             \BRorg@backrefxxx{##1}{##2}{##3}%
86           }%
87           \ifx\reserved@a\reserved@b
88             \global\let\BR@found=Y%
89           \fi
90         }%
91         \setbox\@tempboxa\hbox{\csname br@\x\endcsname}%
92       \endgroup
93       \if N\BR@found
94         \expandafter\protected@xdef\csname br@\x\endcsname{%
95           \csname br@\x\endcsname, %
96           \protect\backrefxxx#2%
97         }%
98       \fi
99     \fi
100   }%
101 }
102 \def\@currentHref{}
103 \AtBeginDocument{%
104   \let\BRorg@bibitem\bibitem
105   \let\bibitem\BR@bibitem
106   \let\BRorg@thebibliography\thebibliography
107   \def\thebibliography{%
108     \@starttoc{brf}{}%
109     \BRorg@thebibliography
110   }%
111   \@ifundefined{NAT@parse}{%
112     \global\let\BRorg@citex\@citex
113     \global\let\@citex\BR@citex
114   }{%
115     \PackageInfo{backref}{** backref set up for natbib **}%
116   }%
117 }
118 \def\BR@citex[#1]#2{%
119   \BRorg@citex[#1]{#2}%
120   \ifBR@verbose
121     \PackageInfo{backref}{back cite \string`#2\string'}%
122   \fi
123   \Hy@backout{#2}%
124 }
125 \@ifpackageloaded{chicago}{%
126   \let\BRorg@citedatax\@citedatax
127   \def\@citedatax[#1]#2{%
128     \BRorg@citedatax[#1]{#2}%
129     \Hy@backout{#2}%
130   }%
131 }{}
132 \def\Hy@backout#1{%
133   \@bsphack
134   \ifx\@empty\@currentlabel
135     \protected@write\@auxout{}{%
136       \string\@writefile{brf}{%
137         \string\backcite{#1}{{\thepage}{(document)}{Doc-Start}}%
138       }%
139     }%
140   \else
141    \protected@write\@auxout{}{%
142      \string\@writefile{brf}{%
143        \string\backcite{#1}{{\thepage}{\@currentlabel}{\@currentHref}}%
144      }%
145    }%
146   \fi
147   \@esphack
148 }
149 \endinput
150 %%
151 %% End of file `backref.sty'.