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
|
\def\fileversion{1.20}
\def\filedate{2002/06/09}
%
% \iffalse
%% File: backref.dtx Copyright (C) 1995-2002 David Carlisle, Sebastian Rahtz, Heiko Oberdiek
%
%% This file is part of the `Hyperref Bundle'.
%% -------------------------------------------
%%
%% It may be distributed under the conditions of the LaTeX Project Public
%% License, either version 1.2 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.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%%
%% The list of all files belonging to the `Hyperref Bundle' is
%% given in the file `manifest.txt'.
%<*driver>
\documentclass{ltxdoc}
\begin{document}
\title{%
Back referencing from bibliographical citations%
\thanks{%
This file has version number \fileversion,
last revised \filedate.%
}%
}
\author{David Carlisle and Sebastian Rahtz}
\date{\filedate}
\maketitle
\tableofcontents
\DocInput{backref.dtx}
\end{document}
%</driver>
% \fi
% \CheckSum{240}
% \MakeShortVerb{|}
% \section{Introduction}
%
% \section{Usage}
%
% \StopEventually{}
%
% \section{The macros}
% Internal command names of this package start with |\BR@|,
% commands, that store the original meaning of commands, which
% will be redefined, are prefixed with |\BRorg@|.
%
% \subsection{Package identification}
% \begin{macrocode}
%<*package>
\ProvidesPackage{backref}%
[\filedate\space v\fileversion\space Bibliographical back referencing]
% \end{macrocode}
%
% \subsection{Options}
%
% \subsubsection{Option verbose}
% If package hyperref is loaded, then its setting is used as
% default for the verbose switch.
% \begin{macrocode}
\newif\ifBR@verbose
\@ifundefined{ifHy@verbose}{%
\BR@verbosefalse
}{%
\let\ifBR@verbose\ifHy@verbose
}
\DeclareOption{verbose}{\BR@verbosetrue}
% \end{macrocode}
%
% \subsubsection{Options for way of working}
%
% What is printed depends on how the 3 available items of
% information are used (page number, section number, label).
% \begin{macrocode}
\long\def\page@backref#1#2#3{#1}
\long\def\section@backref#1#2#3{#2}
\long\def\hyper@section@backref#1#2#3{\hyperlink{#3}{#2}}
\long\def\hyper@page@backref#1#2#3{\hyperlink{page.#1}{#1}}
% \end{macrocode}
% \begin{macro}{\backrefpagesname}
% \begin{macro}{\backrefsectionsname}
% Text strings are implemented via \cmd{\...name} commands for
% language independence.
% \begin{macrocode}
\def\backrefpagesname{pages}
\def\backrefsectionsname{sections}
% \end{macrocode}
% \end{macro}
% \end{macro}
% Now the options follows, that can be used without
% package hyperref.
% \begin{macrocode}
\DeclareOption{pageref}{%
\def\backref{\backrefpagesname\ }%
\let\backrefxxx\page@backref
}
\DeclareOption{ref}{%
\def\backref{\backrefsectionsname\ }%
\let\backrefxxx\section@backref
}
% \end{macrocode}
% Set up back-referencing to be hyper links, by page or section.
% \begin{macrocode}
\DeclareOption{hyperref}{%
\def\backref{}\let\backrefxxx\hyper@section@backref
}
\DeclareOption{hyperpageref}{%
\def\backref{}\let\backrefxxx\hyper@page@backref
}
% \end{macrocode}
%
% \subsubsection{Process options}
%
% \begin{macrocode}
\ExecuteOptions{pageref}
\ProcessOptions
% \end{macrocode}
%
% \subsection{The bibliography}
%
% \begin{macro}{\BR@bibitem}
% \begin{macrocode}
\def\BR@bibitem{\@ifnextchar[\BR@@lbibitem\BR@@bibitem}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\def\BR@@lbibitem[#1]#2#3\par{%
\BRorg@bibitem[#1]{#2}#3
\newblock
\begingroup
\csname @safe@activestrue\endcsname
\backref{\csname br@#2\endcsname}%
\endgroup
\par
}%
\def\BR@@bibitem#1#2\par{%
\BRorg@bibitem{#1}#2
\newblock
\begingroup
\csname @safe@activestrue\endcsname
\backref{\csname br@#1\endcsname}%
\endgroup
\par
}
\@ifundefined{newblock}{\def\newblock{\par}}{}
% \end{macrocode}
%
% \subsection{Reading .brf file}
%
% \begin{macro}{\backcite}
% The file |\jobname.brf| collects the back cite informations
% as calls of \cmd{\backcite} with the informations
% in the arguments.
%
% To avoid same entries, it is checked before, whether the entry
% already exists. Only the information needed by \cmd{\backrefxxx}
% is compared.
% \begin{macrocode}
\def\backcite#1#2{%
\@for\x:=#1\do{%
\edef\x{\expandafter\@firstofone\x\@empty}%
\expandafter\ifx\csname br@\x\endcsname\relax
\expandafter\protected@xdef\csname br@\x\endcsname{%
\protect\backrefxxx#2%
}%
\else
\begingroup
\expandafter\def\expandafter\reserved@a\expandafter{%
\backrefxxx#2%
}%
\let\BRorg@backrefxxx\backrefxxx
\global\let\BR@found=N%
\long\def\backrefxxx##1##2##3{%
\expandafter\def\expandafter\reserved@b\expandafter{%
\BRorg@backrefxxx{##1}{##2}{##3}%
}%
\ifx\reserved@a\reserved@b
\global\let\BR@found=Y%
\fi
}%
\setbox\@tempboxa\hbox{\csname br@\x\endcsname}%
\endgroup
\if N\BR@found
\expandafter\protected@xdef\csname br@\x\endcsname{%
\csname br@\x\endcsname, %
\protect\backrefxxx#2%
}%
\fi
\fi
}%
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Initialization}
%
% \begin{macrocode}
\def\@currentHref{}
\AtBeginDocument{%
\let\BRorg@bibitem\bibitem
\let\bibitem\BR@bibitem
\let\BRorg@thebibliography\thebibliography
\def\thebibliography{%
\@starttoc{brf}{}%
\BRorg@thebibliography
}%
\@ifundefined{NAT@parse}{%
\global\let\BRorg@citex\@citex
\global\let\@citex\BR@citex
}{%
\PackageInfo{backref}{** backref set up for natbib **}%
}%
}
% \end{macrocode}
%
% \subsection{Collecting back cite informations}
%
% \begin{macro}{\BR@citex}
% \begin{macrocode}
\def\BR@citex[#1]#2{%
\BRorg@citex[#1]{#2}%
\ifBR@verbose
\PackageInfo{backref}{back cite \string`#2\string'}%
\fi
\Hy@backout{#2}%
}
% \end{macrocode}
% \end{macro}
%
% Grr. for chicago.sty
% \begin{macrocode}
\@ifpackageloaded{chicago}{%
\let\BRorg@citedatax\@citedatax
\def\@citedatax[#1]#2{%
\BRorg@citedatax[#1]{#2}%
\Hy@backout{#2}%
}%
}{}
% \end{macrocode}
% \begin{macro}{\Hy@backout}
% \begin{macrocode}
\def\Hy@backout#1{%
\@bsphack
\ifx\@empty\@currentlabel
\protected@write\@auxout{}{%
\string\@writefile{brf}{%
\string\backcite{#1}{{\thepage}{(document)}{Doc-Start}}%
}%
}%
\else
\protected@write\@auxout{}{%
\string\@writefile{brf}{%
\string\backcite{#1}{{\thepage}{\@currentlabel}{\@currentHref}}%
}%
}%
\fi
\@esphack
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \Finale
%
\endinput
|