| 1 |
% \iffalse |
| 2 |
%% File: backref.dtx |
| 3 |
%% Copyright (C) 1995-2000 David Carlisle, Sebastian Rahtz, Heiko Oberdiek |
| 4 |
%% 2001-2012 Heiko Oberdiek |
| 5 |
%% 2016-2019 Oberdiek Package Support Group |
| 6 |
%% 2019-2025 The LaTeX Project |
| 7 |
%% https://github.com/latex3/hyperref/issues |
| 8 |
%% |
| 9 |
%% This file is part of the `Hyperref Bundle'. |
| 10 |
%% ------------------------------------------- |
| 11 |
%% |
| 12 |
%% This work may be distributed and/or modified under the |
| 13 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 14 |
%% of this license or (at your option) any later version. |
| 15 |
%% The latest version of this license is in |
| 16 |
%% http://www.latex-project.org/lppl.txt |
| 17 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 18 |
%% version 2005/12/01 or later. |
| 19 |
%% |
| 20 |
%% This work has the LPPL maintenance status `maintained'. |
| 21 |
%% |
| 22 |
%% The Current Maintainer of this work is The LaTeX Project. |
| 23 |
%% |
| 24 |
%% The list of all files belonging to the `Hyperref Bundle' is |
| 25 |
%% given in the file `manifest.txt'. |
| 26 |
% |
| 27 |
%<*dtx> |
| 28 |
\ProvidesFile{backref.dtx} |
| 29 |
%</dtx> |
| 30 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 31 |
%<package>\ProvidesPackage{backref} |
| 32 |
%<driver>\ProvidesFile{backref.drv} |
| 33 |
% \fi |
| 34 |
% \ProvidesFile{backref.dtx} |
| 35 |
[2025-06-21 v1.45 Bibliographical back referencing]% |
| 36 |
% |
| 37 |
% |
| 38 |
% \iffalse |
| 39 |
%<*driver> |
| 40 |
\PassOptionsToPackage{numbered}{hypdoc} |
| 41 |
\documentclass{ltxdoc} |
| 42 |
\usepackage[numbered]{hypdoc} |
| 43 |
\usepackage{bmhydoc} |
| 44 |
\usepackage{backref} |
| 45 |
\EnableCrossrefs |
| 46 |
\CodelineIndex |
| 47 |
\begin{document} |
| 48 |
\GetFileInfo{backref.sty}% |
| 49 |
\title{% |
| 50 |
Back referencing from bibliographical citations% |
| 51 |
\thanks{% |
| 52 |
This file has version number \fileversion, % |
| 53 |
last revised \filedate.% |
| 54 |
}% |
| 55 |
}% |
| 56 |
\author{David Carlisle and Sebastian Rahtz (deceased)\thanks{\url{https://github.com/latex3/hyperref/issues}}}% |
| 57 |
\date{\filedate}% |
| 58 |
\maketitle |
| 59 |
\makeatletter |
| 60 |
\@ifundefined{HyperrefOverview}{}{% |
| 61 |
\HyperrefOverview*% |
| 62 |
}% |
| 63 |
\tableofcontents |
| 64 |
\DocInput{backref.dtx}% |
| 65 |
\PrintIndex |
| 66 |
\end{document} |
| 67 |
%</driver> |
| 68 |
% \fi |
| 69 |
% |
| 70 |
% \MakeShortVerb{|} |
| 71 |
% |
| 72 |
% \section{Introduction} |
| 73 |
% |
| 74 |
% \section{Usage} |
| 75 |
% |
| 76 |
% \subsection{Options} |
| 77 |
% |
| 78 |
% The supported options are given as package options. |
| 79 |
% Few options (e.g. |verbose|, |enable|, |disable|) |
| 80 |
% can be changed after the package is loaded by |
| 81 |
% the macro \cs{backrefsetup}, e.g.: |
| 82 |
% \begin{quote} |
| 83 |
%\begin{verbatim} |
| 84 |
%\usepackage[verbose]{backref} |
| 85 |
%\backrefsetup{verbose=false} |
| 86 |
%\end{verbatim} |
| 87 |
% \end{quote} |
| 88 |
% This macro is available since version 2012/07/24 v1.37. |
| 89 |
% |
| 90 |
% \subsubsection{Options for type of back references} |
| 91 |
% |
| 92 |
% In short the following options set the type of back |
| 93 |
% references. Default is option |pageref|. |
| 94 |
% \begin{quote} |
| 95 |
% \begin{tabular}{@{}ll@{}} |
| 96 |
% |ref| & section number\\ |
| 97 |
% |pageref| & page number\\ |
| 98 |
% |hyperref| & section number as hyper link\\ |
| 99 |
% |hyperpageref| & page number as hyper link |
| 100 |
% \end{tabular} |
| 101 |
% \end{quote} |
| 102 |
% The options that start with |hyper| are intended for |
| 103 |
% the use with package |hyperref|. In this case package |
| 104 |
% |backref| will be loaded automatically if the |hyperref| |
| 105 |
% options |backref| or |pagebackref| are given. Package |
| 106 |
% |hyperref| then loads package |backref| with the appropriate |
| 107 |
% option: |
| 108 |
% \begin{quote} |
| 109 |
% \begin{tabular}{@{}ll@{}} |
| 110 |
% |hyperref| option & |backref| option set by |hyperref|\\ |
| 111 |
% \hline |
| 112 |
% |backref| & |hyperref|\\ |
| 113 |
% |backref=section| & |hyperref|\\ |
| 114 |
% |backref=slide| & |hyperref|\\ |
| 115 |
% |backref=page| & |hyperpageref|\\ |
| 116 |
% |pagebackref| & |hyperpageref| |
| 117 |
% \end{tabular} |
| 118 |
% \end{quote} |
| 119 |
% |
| 120 |
% \subsubsection{Language options} |
| 121 |
% |
| 122 |
% Currently supported options are |english| (|american|, |australian|, |
| 123 |
% |british|, |canadian|, |newzealand|, |UKenglish|, |USenglish|), |
| 124 |
% |german| (|ngerman|, |austrian|, |naustrian|), |
| 125 |
% |french| (|acadian|, |canadien|, |frenchb|, |francais|), |
| 126 |
% |spanish|, and |brazil| (|brazilian|). |
| 127 |
% Default is |english|. |
| 128 |
% |
| 129 |
% \subsubsection{Other options} |
| 130 |
% |
| 131 |
% \begin{description} |
| 132 |
% \item[|verbose|:] |
| 133 |
% A message is written into the |.aux| file for each |
| 134 |
% reference that is found for back citing. |
| 135 |
% \item[|enable|, |disable|:] |
| 136 |
% If a citation should not be back cited, then |
| 137 |
% the recording can be turned off by option |disable| |
| 138 |
% and enabled again afterwards, e.g.: |
| 139 |
% \begin{quote} |
| 140 |
%\begin{verbatim} |
| 141 |
%\backrefsetup{disable}\cite{...}\backrefsetup{enable} |
| 142 |
%\end{verbatim} |
| 143 |
% or |
| 144 |
%\begin{verbatim} |
| 145 |
%\backrefsetup{disable}\listoffigures \backrefsetup{enable} |
| 146 |
%\end{verbatim} |
| 147 |
% \end{quote} |
| 148 |
% Both options are added in version 2012/07/24 v1.37. |
| 149 |
% \end{description} |
| 150 |
% |
| 151 |
% \subsection{Detecting the end of a bibliography entry} |
| 152 |
% |
| 153 |
% Package |backref| has to be able to detect the end of an entry |
| 154 |
% in the bibliography, therefore each \cmd{\bibitem} entry must |
| 155 |
% be ended by an empty line (or a |\par| token). |
| 156 |
% \nopagebreak |
| 157 |
% |
| 158 |
% Example: |
| 159 |
%\begin{quote} |
| 160 |
%\begin{verbatim} |
| 161 |
%\begin{thebibliography}{9} |
| 162 |
%\bibitem[bib:abc] First entry. |
| 163 |
% |
| 164 |
%\bibitem[bib:foo] Second entry. |
| 165 |
% |
| 166 |
%\end{thebibliography} |
| 167 |
%\end{verbatim} |
| 168 |
%\end{quote} |
| 169 |
% Then package |backref| can automatically add hooks |
| 170 |
% for the back references list at the end of the entries. |
| 171 |
% |
| 172 |
% \DescribeMacro{\backrefparscanfalse} |
| 173 |
% \DescribeMacro{\backrefparscantrue} |
| 174 |
% Sometimes it is not appropriate if the entry is read as |
| 175 |
% argument. For example, catcode changes for verbatim stuff |
| 176 |
% do not have the desired effect. Therefore the scan for |
| 177 |
% the \cs{par} token can be disabled by \cs{backrefparscanfalse} |
| 178 |
% before \cs{bibitem} and enabled by \cs{backrefparscantrue} |
| 179 |
% afterwards. |
| 180 |
% |
| 181 |
% \DescribeMacro{\backrefprint} |
| 182 |
% If the scan for the end of the entry is disabled, then package |
| 183 |
% |backref| does not know where to put the back references |
| 184 |
% list. The list is printed by the macro \cs{backrefprint}, thus |
| 185 |
% just call it at the right place. Example: |
| 186 |
%\begin{quote} |
| 187 |
%\begin{verbatim} |
| 188 |
%\backrefparscanfalse % disable scan for entry ending |
| 189 |
%\bibitem[...]{...} |
| 190 |
% ... \verb|...| ... % potentially dangerous stuff |
| 191 |
% ... \url{...} ... |
| 192 |
% \backrefprint % print back reference list here |
| 193 |
%\backrefparscantrue % enable scan again |
| 194 |
%\end{verbatim} |
| 195 |
%\end{quote} |
| 196 |
% |
| 197 |
% \subsection{Formatting of the back references list} |
| 198 |
% |
| 199 |
% The back references list is separated from the entry |
| 200 |
% by \cmd{\newblock}, |
| 201 |
% if the used bibliography package supports this. The package options |
| 202 |
% control the kind of back references (page numbers, sections numbers), |
| 203 |
% whereas the hooks control the formatting. |
| 204 |
% |
| 205 |
% There are two hooks \cmd{\backref} and a new hook \cmd{\backrefalt}, |
| 206 |
% available since version 1.21 of package |backref|. The former one |
| 207 |
% is enabled by default. |
| 208 |
% |
| 209 |
% \subsubsection{Formatting hook \cs{backref}} |
| 210 |
% |
| 211 |
% Macro \cmd{\backref} has a a comma separated |
| 212 |
% list of backref references as first and only argument. |
| 213 |
% With hyperref options only this list will be printed. Without |
| 214 |
% hyperref there is an introductory text, controlled by |
| 215 |
% macros \cmd{\backrefpagesname} or \cmd{\backrefsectionsname}. |
| 216 |
% |
| 217 |
% \subsubsection{Formatting hook \cs{backrefalt}} |
| 218 |
% |
| 219 |
% \cmd{\backrefalt} is a new interface since version 1.21 of package |
| 220 |
% |backref|. It takes four arguments: |
| 221 |
% \begin{enumerate} |
| 222 |
% \item Number of citations without dupes. |
| 223 |
% \item Back references list without dupes. |
| 224 |
% \item Number of all citations (with dupes). |
| 225 |
% \item Back reference list with all entries (with dupes). |
| 226 |
% \end{enumerate} |
| 227 |
% The latter options consider equal entries as one entry. |
| 228 |
% Now \cmd{\backrefalt} can easily be defined with text that |
| 229 |
% depends on the number of citations, for example: |
| 230 |
%\begin{quote} |
| 231 |
%\begin{verbatim} |
| 232 |
%\usepackage[backref]{backref} |
| 233 |
%\renewcommand*{\backref}[1]{}% for backref < 1.33 necessary |
| 234 |
%\renewcommand*{\backrefalt}[4]{% |
| 235 |
% \ifcase #1 % |
| 236 |
% No citations.% |
| 237 |
% \or |
| 238 |
% One citation in section #2.% |
| 239 |
% \else |
| 240 |
% #1 citations in sections #2.% |
| 241 |
% \fi |
| 242 |
%} |
| 243 |
%\end{verbatim} |
| 244 |
%\end{quote} |
| 245 |
% The separation between the list entries are controlled by |
| 246 |
% the following macros: |
| 247 |
% \begin{itemize} |
| 248 |
% \item \cmd{\backrefsep}: inserted between entries except for the |
| 249 |
% next cases, default is ``\verb*|, |''. |
| 250 |
% \item \cmd{\backreftwosep}: inserted between entries in |
| 251 |
% a list of two entries, default is ``\verb*| and~|''. |
| 252 |
% \item \cmd{\backreflastsep}: inserted between the last two |
| 253 |
% entries of a list with more than two entries, default is |
| 254 |
% ``\verb*|, and~|''. |
| 255 |
% \end{itemize} |
| 256 |
% Examples: |
| 257 |
% \begin{quote} |
| 258 |
% \meta{entry1}\\ |
| 259 |
% \meta{entry1} \cmd{\backreftwosep} \meta{entry2}\\ |
| 260 |
% \meta{entry1} \cmd{\backrefsep} \meta{entry2} |
| 261 |
% \cmd{\backreflastsep} \meta{entry3} |
| 262 |
% \end{quote} |
| 263 |
% Since version 1.33 it is not necessary to redefine |
| 264 |
% \backref, it is automatically disabled if \backrefalt |
| 265 |
% is redefined. |
| 266 |
% |
| 267 |
% \subsubsection{Refinement \cs{backrefentrycount}} |
| 268 |
% |
| 269 |
% Since version 1.33 the entries of the distinct list of |
| 270 |
% interface \cs{backrefalt} are wrapped in |
| 271 |
% \cs{backrefentrycount}. The macro is called with two |
| 272 |
% arguments. The first is the backref entry and the second |
| 273 |
% one the citation count of this entry. As default the |
| 274 |
% macro passes the first argument through and ignores the |
| 275 |
% count argument. But it can be redefined, e.g. |
| 276 |
%\begin{quote} |
| 277 |
%\begin{verbatim} |
| 278 |
%\renewcommand*{\backrefalt}[4]{...}% see above |
| 279 |
%\renewcommand*{\backrefentrycount}[2]{% |
| 280 |
% #1% |
| 281 |
% \ifnum#2>1 % |
| 282 |
% ~(#2)% |
| 283 |
% \fi |
| 284 |
%} |
| 285 |
%\end{verbatim} |
| 286 |
%\end{quote} |
| 287 |
% In case of duplicates, the distinct entry is |
| 288 |
% appended by the number of citations in parentheses. |
| 289 |
% |
| 290 |
% \StopEventually{} |
| 291 |
% |
| 292 |
% \section{The macros} |
| 293 |
% Internal command names of this package start with |\BR@|, |
| 294 |
% commands, that store the original meaning of commands, which |
| 295 |
% will be redefined, are prefixed with |\BRorg@|. |
| 296 |
% |
| 297 |
% \subsection{Package identification} |
| 298 |
% \begin{macrocode} |
| 299 |
%<*package> |
| 300 |
% \end{macrocode} |
| 301 |
% |
| 302 |
% \subsection{Options} |
| 303 |
% |
| 304 |
% \begin{macrocode} |
| 305 |
\RequirePackage{kvoptions}[2011/06/30] |
| 306 |
\RequirePackage{kvsetkeys}[2009/07/30] |
| 307 |
\SetupKeyvalOptions{% |
| 308 |
family=backref,% |
| 309 |
prefix=BR@,% |
| 310 |
} |
| 311 |
% \end{macrocode} |
| 312 |
% \begin{macro}{\backrefsetup} |
| 313 |
% \begin{macrocode} |
| 314 |
\newcommand*{\backrefsetup}{\kvsetkeys{backref}} |
| 315 |
% \end{macrocode} |
| 316 |
% \end{macro} |
| 317 |
% |
| 318 |
% \subsubsection{Option verbose} |
| 319 |
% If package hyperref is loaded, then its setting is used as |
| 320 |
% default for the verbose switch. |
| 321 |
% \begin{macrocode} |
| 322 |
\DeclareBoolOption[% |
| 323 |
\@ifundefined{ifHy@verbose}{% |
| 324 |
false% |
| 325 |
}{% |
| 326 |
\ifx\ifHy@verbose\iftrue true\else false\fi |
| 327 |
}% |
| 328 |
]{verbose} |
| 329 |
% \end{macrocode} |
| 330 |
% |
| 331 |
% \subsubsection{Options for way of working} |
| 332 |
% |
| 333 |
% What is printed depends on how the 3 available items of |
| 334 |
% information are used (page number, section number, label). |
| 335 |
% \begin{macrocode} |
| 336 |
\long\def\page@backref#1#2#3{#1} |
| 337 |
\long\def\section@backref#1#2#3{#2} |
| 338 |
\long\def\hyper@section@backref#1#2#3{\hyperlink{#3}{#2}} |
| 339 |
\long\def\hyper@page@backref#1#2#3{\hyperlink{page.#1}{#1}} |
| 340 |
% \end{macrocode} |
| 341 |
% Now the options follows, that can be used without |
| 342 |
% package hyperref. |
| 343 |
% \begin{macrocode} |
| 344 |
\DeclareVoidOption{pageref}{% |
| 345 |
\def\backref{\backrefpagesname\ }% |
| 346 |
\let\backrefxxx\page@backref |
| 347 |
} |
| 348 |
\DeclareVoidOption{ref}{% |
| 349 |
\def\backref{\backrefsectionsname\ }% |
| 350 |
\let\backrefxxx\section@backref |
| 351 |
} |
| 352 |
% \end{macrocode} |
| 353 |
% Set up back-referencing to be hyper links, by page or section. |
| 354 |
% \begin{macrocode} |
| 355 |
\DeclareVoidOption{hyperref}{% |
| 356 |
\def\backref{}\let\backrefxxx\hyper@section@backref |
| 357 |
} |
| 358 |
\DeclareVoidOption{hyperpageref}{% |
| 359 |
\def\backref{}\let\backrefxxx\hyper@page@backref |
| 360 |
} |
| 361 |
% \end{macrocode} |
| 362 |
% Recording the back references in the auxiliary file can |
| 363 |
% be enabled and disabled by the following options. |
| 364 |
% \begin{macrocode} |
| 365 |
\DeclareBoolOption[true]{enable} |
| 366 |
\DeclareComplementaryOption{disable}{enable} |
| 367 |
% \end{macrocode} |
| 368 |
% |
| 369 |
% \subsubsection{Language options} |
| 370 |
% |
| 371 |
% \begin{macrocode} |
| 372 |
\def\backrefenglish{% |
| 373 |
\def\backrefpagesname{pages}% |
| 374 |
\def\backrefsectionsname{sections}% |
| 375 |
\def\backrefsep{, }% |
| 376 |
\def\backreftwosep{ and~}% |
| 377 |
\def\backreflastsep{, and~}% |
| 378 |
} |
| 379 |
\def\backrefgerman{% |
| 380 |
\def\backrefpagesname{Seiten}% |
| 381 |
\def\backrefsectionsname{Abschnitte}% |
| 382 |
\def\backrefsep{, }% |
| 383 |
\def\backreftwosep{ und~}% |
| 384 |
\def\backreflastsep{ und~}% |
| 385 |
} |
| 386 |
\def\backreffrench{% |
| 387 |
\def\backrefpagesname{pages}% |
| 388 |
\def\backrefsectionsname{sections}% |
| 389 |
\def\backrefsep{, }% |
| 390 |
\def\backreftwosep{ et~}% |
| 391 |
\def\backreflastsep{ et~}% |
| 392 |
} |
| 393 |
\def\backrefspanish{% |
| 394 |
\def\backrefpagesname{p\'aginas}% |
| 395 |
\def\backrefsectionsname{secciones}% |
| 396 |
\def\backrefsep{, }% |
| 397 |
\def\backreftwosep{ y~}% |
| 398 |
\def\backreflastsep{ y~}% |
| 399 |
} |
| 400 |
\def\backrefbrazil{% |
| 401 |
\def\backrefpagesname{p\'aginas}% |
| 402 |
\def\backrefsectionsname{se\c c\~oes}% |
| 403 |
\def\backrefsep{, }% |
| 404 |
\def\backreftwosep{ e~}% |
| 405 |
\def\backreflastsep{ e~}% |
| 406 |
} |
| 407 |
\def\backrefafrikaans{% |
| 408 |
\def\backrefpagesname{bladsye}% |
| 409 |
\def\backrefsectionsname{afdelings}% |
| 410 |
\def\backrefsep{, }% |
| 411 |
\def\backreftwosep{ en~}% |
| 412 |
\def\backreflastsep{ en~}% |
| 413 |
} |
| 414 |
\def\backrefitalian{% |
| 415 |
\def\backrefpagesname{pagine}% |
| 416 |
\def\backrefsectionsname{sezioni}% |
| 417 |
\def\backrefsep{, }% |
| 418 |
\def\backreftwosep{ e~}% |
| 419 |
\def\backreflastsep{ e~}% |
| 420 |
}% |
| 421 |
% \end{macrocode} |
| 422 |
% Instead of package babel's definition of \cmd{\addto} the |
| 423 |
% implementation of package varioref is used. Additionally |
| 424 |
% argument |#1| is checked for \cmd{\relax}. |
| 425 |
% \begin{macrocode} |
| 426 |
\def\BR@addto#1#2{% |
| 427 |
#2% |
| 428 |
\@temptokena{#2}% |
| 429 |
\ifx#1\relax |
| 430 |
\let#1\@empty |
| 431 |
\fi |
| 432 |
\ifx#1\@undefined |
| 433 |
\edef#1{\the\@temptokena}% |
| 434 |
\else |
| 435 |
\toks@\expandafter{#1}% |
| 436 |
\edef#1{\the\toks@\the\@temptokena}% |
| 437 |
\fi |
| 438 |
\@temptokena{}\toks@\@temptokena |
| 439 |
} |
| 440 |
% \end{macrocode} |
| 441 |
% \begin{macrocode} |
| 442 |
\def\BR@DeclareLang#1#2{% |
| 443 |
\begingroup |
| 444 |
\edef\x##1##2{% |
| 445 |
\noexpand\ifx##2\relax |
| 446 |
\errmessage{No definitions for language `#2' found!}% |
| 447 |
\noexpand\fi |
| 448 |
\endgroup |
| 449 |
\noexpand\DeclareVoidOption{#1}{% |
| 450 |
\noexpand\BR@addto{\noexpand##1}{\noexpand##2}% |
| 451 |
}% |
| 452 |
}% |
| 453 |
\expandafter\x\csname extras#1\expandafter\endcsname |
| 454 |
\csname backref#2\expandafter\endcsname |
| 455 |
} |
| 456 |
\BR@DeclareLang{english}{english} |
| 457 |
\BR@DeclareLang{american}{english} |
| 458 |
\BR@DeclareLang{australian}{english} |
| 459 |
\BR@DeclareLang{british}{english} |
| 460 |
\BR@DeclareLang{canadian}{english} |
| 461 |
\BR@DeclareLang{newzealand}{english} |
| 462 |
\BR@DeclareLang{UKenglish}{english} |
| 463 |
\BR@DeclareLang{USenglish}{english} |
| 464 |
\BR@DeclareLang{german}{german} |
| 465 |
\BR@DeclareLang{ngerman}{german} |
| 466 |
\BR@DeclareLang{austrian}{german} |
| 467 |
\BR@DeclareLang{naustrian}{german} |
| 468 |
\BR@DeclareLang{french}{french} |
| 469 |
\BR@DeclareLang{acadian}{french} |
| 470 |
\BR@DeclareLang{canadien}{french} |
| 471 |
\BR@DeclareLang{frenchb}{french} |
| 472 |
\BR@DeclareLang{francais}{french} |
| 473 |
\BR@DeclareLang{spanish}{spanish} |
| 474 |
\BR@DeclareLang{brazil}{brazil} |
| 475 |
\BR@DeclareLang{brazilian}{brazil} |
| 476 |
\BR@DeclareLang{afrikaans}{afrikaans} |
| 477 |
\BR@DeclareLang{italian}{italian} |
| 478 |
% \end{macrocode} |
| 479 |
% Default is the english version: |
| 480 |
% \begin{macrocode} |
| 481 |
\backrefenglish |
| 482 |
% \end{macrocode} |
| 483 |
% |
| 484 |
% \subsubsection{Process options} |
| 485 |
% |
| 486 |
% \begin{macrocode} |
| 487 |
\backrefsetup{pageref} |
| 488 |
\ProcessKeyvalOptions* |
| 489 |
% \end{macrocode} |
| 490 |
% |
| 491 |
% \begin{macro}{\BR@DisableOption} |
| 492 |
% \begin{macrocode} |
| 493 |
\def\BR@DisableOption#1{% |
| 494 |
\DisableKeyvalOption[% |
| 495 |
action=warning,% |
| 496 |
package=backref,% |
| 497 |
]{backref}{#1}% |
| 498 |
} |
| 499 |
% \end{macrocode} |
| 500 |
% \end{macro} |
| 501 |
% \begin{macrocode} |
| 502 |
\BR@DisableOption{ref} |
| 503 |
\BR@DisableOption{pageref} |
| 504 |
\BR@DisableOption{hyperref} |
| 505 |
\BR@DisableOption{hyperpageref} |
| 506 |
% \end{macrocode} |
| 507 |
% |
| 508 |
% \subsection{The bibliography} |
| 509 |
% |
| 510 |
% \begin{macro}{\ifbackrefparscan} |
| 511 |
% \begin{macrocode} |
| 512 |
\newif\ifbackrefparscan |
| 513 |
\backrefparscantrue |
| 514 |
% \end{macrocode} |
| 515 |
% \end{macro} |
| 516 |
% |
| 517 |
% \begin{macro}{\ifBR@BackrefAlt} |
| 518 |
% \begin{macrocode} |
| 519 |
\newif\ifBR@BackrefAlt |
| 520 |
% \end{macrocode} |
| 521 |
% \end{macro} |
| 522 |
% |
| 523 |
% \begin{macro}{\BR@bibitem} |
| 524 |
% \begin{macrocode} |
| 525 |
\def\BR@bibitem{% |
| 526 |
\ifbackrefparscan |
| 527 |
\expandafter\@ifnextchar\expandafter[\expandafter |
| 528 |
\BR@@lbibitem\expandafter\BR@@bibitem |
| 529 |
\else |
| 530 |
\expandafter\@ifnextchar\expandafter[\expandafter |
| 531 |
\BR@@@lbibitem\expandafter\BR@@@bibitem |
| 532 |
\fi |
| 533 |
} |
| 534 |
% \end{macrocode} |
| 535 |
% \end{macro} |
| 536 |
% \begin{macrocode} |
| 537 |
\def\BR@@lbibitem[#1]#2#3\par{% |
| 538 |
\let\backrefprint\BR@backrefprint |
| 539 |
\BRorg@bibitem[{#1}]{#2}#3% |
| 540 |
\BR@backref{#2}% |
| 541 |
}% |
| 542 |
\def\BR@@bibitem#1#2\par{% |
| 543 |
\let\backrefprint\BR@backrefprint |
| 544 |
\BRorg@bibitem{#1}#2% |
| 545 |
\BR@backref{#1}% |
| 546 |
} |
| 547 |
\def\BR@@@lbibitem[#1]#2{% |
| 548 |
\def\backrefprint{\BR@backref{#2}}% |
| 549 |
\BRorg@bibitem[{#1}]{#2}% |
| 550 |
} |
| 551 |
\def\BR@@@bibitem#1{% |
| 552 |
\def\backrefprint{\BR@backref{#1}}% |
| 553 |
\BRorg@bibitem{#1}% |
| 554 |
} |
| 555 |
\def\BR@backrefprint{% |
| 556 |
\PackageError{backref}{% |
| 557 |
\string\backrefprint\space is only available after \string\bibitem |
| 558 |
\MessageBreak |
| 559 |
with setting \string\backrefparscanfalse |
| 560 |
}\@ehc |
| 561 |
} |
| 562 |
\let\backrefprint\BR@backrefprint |
| 563 |
\def\BR@backref#1{% |
| 564 |
\newblock |
| 565 |
\begingroup |
| 566 |
\csname @safe@activestrue\endcsname |
| 567 |
\expandafter\providecommand\csname brc@#1\endcsname{0}% |
| 568 |
\expandafter\providecommand\csname brcd@#1\endcsname{0}% |
| 569 |
\csname @safe@activesfalse\expandafter\endcsname |
| 570 |
\ifBR@BackrefAlt |
| 571 |
\ifx\backrefentrycount\BR@BackrefEntryCountUnused |
| 572 |
\else |
| 573 |
\BR@PopulateEntryCount{#1}% |
| 574 |
\fi |
| 575 |
\expandafter\backrefalt\csname brc@#1\expandafter\endcsname |
| 576 |
\csname brl@#1\expandafter\endcsname |
| 577 |
\csname brcd@#1\expandafter\endcsname |
| 578 |
\csname brld@#1\endcsname |
| 579 |
\else |
| 580 |
\expandafter\backref\csname br@#1\expandafter\endcsname |
| 581 |
\fi |
| 582 |
\endgroup |
| 583 |
\par |
| 584 |
} |
| 585 |
\@ifundefined{newblock}{\def\newblock{\par}}{} |
| 586 |
\let\BR@Unused\@empty |
| 587 |
\def\BR@BackrefAltUnused#1#2#3#4{\BR@Unused} |
| 588 |
\@ifundefined{backrefalt}{% |
| 589 |
\let\backrefalt\BR@BackrefAltUnused |
| 590 |
}{} |
| 591 |
\def\BR@BackrefEntryCountUnused#1#2{\BR@Unused#1} |
| 592 |
\@ifundefined{backrefentrycount}{% |
| 593 |
\let\backrefentrycount\BR@BackrefEntryCountUnused |
| 594 |
}{} |
| 595 |
% \end{macrocode} |
| 596 |
% |
| 597 |
% \subsection{Reading .brf file} |
| 598 |
% |
| 599 |
% \begin{macro}{\backcite} |
| 600 |
% The file |\jobname.brf| collects the back cite information |
| 601 |
% as calls of \cmd{\backcite} with the information |
| 602 |
% in the arguments. |
| 603 |
% |
| 604 |
% The first argument of macro \cmd{\backcite} is the citation |
| 605 |
% label, the second parameter contains the page number |
| 606 |
% (\cmd{\thepage}), the current label of the citation |
| 607 |
% (\cmd{\@currentlabel}), and the current anchor name |
| 608 |
% (\cmd{\@currentHref}). Example for a citation at the |
| 609 |
% first page in second section: |
| 610 |
%\begin{verbatim} |
| 611 |
%\backcite {bib:abc}{{1}{2}{section.2}} |
| 612 |
%\end{verbatim} |
| 613 |
% |
| 614 |
% While the file |\jobname.brf| is read, the information are |
| 615 |
% collected and stored in macros whose names are built by the |
| 616 |
% citation label \meta{label}: |
| 617 |
% \begin{quote} |
| 618 |
% \begin{tabular}{@{}ll@{}} |
| 619 |
% |\br@|\meta{label} & list, entries separated by comma without dupes\\ |
| 620 |
% |\brc@|\meta{label} & number of citations without dupes\\ |
| 621 |
% |\brl@|\meta{label} & backref list without dupes\\ |
| 622 |
% |\brcd@|\meta{label} & number of all citations (with dupes)\\ |
| 623 |
% |\brld@|\meta{label} & backref list with all entries (with dupes) |
| 624 |
% \end{tabular} |
| 625 |
% \end{quote} |
| 626 |
% What are ``dupes''? An instance: you have three references to |
| 627 |
% an entry in the bibliography on the first page: |
| 628 |
%\begin{verbatim} |
| 629 |
%\backcite {bib:abc}{{1}{1}{section.1}} |
| 630 |
%\backcite {bib:abc}{{1}{1}{section.1}} |
| 631 |
%\backcite {bib:abc}{{1}{2}{section.2}} |
| 632 |
%\end{verbatim} |
| 633 |
% Then the whole backref list with option |pageref| would print, e.g.: |
| 634 |
% \begin{quote} |
| 635 |
% Entry for |bib:abc|. Cited on pages 1, 1, 1. |
| 636 |
% \end{quote} |
| 637 |
% Without dupes the entries with the same page number would be removed, |
| 638 |
% e.g.: |
| 639 |
% \begin{quote} |
| 640 |
% Entry for |bib:abc|. Cited on page 1. |
| 641 |
% \end{quote} |
| 642 |
% Also the third entry is removed, because it has the same page number. |
| 643 |
% For the comparison only these pieces of information are considered |
| 644 |
% that will be used later by \cmd{\backrefxxx}. With option |
| 645 |
% |pageref| macro \cmd{\backrefxxx} becomes \cmd{\page@backref} that |
| 646 |
% throws away the second and third argument and only uses the first |
| 647 |
% argument with the page number. To be more precise, the first |
| 648 |
% expansion of \cmd{\backrefxxx} is used in comparison. If some |
| 649 |
% arguments are used here, but later omitted, then this will not |
| 650 |
% be detected. |
| 651 |
% |
| 652 |
% \begin{macro}{\backrefxxxdupe} |
| 653 |
% With option |hyperref| you will get two entries |
| 654 |
% in the following example because the second entry differs in the |
| 655 |
% link information, so the result will be the same section number, |
| 656 |
% but as different links. |
| 657 |
%\begin{verbatim} |
| 658 |
%\backref {bib:abc}{{1}{1}{section.1}} |
| 659 |
%\backref {bib:abc}{{1}{1}{equation.1}} |
| 660 |
%\end{verbatim} |
| 661 |
% Macro \cmd{\backrefxxxdupe} will be used |
| 662 |
% in the comparison test if it is defined. Thus you can provide a |
| 663 |
% definition in this case as follows: |
| 664 |
%\begin{verbatim} |
| 665 |
%\newcommand*{\backrefxxxdupe}[3]{#2} |
| 666 |
%\end{verbatim} |
| 667 |
% Then only the section number is interpreted, but not the anchor name. |
| 668 |
% \end{macro} |
| 669 |
% |
| 670 |
% To avoid same entries, it is checked before, whether the entry |
| 671 |
% already exists. Only the information needed by \cmd{\backrefxxx} |
| 672 |
% is compared. |
| 673 |
% \begin{macrocode} |
| 674 |
\def\backcite#1#2{% |
| 675 |
\@for\x:=#1\do{% |
| 676 |
\begingroup |
| 677 |
\csname @safe@activestrue\endcsname |
| 678 |
\edef\x{\endgroup |
| 679 |
\def\noexpand\x{\expandafter\@firstofone\x\@empty}% |
| 680 |
}% |
| 681 |
\x |
| 682 |
% \end{macrocode} |
| 683 |
% Now macro \cmd{\x} contains the citation label name. |
| 684 |
% \begin{macrocode} |
| 685 |
\expandafter\ifx\csname br@\x\endcsname\relax |
| 686 |
% \end{macrocode} |
| 687 |
% Initialization, fill in the first entry. |
| 688 |
% \begin{macrocode} |
| 689 |
\expandafter\protected@xdef\csname br@\x\endcsname{% |
| 690 |
\protect\backrefxxx#2% |
| 691 |
}% |
| 692 |
\ifBR@BackrefAlt |
| 693 |
\global\expandafter\let\csname brl@\x\expandafter\endcsname |
| 694 |
\csname br@\x\endcsname |
| 695 |
\global\expandafter\let\csname brld@\x\expandafter\endcsname |
| 696 |
\csname br@\x\endcsname |
| 697 |
\expandafter\gdef\csname brc@\x\endcsname{1}% |
| 698 |
\expandafter\gdef\csname brcd@\x\endcsname{1}% |
| 699 |
\fi |
| 700 |
\else |
| 701 |
% \end{macrocode} |
| 702 |
% Fill in further entry. But check for dupe first. |
| 703 |
% \begin{macrocode} |
| 704 |
\begingroup |
| 705 |
\@ifundefined{backrefxxxdupe}{}{\let\backrefxxx\backrefxxxdupe}% |
| 706 |
\expandafter\def\expandafter\reserved@a\expandafter{% |
| 707 |
\backrefxxx#2% |
| 708 |
}% |
| 709 |
\let\BRorg@backrefxxx\backrefxxx |
| 710 |
\global\let\BR@found=N% |
| 711 |
\long\def\backrefxxx##1##2##3{% |
| 712 |
\expandafter\def\expandafter\reserved@b\expandafter{% |
| 713 |
\BRorg@backrefxxx{##1}{##2}{##3}% |
| 714 |
}% |
| 715 |
\ifx\reserved@a\reserved@b |
| 716 |
\global\let\BR@found=Y% |
| 717 |
\fi |
| 718 |
}% |
| 719 |
\setbox\@tempboxa\hbox{\csname br@\x\endcsname}% |
| 720 |
\endgroup |
| 721 |
\let\backrefsep\relax |
| 722 |
\def\backreftwosep{\backrefsep}% |
| 723 |
\def\backreflastsep{\backrefsep}% |
| 724 |
\if N\BR@found |
| 725 |
\expandafter\protected@xdef\csname br@\x\endcsname{% |
| 726 |
\csname br@\x\endcsname, % |
| 727 |
\protect\backrefxxx#2% |
| 728 |
}% |
| 729 |
\ifBR@BackrefAlt |
| 730 |
\expandafter\protected@xdef\csname brl@\x\endcsname{% |
| 731 |
\csname brl@\x\endcsname |
| 732 |
\ifnum\@nameuse{brc@\x}=1 % |
| 733 |
\noexpand\backreftwosep |
| 734 |
\else |
| 735 |
\noexpand\backreflastsep |
| 736 |
\fi |
| 737 |
\protect\backrefxxx#2% |
| 738 |
}% |
| 739 |
\count@=\@nameuse{brc@\x}\relax |
| 740 |
\advance\count@ by 1 % |
| 741 |
\expandafter\xdef\csname brc@\x\endcsname{\the\count@}% |
| 742 |
\fi |
| 743 |
\fi |
| 744 |
\ifBR@BackrefAlt |
| 745 |
\expandafter\protected@xdef\csname brld@\x\endcsname{% |
| 746 |
\csname brld@\x\endcsname |
| 747 |
\ifnum\@nameuse{brcd@\x}=1 % |
| 748 |
\noexpand\backreftwosep |
| 749 |
\else |
| 750 |
\noexpand\backreflastsep |
| 751 |
\fi |
| 752 |
\protect\backrefxxx#2% |
| 753 |
}% |
| 754 |
\count@=\@nameuse{brcd@\x}\relax |
| 755 |
\advance\count@ by 1 % |
| 756 |
\expandafter\xdef\csname brcd@\x\endcsname{\the\count@}% |
| 757 |
\fi |
| 758 |
\fi |
| 759 |
}% |
| 760 |
} |
| 761 |
% \end{macrocode} |
| 762 |
% \end{macro} |
| 763 |
% |
| 764 |
% \begin{macro}{\BR@PopulateEntryCount} |
| 765 |
% \begin{macrocode} |
| 766 |
\def\BR@PopulateEntryCount#1{% |
| 767 |
\begingroup |
| 768 |
\toks@{}% |
| 769 |
\def\backrefsep{% |
| 770 |
\toks@\expandafter{\the\toks@\backrefsep}% |
| 771 |
}% |
| 772 |
\def\backreftwosep{% |
| 773 |
\toks@\expandafter{\the\toks@\backreftwosep}% |
| 774 |
}% |
| 775 |
\def\backreflastsep{% |
| 776 |
\toks@\expandafter{\the\toks@\backreflastsep}% |
| 777 |
}% |
| 778 |
\def\protect{}% |
| 779 |
\let\BR@backrefxxx\backrefxxx |
| 780 |
\let\backrefxxx\BR@PopulateBackrefxxx |
| 781 |
\def\BR@name{#1}% |
| 782 |
\csname brl@#1\endcsname |
| 783 |
\expandafter\xdef\csname brl@#1\endcsname{\the\toks@}% |
| 784 |
\endgroup |
| 785 |
} |
| 786 |
% \end{macrocode} |
| 787 |
% \end{macro} |
| 788 |
% \begin{macro}{\BR@PopulateBackrefxxx} |
| 789 |
% \begin{macrocode} |
| 790 |
\def\BR@PopulateBackrefxxx#1#2#3{% |
| 791 |
\expandafter\def\expandafter\BR@tempa\expandafter{% |
| 792 |
\BR@backrefxxx{#1}{#2}{#3}% |
| 793 |
}% |
| 794 |
\begingroup |
| 795 |
\count@=\z@ |
| 796 |
\def\backrefsep{}% |
| 797 |
\def\backreftwosep{}% |
| 798 |
\def\backreflastsep{}% |
| 799 |
\let\backrefxxx\BR@@PopulateBackrefxxx |
| 800 |
\csname brld@\BR@name\endcsname |
| 801 |
\toks\tw@={\backrefxxx{#1}{#2}{#3}}% |
| 802 |
\edef\x{\endgroup |
| 803 |
\toks@{% |
| 804 |
\the\toks@ |
| 805 |
\noexpand\backrefentrycount{% |
| 806 |
\the\toks\tw@ |
| 807 |
}{\the\count@}% |
| 808 |
}% |
| 809 |
}% |
| 810 |
\x |
| 811 |
} |
| 812 |
% \end{macrocode} |
| 813 |
% \end{macro} |
| 814 |
% \begin{macro}{\BR@@PopulateBackrefxxx} |
| 815 |
% \begin{macrocode} |
| 816 |
\def\BR@@PopulateBackrefxxx#1#2#3{% |
| 817 |
\expandafter\def\expandafter\BR@tempb\expandafter{% |
| 818 |
\BR@backrefxxx{#1}{#2}{#3}% |
| 819 |
}% |
| 820 |
\ifx\BR@tempa\BR@tempb |
| 821 |
\advance\count@\@ne |
| 822 |
\fi |
| 823 |
} |
| 824 |
% \end{macrocode} |
| 825 |
% \end{macro} |
| 826 |
% |
| 827 |
% \subsection{Initialization} |
| 828 |
% |
| 829 |
% \begin{macrocode} |
| 830 |
\def\@currentHref{} |
| 831 |
\AtBeginDocument{% |
| 832 |
\let\BRorg@bibitem\bibitem |
| 833 |
\let\bibitem\BR@bibitem |
| 834 |
\let\BRorg@thebibliography\thebibliography |
| 835 |
\def\thebibliography{% |
| 836 |
\BR@starttoc |
| 837 |
\BRorg@thebibliography |
| 838 |
}% |
| 839 |
\@ifundefined{NAT@parse}{% |
| 840 |
\global\let\BRorg@citex\@citex |
| 841 |
\global\let\@citex\BR@citex |
| 842 |
}{% |
| 843 |
\@ifpackageloaded{hyperref}{}{% |
| 844 |
\def\hyper@natlinkstart#1{\Hy@backout{#1}}% |
| 845 |
}% |
| 846 |
\PackageInfo{backref}{** backref set up for natbib **}% |
| 847 |
}% |
| 848 |
} |
| 849 |
% \end{macrocode} |
| 850 |
% \begin{macro}{\BR@starttoc} |
| 851 |
% \begin{macrocode} |
| 852 |
\def\BR@starttoc{% |
| 853 |
\ifx\backrefalt\BR@BackrefAltUnused |
| 854 |
\global\BR@BackrefAltfalse |
| 855 |
\else |
| 856 |
\global\BR@BackrefAlttrue |
| 857 |
\fi |
| 858 |
\begingroup |
| 859 |
\makeatletter |
| 860 |
\@input{\jobname.brf}% |
| 861 |
\if@filesw |
| 862 |
\@ifundefined{tf@brf}{% |
| 863 |
\expandafter\newwrite\csname tf@brf\endcsname |
| 864 |
}{}% |
| 865 |
\@ifundefined{tf@brf@open}{% |
| 866 |
\BR@RerunFileCheck |
| 867 |
\immediate\openout\csname tf@brf\endcsname\jobname.brf\relax |
| 868 |
\gdef\tf@brf@open{}% |
| 869 |
}{}% |
| 870 |
\fi |
| 871 |
\@nobreakfalse |
| 872 |
\endgroup |
| 873 |
} |
| 874 |
% \end{macrocode} |
| 875 |
% \end{macro} |
| 876 |
% |
| 877 |
% \subsection{Collecting back cite information} |
| 878 |
% |
| 879 |
% \begin{macro}{\BR@citex} |
| 880 |
% \begin{macrocode} |
| 881 |
\def\BR@citex[#1]#2{% |
| 882 |
\BRorg@citex[{#1}]{#2}% |
| 883 |
\Hy@backout{#2}% |
| 884 |
} |
| 885 |
% \end{macrocode} |
| 886 |
% \end{macro} |
| 887 |
% |
| 888 |
% Grr. for chicago.sty |
| 889 |
% \begin{macrocode} |
| 890 |
\@ifpackageloaded{chicago}{% |
| 891 |
\let\BRorg@citedatax\@citedatax |
| 892 |
\def\@citedatax[#1]#2{% |
| 893 |
\BRorg@citedatax[{#1}]{#2}% |
| 894 |
\Hy@backout{#2}% |
| 895 |
}% |
| 896 |
}{} |
| 897 |
% \end{macrocode} |
| 898 |
% \begin{macro}{\Hy@backout} |
| 899 |
% \begin{macrocode} |
| 900 |
\def\Hy@backout#1{% |
| 901 |
\@bsphack |
| 902 |
\ifBR@enable |
| 903 |
\ifBR@verbose |
| 904 |
\PackageInfo{backref}{Back cite \string`#1\string'}% |
| 905 |
\fi |
| 906 |
\ifx\@empty\@currentlabel |
| 907 |
\protected@write\@auxout{}{% |
| 908 |
\string\@writefile{brf}{% |
| 909 |
\string\backcite{#1}{{\thepage}{(document)}{Doc-Start}}% |
| 910 |
}% |
| 911 |
}% |
| 912 |
\else |
| 913 |
\protected@write\@auxout{}{% |
| 914 |
\string\@writefile{brf}{% |
| 915 |
\string\backcite{#1}{{\thepage}{\@currentlabel}{\@currentHref}}% |
| 916 |
}% |
| 917 |
}% |
| 918 |
\fi |
| 919 |
\else |
| 920 |
\ifBR@verbose |
| 921 |
\PackageInfo{backref}{Disabled back cite \string`#1\string'}% |
| 922 |
\fi |
| 923 |
\fi |
| 924 |
\@esphack |
| 925 |
} |
| 926 |
% \end{macrocode} |
| 927 |
% \end{macro} |
| 928 |
% |
| 929 |
% \subsection{Rerun warning} |
| 930 |
% |
| 931 |
% \begin{macro}{\BR@RerunFileCheck} |
| 932 |
% The following code computes a MD5 sum and the file size of the |
| 933 |
% |.brf| file at the begin and the end of the document and compares |
| 934 |
% them. A rerun warning is given, if they do not match. |
| 935 |
% This method requires pdf\TeX\ or Lua\TeX. The method fails, |
| 936 |
% if the MD5 sum and the file size are the same for |
| 937 |
% a changed |.brf| file (it's probably very seldom). |
| 938 |
% \begin{macrocode} |
| 939 |
\RequirePackage{rerunfilecheck}[2009/12/10] |
| 940 |
\def\BR@RerunFileCheck{% |
| 941 |
\RerunFileCheck{\jobname.brf}{% |
| 942 |
\@ifundefined{tf@brf@open}{% |
| 943 |
}{% |
| 944 |
\immediate\closeout\tf@brf |
| 945 |
}% |
| 946 |
}{% |
| 947 |
Rerun to get bibliographical references right% |
| 948 |
}% |
| 949 |
} |
| 950 |
% \end{macrocode} |
| 951 |
% \end{macro} |
| 952 |
% |
| 953 |
% \begin{macrocode} |
| 954 |
%</package> |
| 955 |
% \end{macrocode} |
| 956 |
% |
| 957 |
% \Finale |
| 958 |
% |
| 959 |
\endinput |