%% %% citebackref.sty, version 0.1, 23 May 1996. %% %% For use with LaTeX %% Copyright (C) 1996 by John Maraist, all rights reserved %% %% This code is freely distributable in its entirety, and is made %% available to you under the GNU General License. %% %% Purpose of package: %% To record the pages where citation to specific bibliographic %% entries are made in a LaTeX document. %% %% Interface: %% For a bibliographic entry with label L, the command %% \citebackrefpages{L} %% will generate the list of pages where a that entry has been \cite'd to %% that point in a document, removing duplicate page numbers. %% %% Parameters: %% The four commands below control the formatting of the page printout. %% All can be (relatively) safely redefined. %% %% \citebackrefpageundefined %% Expanded when the given label is undefined. %% Default: {?} %% %% \citebackrefpageempty %% Expanded when the label is defined, but not used. %% Default: {} %% %% \citebackrefpageleader %% Expanded before the list of pages. %% Default: {: p.\,} %% %% \citebackrefpageseparator %% Expanded between each pages in the list. %% Default: {,\penalty\@m\,} %% The "\penalty\@m" part allows a line break. %% %% Limitations: %% (1) The \citebackrefpages{L} command prints only uses between the %% beginning of the document and the invocation of the command: %% subsequent references are not mentioned. A future revision will %% instead use a pass through the .aux file. %% (2) This is a LaTeX hack, not a BibTeX hack. If you use BibTeX to %% generate your bibliography, you must either (a) hand-edit your final %% bibliography or (b) modify your BibTeX style file. Maybe one day I'll %% make standard edits to a few .bst files, but not today... %% (3) Only references using \cite will be noticed. %% %% Default customizable behavior \def\citebackrefpageundefined{?} \def\citebackrefpageempty{} \def\citebackrefpageleader{: p.\,} \def\citebackrefpageseparator{,\penalty\@m\,} %% Debugging options. Uncomment the redefinitions of these commands %% to generate debugging information in the LaTeX interactive output. \def\@@ncEncodeDebug#1{} \def\@@ncDecodeDebug#1{} %\def\@@ncEncodeDebug#1{\typeout{#1}} %\def\@@ncDecodeDebug#1{\typeout{#1}} %% Save the definitions of some existing commands. Hopefully, we can %% be as compatible as possible with other packages. \let\@@oldcite=\cite \let\@@bibitem=\bibitem \let\@@biblabel=\@biblabel %% The main routine and loop. \def\@noteciteone#1% {\@@ncEncodeDebug{ Running noteciteone with #1 on page \arabic{page}.}% \@ifundefined{last@#1}% {\expandafter\xdef\csname last@#1\endcsname{-100}% \@@ncEncodeDebug{ Set last@#1 to \@nameuse{last@#1}.}}% {\@@ncEncodeDebug{ Did not initialize last@#1, set to \@nameuse{last@#1}.}% }% \@ifundefined{cited@#1}% {\@@ncEncodeDebug{ First definition of cited@#1 to \arabic{page}.}% \expandafter\xdef\csname cited@#1\endcsname{\arabic{page}}}% {\ifnum\@nameuse{last@#1}=\thepage% \@@ncEncodeDebug{ Last use \@nameuse{last@#1} same as current page \thepage, skipping with cited@#1 as \@nameuse{cited@#1}.}% \else% \expandafter\xdef\csname cited@#1\endcsname% {\@nameuse{cited@#1}% \citebackrefpageseparator\arabic{page}}% \@@ncEncodeDebug{ Reset cited@#1 to \@nameuse{cited@#1}.}% \fi}% \expandafter\xdef\csname last@#1\endcsname{\thepage}} %% Loop. \def\notecite#1{\@for\@notecitetemp:=#1% \do{\@ifundefined{b@\@notecitetemp}% {\@@ncEncodeDebug{b@\@notecitetemp undefined, skipping to next.}}% {\@@ncEncodeDebug{Calling noteciteone with b@\@notecitetemp.}% \edef\@NCtemp{\@nameuse{b@\@notecitetemp}}% \@noteciteone{\@NCtemp}}}} %% Output interface. \def\citebackrefpages#1% {\@@ncDecodeDebug{Called citebackrefpages with #1}% \@ifundefined{cited@\@nameuse{b@#1}}% {\citebackrefpageundefined% \@@ncDecodeDebug{ b@#1 undefined; exiting.}} {\@ifundefined{cited@\@nameuse{b@#1}}% {\citebackrefpageempty% \@@ncDecodeDebug{ cited@\@nameuse{b@#1} undefined; exiting.}}% {\@@ncDecodeDebug{ cited@\@nameuse{b@#1} defined; proceeding.}% \citebackrefpageleader\@nameuse{cited@\@nameuse{b@#1}}}}} %% Redefinition of \cite. \def\@newcitewithoutoptional#1{\notecite{#1}\@@oldcite{#1}} \def\@newcitewithoptional[#1]#2{\notecite{#2}\@@oldcite[#1]{#2}} \def\cite{\@ifnextchar [{\@newcitewithoptional}{\@newcitewithoutoptional}} % \def\@biblabel#1{\@ifundefined{cited@#1}% % {[#1]}% % {[#1\@ifundefined{backrefeditlabels}{}% % {\citebackrefpageleader\@nameuse{cited@#1}}]}}