Debian Codegraph @

texmf-dist/tex/latex/hyperref/backref.sty

raw
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 %% Copyright
10 %% 1995-2001 Sebastian Rahtz, with portions written by David Carlisle and Heiko Oberdiek
11 %% 2001-2015 Heiko Oberdiek
12 %% 2016-2019 Oberdiek Package Support Group
13 %% 2019-2026 LaTeX Project
14 %% https://github.com/latex3/hyperref/issues
15 %%
16 %% This file is part of the `Hyperref Bundle'.
17 %% -------------------------------------------
18 %%
19 %% This work may be distributed and/or modified under the
20 %% conditions of the LaTeX Project Public License, either version 1.3
21 %% of this license or (at your option) any later version.
22 %% The latest version of this license is in
23 %% http://www.latex-project.org/lppl.txt
24 %% and version 1.3 or later is part of all distributions of LaTeX
25 %% version 2005/12/01 or later.
26 %%
27 %% This work has the LPPL maintenance status `maintained'.
28 %%
29 %% The Current Maintainer of this work is the LaTeX Project.
30 %%
31 %% The list of all files belonging to the `Hyperref Bundle' is
32 %% given in the file `manifest.txt'.
33 %%
34 %% File: backref.dtx
35 %% Copyright (C) 1995-2000 David Carlisle, Sebastian Rahtz, Heiko Oberdiek
36 %% 2001-2012 Heiko Oberdiek
37 %% 2016-2019 Oberdiek Package Support Group
38 %% 2019-2025 The LaTeX Project
39 %% https://github.com/latex3/hyperref/issues
40 %%
41 %% This file is part of the `Hyperref Bundle'.
42 %% -------------------------------------------
43 %%
44 %% This work may be distributed and/or modified under the
45 %% conditions of the LaTeX Project Public License, either version 1.3
46 %% of this license or (at your option) any later version.
47 %% The latest version of this license is in
48 %% http://www.latex-project.org/lppl.txt
49 %% and version 1.3 or later is part of all distributions of LaTeX
50 %% version 2005/12/01 or later.
51 %%
52 %% This work has the LPPL maintenance status `maintained'.
53 %%
54 %% The Current Maintainer of this work is The LaTeX Project.
55 %%
56 %% The list of all files belonging to the `Hyperref Bundle' is
57 %% given in the file `manifest.txt'.
58 \NeedsTeXFormat{LaTeX2e}
59 \ProvidesPackage{backref}
60 [2025-06-21 v1.45 Bibliographical back referencing]%
61 \RequirePackage{kvoptions}[2011/06/30]
62 \RequirePackage{kvsetkeys}[2009/07/30]
63 \SetupKeyvalOptions{%
64 family=backref,%
65 prefix=BR@,%
66 }
67 \newcommand*{\backrefsetup}{\kvsetkeys{backref}}
68 \DeclareBoolOption[%
69 \@ifundefined{ifHy@verbose}{%
70 false%
71 }{%
72 \ifx\ifHy@verbose\iftrue true\else false\fi
73 }%
74 ]{verbose}
75 \long\def\page@backref#1#2#3{#1}
76 \long\def\section@backref#1#2#3{#2}
77 \long\def\hyper@section@backref#1#2#3{\hyperlink{#3}{#2}}
78 \long\def\hyper@page@backref#1#2#3{\hyperlink{page.#1}{#1}}
79 \DeclareVoidOption{pageref}{%
80 \def\backref{\backrefpagesname\ }%
81 \let\backrefxxx\page@backref
82 }
83 \DeclareVoidOption{ref}{%
84 \def\backref{\backrefsectionsname\ }%
85 \let\backrefxxx\section@backref
86 }
87 \DeclareVoidOption{hyperref}{%
88 \def\backref{}\let\backrefxxx\hyper@section@backref
89 }
90 \DeclareVoidOption{hyperpageref}{%
91 \def\backref{}\let\backrefxxx\hyper@page@backref
92 }
93 \DeclareBoolOption[true]{enable}
94 \DeclareComplementaryOption{disable}{enable}
95 \def\backrefenglish{%
96 \def\backrefpagesname{pages}%
97 \def\backrefsectionsname{sections}%
98 \def\backrefsep{, }%
99 \def\backreftwosep{ and~}%
100 \def\backreflastsep{, and~}%
101 }
102 \def\backrefgerman{%
103 \def\backrefpagesname{Seiten}%
104 \def\backrefsectionsname{Abschnitte}%
105 \def\backrefsep{, }%
106 \def\backreftwosep{ und~}%
107 \def\backreflastsep{ und~}%
108 }
109 \def\backreffrench{%
110 \def\backrefpagesname{pages}%
111 \def\backrefsectionsname{sections}%
112 \def\backrefsep{, }%
113 \def\backreftwosep{ et~}%
114 \def\backreflastsep{ et~}%
115 }
116 \def\backrefspanish{%
117 \def\backrefpagesname{p\'aginas}%
118 \def\backrefsectionsname{secciones}%
119 \def\backrefsep{, }%
120 \def\backreftwosep{ y~}%
121 \def\backreflastsep{ y~}%
122 }
123 \def\backrefbrazil{%
124 \def\backrefpagesname{p\'aginas}%
125 \def\backrefsectionsname{se\c c\~oes}%
126 \def\backrefsep{, }%
127 \def\backreftwosep{ e~}%
128 \def\backreflastsep{ e~}%
129 }
130 \def\backrefafrikaans{%
131 \def\backrefpagesname{bladsye}%
132 \def\backrefsectionsname{afdelings}%
133 \def\backrefsep{, }%
134 \def\backreftwosep{ en~}%
135 \def\backreflastsep{ en~}%
136 }
137 \def\backrefitalian{%
138 \def\backrefpagesname{pagine}%
139 \def\backrefsectionsname{sezioni}%
140 \def\backrefsep{, }%
141 \def\backreftwosep{ e~}%
142 \def\backreflastsep{ e~}%
143 }%
144 \def\BR@addto#1#2{%
145 #2%
146 \@temptokena{#2}%
147 \ifx#1\relax
148 \let#1\@empty
149 \fi
150 \ifx#1\@undefined
151 \edef#1{\the\@temptokena}%
152 \else
153 \toks@\expandafter{#1}%
154 \edef#1{\the\toks@\the\@temptokena}%
155 \fi
156 \@temptokena{}\toks@\@temptokena
157 }
158 \def\BR@DeclareLang#1#2{%
159 \begingroup
160 \edef\x##1##2{%
161 \noexpand\ifx##2\relax
162 \errmessage{No definitions for language `#2' found!}%
163 \noexpand\fi
164 \endgroup
165 \noexpand\DeclareVoidOption{#1}{%
166 \noexpand\BR@addto{\noexpand##1}{\noexpand##2}%
167 }%
168 }%
169 \expandafter\x\csname extras#1\expandafter\endcsname
170 \csname backref#2\expandafter\endcsname
171 }
172 \BR@DeclareLang{english}{english}
173 \BR@DeclareLang{american}{english}
174 \BR@DeclareLang{australian}{english}
175 \BR@DeclareLang{british}{english}
176 \BR@DeclareLang{canadian}{english}
177 \BR@DeclareLang{newzealand}{english}
178 \BR@DeclareLang{UKenglish}{english}
179 \BR@DeclareLang{USenglish}{english}
180 \BR@DeclareLang{german}{german}
181 \BR@DeclareLang{ngerman}{german}
182 \BR@DeclareLang{austrian}{german}
183 \BR@DeclareLang{naustrian}{german}
184 \BR@DeclareLang{french}{french}
185 \BR@DeclareLang{acadian}{french}
186 \BR@DeclareLang{canadien}{french}
187 \BR@DeclareLang{frenchb}{french}
188 \BR@DeclareLang{francais}{french}
189 \BR@DeclareLang{spanish}{spanish}
190 \BR@DeclareLang{brazil}{brazil}
191 \BR@DeclareLang{brazilian}{brazil}
192 \BR@DeclareLang{afrikaans}{afrikaans}
193 \BR@DeclareLang{italian}{italian}
194 \backrefenglish
195 \backrefsetup{pageref}
196 \ProcessKeyvalOptions*
197 \def\BR@DisableOption#1{%
198 \DisableKeyvalOption[%
199 action=warning,%
200 package=backref,%
201 ]{backref}{#1}%
202 }
203 \BR@DisableOption{ref}
204 \BR@DisableOption{pageref}
205 \BR@DisableOption{hyperref}
206 \BR@DisableOption{hyperpageref}
207 \newif\ifbackrefparscan
208 \backrefparscantrue
209 \newif\ifBR@BackrefAlt
210 \def\BR@bibitem{%
211 \ifbackrefparscan
212 \expandafter\@ifnextchar\expandafter[\expandafter
213 \BR@@lbibitem\expandafter\BR@@bibitem
214 \else
215 \expandafter\@ifnextchar\expandafter[\expandafter
216 \BR@@@lbibitem\expandafter\BR@@@bibitem
217 \fi
218 }
219 \def\BR@@lbibitem[#1]#2#3\par{%
220 \let\backrefprint\BR@backrefprint
221 \BRorg@bibitem[{#1}]{#2}#3%
222 \BR@backref{#2}%
223 }%
224 \def\BR@@bibitem#1#2\par{%
225 \let\backrefprint\BR@backrefprint
226 \BRorg@bibitem{#1}#2%
227 \BR@backref{#1}%
228 }
229 \def\BR@@@lbibitem[#1]#2{%
230 \def\backrefprint{\BR@backref{#2}}%
231 \BRorg@bibitem[{#1}]{#2}%
232 }
233 \def\BR@@@bibitem#1{%
234 \def\backrefprint{\BR@backref{#1}}%
235 \BRorg@bibitem{#1}%
236 }
237 \def\BR@backrefprint{%
238 \PackageError{backref}{%
239 \string\backrefprint\space is only available after \string\bibitem
240 \MessageBreak
241 with setting \string\backrefparscanfalse
242 }\@ehc
243 }
244 \let\backrefprint\BR@backrefprint
245 \def\BR@backref#1{%
246 \newblock
247 \begingroup
248 \csname @safe@activestrue\endcsname
249 \expandafter\providecommand\csname brc@#1\endcsname{0}%
250 \expandafter\providecommand\csname brcd@#1\endcsname{0}%
251 \csname @safe@activesfalse\expandafter\endcsname
252 \ifBR@BackrefAlt
253 \ifx\backrefentrycount\BR@BackrefEntryCountUnused
254 \else
255 \BR@PopulateEntryCount{#1}%
256 \fi
257 \expandafter\backrefalt\csname brc@#1\expandafter\endcsname
258 \csname brl@#1\expandafter\endcsname
259 \csname brcd@#1\expandafter\endcsname
260 \csname brld@#1\endcsname
261 \else
262 \expandafter\backref\csname br@#1\expandafter\endcsname
263 \fi
264 \endgroup
265 \par
266 }
267 \@ifundefined{newblock}{\def\newblock{\par}}{}
268 \let\BR@Unused\@empty
269 \def\BR@BackrefAltUnused#1#2#3#4{\BR@Unused}
270 \@ifundefined{backrefalt}{%
271 \let\backrefalt\BR@BackrefAltUnused
272 }{}
273 \def\BR@BackrefEntryCountUnused#1#2{\BR@Unused#1}
274 \@ifundefined{backrefentrycount}{%
275 \let\backrefentrycount\BR@BackrefEntryCountUnused
276 }{}
277 \def\backcite#1#2{%
278 \@for\x:=#1\do{%
279 \begingroup
280 \csname @safe@activestrue\endcsname
281 \edef\x{\endgroup
282 \def\noexpand\x{\expandafter\@firstofone\x\@empty}%
283 }%
284 \x
285 \expandafter\ifx\csname br@\x\endcsname\relax
286 \expandafter\protected@xdef\csname br@\x\endcsname{%
287 \protect\backrefxxx#2%
288 }%
289 \ifBR@BackrefAlt
290 \global\expandafter\let\csname brl@\x\expandafter\endcsname
291 \csname br@\x\endcsname
292 \global\expandafter\let\csname brld@\x\expandafter\endcsname
293 \csname br@\x\endcsname
294 \expandafter\gdef\csname brc@\x\endcsname{1}%
295 \expandafter\gdef\csname brcd@\x\endcsname{1}%
296 \fi
297 \else
298 \begingroup
299 \@ifundefined{backrefxxxdupe}{}{\let\backrefxxx\backrefxxxdupe}%
300 \expandafter\def\expandafter\reserved@a\expandafter{%
301 \backrefxxx#2%
302 }%
303 \let\BRorg@backrefxxx\backrefxxx
304 \global\let\BR@found=N%
305 \long\def\backrefxxx##1##2##3{%
306 \expandafter\def\expandafter\reserved@b\expandafter{%
307 \BRorg@backrefxxx{##1}{##2}{##3}%
308 }%
309 \ifx\reserved@a\reserved@b
310 \global\let\BR@found=Y%
311 \fi
312 }%
313 \setbox\@tempboxa\hbox{\csname br@\x\endcsname}%
314 \endgroup
315 \let\backrefsep\relax
316 \def\backreftwosep{\backrefsep}%
317 \def\backreflastsep{\backrefsep}%
318 \if N\BR@found
319 \expandafter\protected@xdef\csname br@\x\endcsname{%
320 \csname br@\x\endcsname, %
321 \protect\backrefxxx#2%
322 }%
323 \ifBR@BackrefAlt
324 \expandafter\protected@xdef\csname brl@\x\endcsname{%
325 \csname brl@\x\endcsname
326 \ifnum\@nameuse{brc@\x}=1 %
327 \noexpand\backreftwosep
328 \else
329 \noexpand\backreflastsep
330 \fi
331 \protect\backrefxxx#2%
332 }%
333 \count@=\@nameuse{brc@\x}\relax
334 \advance\count@ by 1 %
335 \expandafter\xdef\csname brc@\x\endcsname{\the\count@}%
336 \fi
337 \fi
338 \ifBR@BackrefAlt
339 \expandafter\protected@xdef\csname brld@\x\endcsname{%
340 \csname brld@\x\endcsname
341 \ifnum\@nameuse{brcd@\x}=1 %
342 \noexpand\backreftwosep
343 \else
344 \noexpand\backreflastsep
345 \fi
346 \protect\backrefxxx#2%
347 }%
348 \count@=\@nameuse{brcd@\x}\relax
349 \advance\count@ by 1 %
350 \expandafter\xdef\csname brcd@\x\endcsname{\the\count@}%
351 \fi
352 \fi
353 }%
354 }
355 \def\BR@PopulateEntryCount#1{%
356 \begingroup
357 \toks@{}%
358 \def\backrefsep{%
359 \toks@\expandafter{\the\toks@\backrefsep}%
360 }%
361 \def\backreftwosep{%
362 \toks@\expandafter{\the\toks@\backreftwosep}%
363 }%
364 \def\backreflastsep{%
365 \toks@\expandafter{\the\toks@\backreflastsep}%
366 }%
367 \def\protect{}%
368 \let\BR@backrefxxx\backrefxxx
369 \let\backrefxxx\BR@PopulateBackrefxxx
370 \def\BR@name{#1}%
371 \csname brl@#1\endcsname
372 \expandafter\xdef\csname brl@#1\endcsname{\the\toks@}%
373 \endgroup
374 }
375 \def\BR@PopulateBackrefxxx#1#2#3{%
376 \expandafter\def\expandafter\BR@tempa\expandafter{%
377 \BR@backrefxxx{#1}{#2}{#3}%
378 }%
379 \begingroup
380 \count@=\z@
381 \def\backrefsep{}%
382 \def\backreftwosep{}%
383 \def\backreflastsep{}%
384 \let\backrefxxx\BR@@PopulateBackrefxxx
385 \csname brld@\BR@name\endcsname
386 \toks\tw@={\backrefxxx{#1}{#2}{#3}}%
387 \edef\x{\endgroup
388 \toks@{%
389 \the\toks@
390 \noexpand\backrefentrycount{%
391 \the\toks\tw@
392 }{\the\count@}%
393 }%
394 }%
395 \x
396 }
397 \def\BR@@PopulateBackrefxxx#1#2#3{%
398 \expandafter\def\expandafter\BR@tempb\expandafter{%
399 \BR@backrefxxx{#1}{#2}{#3}%
400 }%
401 \ifx\BR@tempa\BR@tempb
402 \advance\count@\@ne
403 \fi
404 }
405 \def\@currentHref{}
406 \AtBeginDocument{%
407 \let\BRorg@bibitem\bibitem
408 \let\bibitem\BR@bibitem
409 \let\BRorg@thebibliography\thebibliography
410 \def\thebibliography{%
411 \BR@starttoc
412 \BRorg@thebibliography
413 }%
414 \@ifundefined{NAT@parse}{%
415 \global\let\BRorg@citex\@citex
416 \global\let\@citex\BR@citex
417 }{%
418 \@ifpackageloaded{hyperref}{}{%
419 \def\hyper@natlinkstart#1{\Hy@backout{#1}}%
420 }%
421 \PackageInfo{backref}{** backref set up for natbib **}%
422 }%
423 }
424 \def\BR@starttoc{%
425 \ifx\backrefalt\BR@BackrefAltUnused
426 \global\BR@BackrefAltfalse
427 \else
428 \global\BR@BackrefAlttrue
429 \fi
430 \begingroup
431 \makeatletter
432 \@input{\jobname.brf}%
433 \if@filesw
434 \@ifundefined{tf@brf}{%
435 \expandafter\newwrite\csname tf@brf\endcsname
436 }{}%
437 \@ifundefined{tf@brf@open}{%
438 \BR@RerunFileCheck
439 \immediate\openout\csname tf@brf\endcsname\jobname.brf\relax
440 \gdef\tf@brf@open{}%
441 }{}%
442 \fi
443 \@nobreakfalse
444 \endgroup
445 }
446 \def\BR@citex[#1]#2{%
447 \BRorg@citex[{#1}]{#2}%
448 \Hy@backout{#2}%
449 }
450 \@ifpackageloaded{chicago}{%
451 \let\BRorg@citedatax\@citedatax
452 \def\@citedatax[#1]#2{%
453 \BRorg@citedatax[{#1}]{#2}%
454 \Hy@backout{#2}%
455 }%
456 }{}
457 \def\Hy@backout#1{%
458 \@bsphack
459 \ifBR@enable
460 \ifBR@verbose
461 \PackageInfo{backref}{Back cite \string`#1\string'}%
462 \fi
463 \ifx\@empty\@currentlabel
464 \protected@write\@auxout{}{%
465 \string\@writefile{brf}{%
466 \string\backcite{#1}{{\thepage}{(document)}{Doc-Start}}%
467 }%
468 }%
469 \else
470 \protected@write\@auxout{}{%
471 \string\@writefile{brf}{%
472 \string\backcite{#1}{{\thepage}{\@currentlabel}{\@currentHref}}%
473 }%
474 }%
475 \fi
476 \else
477 \ifBR@verbose
478 \PackageInfo{backref}{Disabled back cite \string`#1\string'}%
479 \fi
480 \fi
481 \@esphack
482 }
483 \RequirePackage{rerunfilecheck}[2009/12/10]
484 \def\BR@RerunFileCheck{%
485 \RerunFileCheck{\jobname.brf}{%
486 \@ifundefined{tf@brf@open}{%
487 }{%
488 \immediate\closeout\tf@brf
489 }%
490 }{%
491 Rerun to get bibliographical references right%
492 }%
493 }
494 \endinput
495 %%
496 %% End of file `backref.sty'.