\def\fileversion{1.9} \def\filedate{1996/09/29} \def\docdate {1995/02/07} % % \iffalse %% File: backref.dtx Copyright (C) 1995, 1996 David Carlisle, Sebastian Rahtz % % This package is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. % %<*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} % % \fi % \CheckSum{143} % \MakeShortVerb{|} % \tableofcontents % \section{Introduction} % % \section{Usage} % % \StopEventually{} % % \section{The macros} % % \begin{macrocode} %<*package> \ProvidesPackage{backref}[\filedate: bibliographical back referencing, \fileversion] \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}{#1}% } \long\def\hyper@page@backref#1#2#3{% \hyperlink{page.#2}{#2}% } \DeclareOption{pageref}{% \def\backref{pages }% \let\backrefxxx\page@backref } \DeclareOption{ref}{% \def\backref{sections }% \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 } \ExecuteOptions{pageref} \ProcessOptions \@ifundefined{newblock}{\def\newblock{\par}}{} \def\xbibitem{\@ifnextchar[{\@xlbibitem}{\@xbibitem}} \def\@xlbibitem[#1]#2#3\par{% \oldb[#1]{#2}#3 \newblock \backref{\csname br@#2\endcsname}% \par }% \def\@xbibitem#1#2\par{% \oldb{#1}#2 \newblock \backref{\csname br@#1\endcsname}% \par } \def\backcite#1#2{% \@for\x:=#1\do{\expandafter\protected@xdef\csname br@\x\endcsname{% \expandafter\ifx\csname br@\x\endcsname\relax\else \csname br@\x\endcsname, \fi\protect\backrefxxx#2}}} \def\@currentHref{} \AtBeginDocument{% \let\oldb\bibitem \let\bibitem\xbibitem \let\oldbibl\thebibliography \def\thebibliography{\@starttoc{brf}{}\oldbibl} \@ifpackageloaded{natbib}{\typeout{** backref set up for natbib ***}% }{% \global\let\old@citex\@citex \global\let\@citex\x@citex } } \def\x@citex[#1]#2{% \old@citex[#1]{#2}% \Hyper@backout{#2}% } \def\Hyper@backout#1{% \def\@nothing{}% \ifx\@nothing\@currentlabel\else \@bsphack \protected@write\@auxout{}% {\string\@writefile{brf}% {\string\backcite{#1}{{\thepage}{\@currentlabel}{\@currentHref}}}}% \@esphack \fi } % % \end{macrocode} % % \Finale % \endinput