summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/hyperref/backref.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-01-17 23:32:39 +0000
committerKarl Berry <karl@freefriends.org>2010-01-17 23:32:39 +0000
commit141203d77d129a6f04915541e9d0506493bdeab3 (patch)
tree65874c1b68a1a72829a638c8b650953b99193371 /Master/texmf-dist/source/latex/hyperref/backref.dtx
parentf54d59c4fcbb03552550891dca04939761a8d37a (diff)
hyperref update (17jan10)
git-svn-id: svn://tug.org/texlive/trunk@16758 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/hyperref/backref.dtx')
-rw-r--r--Master/texmf-dist/source/latex/hyperref/backref.dtx185
1 files changed, 153 insertions, 32 deletions
diff --git a/Master/texmf-dist/source/latex/hyperref/backref.dtx b/Master/texmf-dist/source/latex/hyperref/backref.dtx
index d83194c6938..889a86b77de 100644
--- a/Master/texmf-dist/source/latex/hyperref/backref.dtx
+++ b/Master/texmf-dist/source/latex/hyperref/backref.dtx
@@ -22,9 +22,9 @@
%<driver>\ProvidesFile{backref.drv}
% \fi
% \ProvidesFile{backref.dtx}
- [2010/01/09 v1.32 Bibliographical back referencing]%
+ [2010/01/16 v1.33 Bibliographical back referencing]%
%
-% \CheckSum{607}
+% \CheckSum{747}
%
% \iffalse
%<*driver>
@@ -186,7 +186,7 @@
%\begin{quote}
%\begin{verbatim}
%\usepackage[backref]{backref}
-%\renewcommand*{\backref}[1]{}
+%\renewcommand*{\backref}[1]{}% for backref < 1.33 necessary
%\renewcommand*{\backrefalt}[4]{%
% \ifcase #1 %
% No citations.%
@@ -216,6 +216,32 @@
% \meta{entry1} \cmd{\backrefsep} \meta{entry2}
% \cmd{\backreflastsep} \meta{entry3}
% \end{quote}
+% Since version 1.33 it is not necessary to redefine
+% \backref, it is automatically disabled if \backrefalt
+% is redefined.
+%
+% \subsubsection{Refinement \cs{backrefentrycount}}
+%
+% Since version 1.33 the entries of the distinct list of
+% interface \cs{backrefalt} are wrapped in
+% \cs{backrefentrycount}. The macro is called with two
+% arguments. The first is the backref entry and the second
+% one the citation count of this entry. As default the
+% macro passes the first argument through and ignores the
+% count argument. But it can be redefined, e.g.
+%\begin{quote}
+%\begin{verbatim}
+%\renewcommand*{\backrefalt}[4]{...}% see above
+%\renewcommand*{\backrefentrycount}[2]{%
+% #1%
+% \ifnum#2>1 %
+% ~(#2)%
+% \fi
+%}
+%\end{verbatim}
+%\end{quote}
+% In case of duplicates, the distinct entry is
+% appended by the number of citations in parentheses.
%
% \StopEventually{}
%
@@ -399,6 +425,12 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\ifBR@BackrefAlt}
+% \begin{macrocode}
+\newif\ifBR@BackrefAlt
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\BR@bibitem}
% \begin{macrocode}
\def\BR@bibitem{%
@@ -446,16 +478,31 @@
\expandafter\providecommand\csname brc@#1\endcsname{0}%
\expandafter\providecommand\csname brcd@#1\endcsname{0}%
\csname @safe@activesfalse\expandafter\endcsname
- \expandafter\backref\csname br@#1\expandafter\endcsname
- \expandafter\backrefalt\csname brc@#1\expandafter\endcsname
- \csname brl@#1\expandafter\endcsname
- \csname brcd@#1\expandafter\endcsname
- \csname brld@#1\endcsname
+ \ifBR@BackrefAlt
+ \ifx\backrefentrycount\BR@BackrefEntryCountUnused
+ \else
+ \BR@PopulateEntryCount{#1}%
+ \fi
+ \expandafter\backrefalt\csname brc@#1\expandafter\endcsname
+ \csname brl@#1\expandafter\endcsname
+ \csname brcd@#1\expandafter\endcsname
+ \csname brld@#1\endcsname
+ \else
+ \expandafter\backref\csname br@#1\expandafter\endcsname
+ \fi
\endgroup
\par
}
\@ifundefined{newblock}{\def\newblock{\par}}{}
-\providecommand*{\backrefalt}[4]{}
+\let\BR@Unused\@empty
+\def\BR@BackrefAltUnused#1#2#3#4{\BR@Unused}
+\@ifundefined{backrefalt}{%
+ \let\backrefalt\BR@BackrefAltUnused
+}{}
+\def\BR@BackrefEntryCountUnused#1#2{\BR@Unused#1}
+\@ifundefined{backrefentrycount}{%
+ \let\backrefentrycount\BR@BackrefEntryCountUnused
+}{}
% \end{macrocode}
%
% \subsection{Reading .brf file}
@@ -553,12 +600,14 @@
\expandafter\protected@xdef\csname br@\x\endcsname{%
\protect\backrefxxx#2%
}%
- \global\expandafter\let\csname brl@\x\expandafter\endcsname
- \csname br@\x\endcsname
- \global\expandafter\let\csname brld@\x\expandafter\endcsname
- \csname br@\x\endcsname
- \expandafter\gdef\csname brc@\x\endcsname{1}%
- \expandafter\gdef\csname brcd@\x\endcsname{1}%
+ \ifBR@BackrefAlt
+ \global\expandafter\let\csname brl@\x\expandafter\endcsname
+ \csname br@\x\endcsname
+ \global\expandafter\let\csname brld@\x\expandafter\endcsname
+ \csname br@\x\endcsname
+ \expandafter\gdef\csname brc@\x\endcsname{1}%
+ \expandafter\gdef\csname brcd@\x\endcsname{1}%
+ \fi
\else
% \end{macrocode}
% Fill in further entry. But check for dupe first.
@@ -588,37 +637,104 @@
\csname br@\x\endcsname, %
\protect\backrefxxx#2%
}%
- \expandafter\protected@xdef\csname brl@\x\endcsname{%
- \csname brl@\x\endcsname
- \ifnum\@nameuse{brc@\x}=1 %
+ \ifBR@BackrefAlt
+ \expandafter\protected@xdef\csname brl@\x\endcsname{%
+ \csname brl@\x\endcsname
+ \ifnum\@nameuse{brc@\x}=1 %
+ \noexpand\backreftwosep
+ \else
+ \noexpand\backreflastsep
+ \fi
+ \protect\backrefxxx#2%
+ }%
+ \count@=\@nameuse{brc@\x}\relax
+ \advance\count@ by 1 %
+ \expandafter\xdef\csname brc@\x\endcsname{\the\count@}%
+ \fi
+ \fi
+ \ifBR@BackrefAlt
+ \expandafter\protected@xdef\csname brld@\x\endcsname{%
+ \csname brld@\x\endcsname
+ \ifnum\@nameuse{brcd@\x}=1 %
\noexpand\backreftwosep
\else
\noexpand\backreflastsep
\fi
\protect\backrefxxx#2%
}%
- \count@=\@nameuse{brc@\x}\relax
+ \count@=\@nameuse{brcd@\x}\relax
\advance\count@ by 1 %
- \expandafter\xdef\csname brc@\x\endcsname{\the\count@}%
+ \expandafter\xdef\csname brcd@\x\endcsname{\the\count@}%
\fi
- \expandafter\protected@xdef\csname brld@\x\endcsname{%
- \csname brld@\x\endcsname
- \ifnum\@nameuse{brcd@\x}=1 %
- \noexpand\backreftwosep
- \else
- \noexpand\backreflastsep
- \fi
- \protect\backrefxxx#2%
- }%
- \count@=\@nameuse{brcd@\x}\relax
- \advance\count@ by 1 %
- \expandafter\xdef\csname brcd@\x\endcsname{\the\count@}%
\fi
}%
}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\BR@PopulateEntryCount}
+% \begin{macrocode}
+\def\BR@PopulateEntryCount#1{%
+ \begingroup
+ \toks@{}%
+ \def\backrefsep{%
+ \toks@\expandafter{\the\toks@\backrefsep}%
+ }%
+ \def\backreftwosep{%
+ \toks@\expandafter{\the\toks@\backreftwosep}%
+ }%
+ \def\backreflastsep{%
+ \toks@\expandafter{\the\toks@\backreflastsep}%
+ }%
+ \def\protect{}%
+ \let\BR@backrefxxx\backrefxxx
+ \let\backrefxxx\BR@PopulateBackrefxxx
+ \def\BR@name{#1}%
+ \csname brl@#1\endcsname
+ \expandafter\xdef\csname brl@#1\endcsname{\the\toks@}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\BR@PopulateBackrefxxx}
+% \begin{macrocode}
+\def\BR@PopulateBackrefxxx#1#2#3{%
+ \expandafter\def\expandafter\BR@tempa\expandafter{%
+ \BR@backrefxxx{#1}{#2}{#3}%
+ }%
+ \begingroup
+ \count@=\z@
+ \def\backrefsep{}%
+ \def\backreftwosep{}%
+ \def\backreflastsep{}%
+ \let\backrefxxx\BR@@PopulateBackrefxxx
+ \csname brld@\BR@name\endcsname
+ \toks\tw@={\backrefxxx{#1}{#2}{#3}}%
+ \edef\x{\endgroup
+ \toks@{%
+ \the\toks@
+ \noexpand\backrefentrycount{%
+ \the\toks\tw@
+ }{\the\count@}%
+ }%
+ }%
+ \x
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\BR@@PopulateBackrefxxx}
+% \begin{macrocode}
+\def\BR@@PopulateBackrefxxx#1#2#3{%
+ \expandafter\def\expandafter\BR@tempb\expandafter{%
+ \BR@backrefxxx{#1}{#2}{#3}%
+ }%
+ \ifx\BR@tempa\BR@tempb
+ \advance\count@\@ne
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Initialization}
%
% \begin{macrocode}
@@ -645,6 +761,11 @@
% \begin{macro}{\BR@starttoc}
% \begin{macrocode}
\def\BR@starttoc{%
+ \ifx\backrefalt\BR@BackrefAltUnused
+ \global\BR@BackrefAltfalse
+ \else
+ \global\BR@BackrefAlttrue
+ \fi
\begingroup
\makeatletter
\@input{\jobname.brf}%