diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/refcount.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/oberdiek/refcount.dtx | 224 |
1 files changed, 189 insertions, 35 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/refcount.dtx b/Master/texmf-dist/source/latex/oberdiek/refcount.dtx index 5840a945849..3aacff49d00 100644 --- a/Master/texmf-dist/source/latex/oberdiek/refcount.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/refcount.dtx @@ -1,11 +1,12 @@ % \iffalse meta-comment -% +% % File: refcount.dtx -% Version: 2010/12/01 v3.2 -% -% Copyright (C) 1998, 2000, 2006, 2008, 2010 by +% Version: 2011/10/16 v3.4 +% Info: Data extraction from label references +% +% Copyright (C) 1998, 2000, 2006, 2008, 2010, 2011 by % Heiko Oberdiek <heiko.oberdiek at googlemail.com> -% +% % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either % version 1.3c of this license or (at your option) any later @@ -15,21 +16,21 @@ % http://www.latex-project.org/lppl.txt % and version 1.3 or later is part of all distributions of % LaTeX version 2005/12/01 or later. -% +% % This work has the LPPL maintenance status "maintained". -% +% % This Current Maintainer of this work is Heiko Oberdiek. -% +% % This work consists of the main source file refcount.dtx % and the derived files % refcount.sty, refcount.pdf, refcount.ins, refcount.drv, % refcount-test1.tex, refcount-test2.tex, refcount-test3.tex, -% refcount-test4.tex. -% +% refcount-test4.tex, refcount-test5.tex. +% % Distribution: % CTAN:macros/latex/contrib/oberdiek/refcount.dtx % CTAN:macros/latex/contrib/oberdiek/refcount.pdf -% +% % Unpacking: % (a) If refcount.ins is present: % tex refcount.ins @@ -38,7 +39,7 @@ % (c) If you insist on using LaTeX % latex \let\install=y\input{refcount.dtx} % (quote the arguments according to the demands of your shell) -% +% % Documentation: % (a) If refcount.drv is present: % latex refcount.drv @@ -48,14 +49,14 @@ % if available. Here you can specify further options, e.g. % use A4 as paper format: % \PassOptionsToClass{a4paper}{article} -% +% % Programm calls to get the documentation (example): % pdflatex refcount.dtx % makeindex -s gind.ist refcount.idx % pdflatex refcount.dtx % makeindex -s gind.ist refcount.idx % pdflatex refcount.dtx -% +% % Installation: % TDS:tex/latex/oberdiek/refcount.sty % TDS:doc/latex/oberdiek/refcount.pdf @@ -63,6 +64,7 @@ % TDS:doc/latex/oberdiek/test/refcount-test2.tex % TDS:doc/latex/oberdiek/test/refcount-test3.tex % TDS:doc/latex/oberdiek/test/refcount-test4.tex +% TDS:doc/latex/oberdiek/test/refcount-test5.tex % TDS:source/latex/oberdiek/refcount.dtx % %<*ignore> @@ -80,7 +82,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: refcount 2010/12/01 v3.2 Data extraction from references (HO)} +\Msg{* Package: refcount 2011/10/16 v3.4 Data extraction from label references (HO)} \Msg{************************************************************************} \keepsilent @@ -92,9 +94,9 @@ This is a generated file. Project: refcount -Version: 2010/12/01 v3.2 +Version: 2011/10/16 v3.4 -Copyright (C) 1998, 2000, 2006, 2008, 2010 by +Copyright (C) 1998, 2000, 2006, 2008, 2010, 2011 by Heiko Oberdiek <heiko.oberdiek at googlemail.com> This work may be distributed and/or modified under the @@ -115,7 +117,7 @@ This work consists of the main source file refcount.dtx and the derived files refcount.sty, refcount.pdf, refcount.ins, refcount.drv, refcount-test1.tex, refcount-test2.tex, refcount-test3.tex, - refcount-test4.tex. + refcount-test4.tex, refcount-test5.tex. \endpreamble \let\MetaPrefix\DoubleperCent @@ -130,6 +132,11 @@ and the derived files \file{refcount-test2.tex}{\from{refcount.dtx}{test2}}% \file{refcount-test3.tex}{\from{refcount.dtx}{test3}}% \file{refcount-test4.tex}{\from{refcount.dtx}{test3,test4}}% + \file{refcount-test5.tex}{\from{refcount.dtx}{test5}}% + \nopreamble + \nopostamble + \usedir{source/latex/oberdiek/catalogue}% + \file{refcount.xml}{\from{refcount.dtx}{catalogue}}% } \catcode32=13\relax% active space @@ -156,16 +163,16 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{refcount.drv}% - [2010/12/01 v3.2 Data extraction from references (HO)]% + [2011/10/16 v3.4 Data extraction from label references (HO)]% \documentclass{ltxdoc} -\usepackage{holtxdoc}[2011/02/04] +\usepackage{holtxdoc}[2011/11/22] \begin{document} \DocInput{refcount.dtx}% \end{document} %</driver> % \fi % -% \CheckSum{1072} +% \CheckSum{1185} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -186,7 +193,7 @@ and the derived files % \GetFileInfo{refcount.drv} % % \title{The \xpackage{refcount} package} -% \date{2010/12/01 v3.2} +% \date{2011/10/16 v3.4} % \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}} % % \maketitle @@ -195,7 +202,7 @@ and the derived files % References are not numbers, however they often store numerical % data such as section or page numbers. \cs{ref} or \cs{pageref} % cannot be used for counter assignments or calculations because -% they are not expandable, generate warnings, or can even be links, +% they are not expandable, generate warnings, or can even be links. % The package provides expandable macros to extract the data % from references. Packages \xpackage{hyperref}, \xpackage{nameref}, % \xpackage{titleref}, and \xpackage{babel} are supported. @@ -413,7 +420,7 @@ and the derived files \fi \expandafter\x\csname ver@refcount.sty\endcsname \ProvidesPackage{refcount}% - [2010/12/01 v3.2 Data extraction from references (HO)]% + [2011/10/16 v3.4 Data extraction from label references (HO)]% % \end{macrocode} % % \begin{macrocode} @@ -469,7 +476,7 @@ and the derived files \input ltxcmds.sty\relax \input infwarerr.sty\relax \else - \RequirePackage{ltxcmds}[2010/04/08]% + \RequirePackage{ltxcmds}[2011/11/09]% \RequirePackage{infwarerr}[2010/04/08]% \fi % \end{macrocode} @@ -501,6 +508,7 @@ and the derived files % \end{macro} % % \begin{macro}{\rc@RobustDefOne} +% \begin{macro}{\rc@RobustDefZero} % \begin{macrocode} \ltx@IfUndefined{protected}{% \ltx@IfUndefined{DeclareRobustCommand}{% @@ -509,12 +517,22 @@ and the derived files #1\def#3##1{#4}% }% }% + \def\rc@RobustDefZero#1#2{% + \rc@IfDefinable#1{% + \def#1{#2}% + }% + }% }{% \def\rc@RobustDefOne#1#2#3#4{% \rc@IfDefinable#3{% \DeclareRobustCommand#2#3[1]{#4}% }% }% + \def\rc@RobustDefZero#1#2{% + \rc@IfDefinable#1{% + \DeclareRobustCommand#1{#2}% + }% + }% }% }{% \def\rc@RobustDefOne#1#2#3#4{% @@ -522,9 +540,15 @@ and the derived files \protected#1\def#3##1{#4}% }% }% + \def\rc@RobustDefZero#1#2{% + \rc@IfDefinable#1{% + \protected\def#1{#2}% + }% + }% } % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\rc@newcommand} % \begin{macrocode} @@ -629,7 +653,7 @@ and the derived files \def\rc@set#1#2#3#4{% \begingroup \csname @safe@activestrue\endcsname - \rc@refused{#4}% + \refused{#4}% \expandafter\rc@@set\csname r@#4\endcsname{#1}{#2}{#3}% \endgroup } @@ -640,7 +664,7 @@ and the derived files %\begin{tabular}[t]{@{}l@{: }l@{}} % |#1|& \cs{r@<...>}\\ % |#2|& \cs{setcounter}, \cs{addtocounter}\\ -% |#3|& \cs{ltx@car} (for \cs{ref}), \cs{ltx@cartwo} (for \cs{pageref})\\ +% |#3|& \cs{ltx@car} (for \cs{ref}), \cs{ltx@carsecond} (for \cs{pageref})\\ % |#4|& \hologo{LaTeX} counter\\ %\end{tabular} %\end{quote} @@ -661,29 +685,29 @@ and the derived files % % \begin{macro}{\setcounterref} % \begin{macrocode} -\rc@newcommand*{\setcounterref}[0]{% +\rc@RobustDefZero\setcounterref{% \rc@set\setcounter\ltx@car } % \end{macrocode} % \end{macro} % \begin{macro}{\addtocounterref} % \begin{macrocode} -\rc@newcommand*{\addtocounterref}[0]{% +\rc@RobustDefZero\addtocounterref{% \rc@set\addtocounter\ltx@car } % \end{macrocode} % \end{macro} % \begin{macro}{\setcounterpageref} % \begin{macrocode} -\rc@newcommand*{\setcounterpageref}[0]{% - \rc@set\setcounter\ltx@cartwo +\rc@RobustDefZero\setcounterpageref{% + \rc@set\setcounter\ltx@carsecond } % \end{macrocode} % \end{macro} % \begin{macro}{\addtocounterpageref} % \begin{macrocode} -\rc@newcommand*{\addtocounterpageref}[0]{% - \rc@set\addtocounter\ltx@cartwo +\rc@RobustDefZero\addtocounterpageref{% + \rc@set\addtocounter\ltx@carsecond } % \end{macrocode} % \end{macro} @@ -989,7 +1013,7 @@ and the derived files \expandafter\ifx\csname RequirePackage\endcsname\relax \input refcount.sty\relax \else - \RequirePackage{refcount}[2010/12/01]% + \RequirePackage{refcount}[2011/10/16]% \fi \catcode`\@=11 % \begingroup\expandafter\expandafter\expandafter\endgroup @@ -1159,7 +1183,7 @@ and the derived files %<*test3> \NeedsTeXFormat{LaTeX2e} \documentclass{article} -\usepackage{refcount}[2010/12/01] +\usepackage{refcount}[2011/10/16] %<test4>\usepackage{nameref} \usepackage{titleref} \begin{document} @@ -1207,6 +1231,74 @@ and the derived files \end{document} %</test3> % \end{macrocode} +% \begin{macrocode} +%<*test5> +\NeedsTeXFormat{LaTeX2e} +\documentclass{book} +\usepackage{refcount}[2011/10/16] +\usepackage{zref-runs} +\newcounter{test} +\begin{document} +\ifnum\zruns>1 % + \makeatletter + \def\Test#1#2#3{% + \begingroup + \setcounter{test}{10}% + \sbox0{% + #1{test}{#2}% + \ifnum#3=\value{test}% + \else + \PackageError{test}{\string#1{#2} <> #3 (\the\value{test})}% + \fi + }% + \ifdim\wd0=0pt % + \else + \PackageError{test}{Non-empty box}\@ehc + \fi + \endgroup + }% + \makeatother + \Test\setcounterpageref{ch:two}{1}% + \Test\setcounterpageref{ch:three}{3}% + \Test\setcounterpageref{ch:four}{5}% + \Test\setcounterpageref{ch:five}{7}% + \Test\setcounterpageref{ch:six}{9}% + \Test\setcounterpageref{ch:seven}{13}% + \Test\addtocounterpageref{ch:two}{11}% + \Test\addtocounterpageref{ch:three}{13}% + \Test\addtocounterpageref{ch:four}{15}% + \Test\addtocounterpageref{ch:five}{17}% + \Test\addtocounterpageref{ch:six}{19}% + \Test\addtocounterpageref{ch:seven}{23}% + \Test\setcounterref{ch:two}{1}% + \Test\setcounterref{ch:three}{2}% + \Test\setcounterref{ch:four}{11}% + \Test\addtocounterref{ch:two}{11}% + \Test\addtocounterref{ch:three}{12}% + \Test\addtocounterref{ch:four}{21}% +\fi +\frontmatter +\chapter{Chapter one}\label{ch:one} +\cleardoublepage +\mainmatter +\chapter{Chapter two}\label{ch:two} +\cleardoublepage +\chapter{Chapter three}\label{ch:three} +\cleardoublepage +\setcounter{chapter}{10} +\chapter{Chapter four}\label{ch:four} +\cleardoublepage +\appendix +\chapter{Chapter five}\label{ch:five} +\cleardoublepage +\chapter{Chapter six}\label{ch:six} +\cleardoublepage +\null +\cleardoublepage +\chapter{Chapter seven}\label{ch:seven} +\end{document} +%</test5> +% \end{macrocode} % % \section{Installation} % @@ -1273,6 +1365,7 @@ and the derived files % test/refcount-test2.tex & doc/latex/oberdiek/test/refcount-test2.tex\\ % test/refcount-test3.tex & doc/latex/oberdiek/test/refcount-test3.tex\\ % test/refcount-test4.tex & doc/latex/oberdiek/test/refcount-test4.tex\\ +% test/refcount-test5.tex & doc/latex/oberdiek/test/refcount-test5.tex\\ % refcount.dtx & source/latex/oberdiek/refcount.dtx\\ % \end{tabular}^^A % }^^A @@ -1393,6 +1486,55 @@ and the derived files %\end{verbatim} % \end{quote} % +% \section{Catalogue} +% +% The following XML file can be used as source for the +% \href{http://mirror.ctan.org/help/Catalogue/catalogue.html}{\TeX\ Catalogue}. +% The elements \texttt{caption} and \texttt{description} are imported +% from the original XML file from the Catalogue. +% The name of the XML file in the Catalogue is \xfile{refcount.xml}. +% \begin{macrocode} +%<*catalogue> +<?xml version='1.0' encoding='us-ascii'?> +<!DOCTYPE entry SYSTEM 'catalogue.dtd'> +<entry datestamp='$Date$' modifier='$Author$' id='refcount'> + <name>refcount</name> + <caption>Counter operations with label references.</caption> + <authorref id='auth:oberdiek'/> + <copyright owner='Heiko Oberdiek' year='1998,2000,2006,2008,2010,2011'/> + <license type='lppl1.3'/> + <version number='3.4'/> + <description> + Provides commands <tt>\setcounterref</tt> and + <tt>\addtocounterref</tt> which use the section (or whatever) + number from the reference as the value to put into the counter, as + in: + + <pre> + ...\label{sec:foo} + ... + \setcounterref{foonum}{sec:foo} + </pre> + Commands <tt>\setcounterpageref</tt> and + <tt>\addtocounterpageref</tt> do the corresponding thing with the + page reference of the label. + <p/> + No <tt>.ins</tt> file is distributed; process the + <tt>.dtx</tt> with plain TeX to create one. + <p/> + The package is part of the <xref refid='oberdiek'>oberdiek</xref> + bundle. + </description> + <documentation details='Package documentation' + href='ctan:/macros/latex/contrib/oberdiek/refcount.pdf'/> + <ctan file='true' path='/macros/latex/contrib/oberdiek/refcount.dtx'/> + <miktex location='oberdiek'/> + <texlive location='oberdiek'/> + <install path='/macros/latex/contrib/oberdiek/oberdiek.tds.zip'/> +</entry> +%</catalogue> +% \end{macrocode} +% % \begin{History} % \begin{Version}{1998/04/08 v1.0} % \item @@ -1434,6 +1576,18 @@ and the derived files % \item % Test files added. % \end{Version} +% \begin{Version}{2011/06/22 v3.3} +% \item +% Bug fix: \cs{rc@refused} is undefined for \cs{setcounterpageref} +% and similar macros. (Bug found by Marc van Dongen.) +% \end{Version} +% \begin{Version}{2011/10/16 v3.4} +% \item +% Bug fix: \cs{setcounterpageref} and \cs{addtocounterpageref} fixed. +% (Bug found by Staz.) +% \item +% Macros \cs{(set|addto)counter(page|)ref} are made robust. +% \end{Version} % \end{History} % % \PrintIndex |