diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/hyperref/nameref.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/hyperref/nameref.dtx | 139 |
1 files changed, 110 insertions, 29 deletions
diff --git a/Master/texmf-dist/source/latex/hyperref/nameref.dtx b/Master/texmf-dist/source/latex/hyperref/nameref.dtx index e2c7445b00f..92f6d6b2af5 100644 --- a/Master/texmf-dist/source/latex/hyperref/nameref.dtx +++ b/Master/texmf-dist/source/latex/hyperref/nameref.dtx @@ -1,10 +1,7 @@ -\def\filedate{2003/12/03} -\def\fileversion{2.21} -% % \iffalse % File: nameref.dtx % Copyright (C) 1995-9 Sebastian Rahtz -% 2000-3 Sebastian Rahtz, Heiko Oberdiek +% 2000-6 Sebastian Rahtz, Heiko Oberdiek % %% This file is part of the `Hyperref Bundle'. %% ------------------------------------------- @@ -18,9 +15,28 @@ %% %% The list of all files belonging to the `Hyperref Bundle' is %% given in the file `manifest.txt'. +% +%<*dtx> +\ProvidesFile{nameref.dtx} +%</dtx> +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{nameref} +%<driver>\ProvidesFile{nameref.drv} +% \fi +% \ProvidesFile{nameref.dtx} + [2006/08/15 v2.26 Cross-referencing by name of section] +% +% \CheckSum{487} +% +% \iffalse %<*driver> \documentclass{ltxdoc} +\IfFileExists{bmhydoc.sty}{\usepackage{bmhydoc}}{} +\usepackage[numbered]{hypdoc} +\EnableCrossrefs +\CodelineIndex \begin{document} + \GetFileInfo{nameref.sty} \title{% Section name references in \LaTeX \thanks{% @@ -31,31 +47,42 @@ \author{Sebastian Rahtz} \date{\filedate} \maketitle + \makeatletter + \@ifundefined{HyperrefOverview}{}{% + \HyperrefOverview*% + }% \tableofcontents \DocInput{nameref.dtx} + \PrintIndex \end{document} %</driver> % \fi -% \CheckSum{463} +% % \StopEventually{} +% % \section{Introduction} % Cross-referencing to include the \emph{name} of the section, rather than % just the number or page. This works by redefining some of the inside % \LaTeX\ macros, so it is vulnerable to future changes. % \section{History} -% Sebastian Rahtz, for Lou Burnard, March 15th 1994; -% SPQR CERN July 1994; -% Last mod. Sept. 3th MG; -% Sept. 19th SPQR; -% April 11th 1995 SPQR (added section formatting hook); -% April 14th 1995 SPQR (compatibility with hyperref); -% June 22 1995 SPQR (removed typeout from Sectionformat); -% September 22 1997 added varioref hacks by Corey Minyard; -% September 28th changes by David Carlisle. +% Sebastian Rahtz, for Lou Burnard, March 15th 1994;\\ +% SPQR CERN July 1994;\\ +% Last mod. Sept. 3th MG;\\ +% Sept. 19th SPQR;\\ +% April 11th 1995 SPQR (added section formatting hook);\\ +% April 14th 1995 SPQR (compatibility with hyperref);\\ +% June 22 1995 SPQR (removed typeout from Sectionformat);\\ +% September 22 1997 added varioref hacks by Corey Minyard;\\ +% September 28th changes by David Carlisle.\\ +% More recent changes are recorded in ChangeLog. +% +% \section{Implementation} % \begin{macrocode} %<*package> -\ProvidesPackage{nameref}[\filedate\space v\fileversion - \space Cross-referencing by name of section] +% \end{macrocode} +% +% \begin{macrocode} +\RequirePackage{refcount}[2006/02/12] % \end{macrocode} % % We redefine |\label| so that it also writes the name of the @@ -67,6 +94,8 @@ \def\strip@period#1.\relax#2\@@@{#1} % \end{macrocode} % +% \subsection{\cs{label} stuff} +% % Here is tested, whether package showkeys is loaded. % But if option final is used, the macros of showkeys % are not defined, so we have to check an additional @@ -176,6 +205,9 @@ }% \endgroup} % \end{macrocode} +% +% \subsection{Changes of section macros} +% % Add to the underlying section heading macros so that they % note the section name for use by label. % @@ -223,6 +255,16 @@ } % \end{macrocode} % +% Captions +% +% \begin{macrocode} +\let\NR@@caption\@caption +\long\def\@caption#1[#2]{% + \def\@currentlabelname{#2}% + \NR@@caption{#1}[{#2}]% +} +% \end{macrocode} +% % Compatibility for package titlesec. % \begin{macrocode} \AtBeginDocument{% @@ -236,6 +278,8 @@ } % \end{macrocode} % +% \subsection{Referencing stuff} +% % We default the label and hypertext reference to be empty. % \begin{macrocode} \def\@currentlabelname{} @@ -260,15 +304,24 @@ % \begin{macrocode} \providecommand*\@safe@activestrue{}% \providecommand*\@safe@activesfalse{}% +\def\NR@setref#1{% + \begingroup + \@safe@activestrue + \expandafter + \endgroup + \expandafter\NR@@setref\csname r@#1\endcsname +} +\def\NR@@setref#1{% + \ifx\@undefined#1% + \let#1\relax + \fi + \@setref#1% +} \def\T@ref#1{% - \@safe@activestrue - \expandafter\@setref\csname r@#1\endcsname\@firstoffive{#1}% - \@safe@activesfalse + \NR@setref{#1}\@firstoffive{#1}% }% \def\T@pageref#1{% - \@safe@activestrue - \expandafter\@setref\csname r@#1\endcsname\@secondoffive{#1}% - \@safe@activesfalse + \NR@setref{#1}\@secondoffive{#1}% }% \ifNR@showkeys \ifx\SK@ref\@empty @@ -276,14 +329,14 @@ \def\T@ref#1{% \@safe@activestrue \SK@\SK@@ref{#1}% - \expandafter\@setref\csname r@#1\endcsname\@firstoffive{#1}% \@safe@activesfalse + \NR@setref{#1}\@firstoffive{#1}% }% \def\T@pageref#1{% \@safe@activestrue \SK@\SK@@ref{#1}% - \expandafter\@setref\csname r@#1\endcsname\@secondoffive{#1}% \@safe@activesfalse + \NR@setref{#1}\@secondoffive{#1}% }% \fi \fi @@ -300,13 +353,12 @@ \DeclareRobustCommand{\pageref}{\T@pageref}% } % \end{macrocode} -% \section{Usage and frontend} +% +% \subsection{Usage and frontend} % Access the (third) name part with |\nameref|; % \begin{macrocode} \def\T@nameref#1{% - \@safe@activestrue - \expandafter\@setref\csname r@#1\endcsname\@thirdoffive{#1}% - \@safe@activesfalse + \NR@setref{#1}\@thirdoffive{#1}% }% \ifNR@showkeys \ifx\SK@ref\@empty @@ -314,8 +366,8 @@ \def\T@nameref#1{% \@safe@activestrue \SK@\SK@@ref{#1}% - \expandafter\@setref\csname r@#1\endcsname\@thirdoffive{#1}% \@safe@activesfalse + \NR@setref{#1}\@thirdoffive{#1}% }% \fi \fi @@ -330,7 +382,36 @@ % \begin{macrocode} \providecommand\Sectionformat[2]{#1} % \end{macrocode} +% +% \subsection{Package ifthen support} +% +% Package ifthen's \cmd{\isodd} does not work with +% \cmd{\pageref} because of the extra link and the +% star form. Therefore we need an expandable variant. +% +% Unfortunately there is no hook in \cmd{\ifthenelse} in order +% to provide expandable versions without link of \cmd{\ref} +% and \cmd{\pageref}. As possible target I could only find +% \cmd{\begingroup}: +% \begin{macrocode} +\@ifpackageloaded{ifthen}{% + \let\NROrg@ifthenelse\ifthenelse + \def\ifthenelse{% + \let\begingroup\NR@TE@begingroup + \NROrg@ifthenelse + }% + \let\NROrg@begingroup\begingroup + \def\NR@TE@begingroup{% + \let\begingroup\NROrg@begingroup + \begingroup + \def\ref##1{\getrefbykeydefault{##1}{}{??}}% + \def\pageref##1{\getrefbykeydefault{##1}{page}{0}}% + }% +}{} +% \end{macrocode} +% % \subsection{Compatibility with varioref} +% % [This section was derived by Corey Minyard \texttt{minyard@acm.org} % from the varioref package] % \begin{macrocode} |