2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \iffalse meta-comment
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Copyright (C) 1998, 2000, 2006, 2008 by
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Heiko Oberdiek <oberdiek@uni-freiburg.de>
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% This work may be distributed and/or modified under the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% conditions of the LaTeX Project Public License, either
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% version 1.3 of this license or (at your option) any later
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% version. The latest version of this license is in
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% and version 1.3 or later is part of all distributions of
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% LaTeX version 2005/12/01 or later.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% This work has the LPPL maintenance status "maintained".
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% This Current Maintainer of this work is Heiko Oberdiek.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% This work consists of the main source file refcount.dtx
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% and the derived files
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% refcount.sty, refcount.pdf, refcount.ins, refcount.drv.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Distribution:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% CTAN:macros/latex/contrib/oberdiek/refcount.dtx
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% CTAN:macros/latex/contrib/oberdiek/refcount.pdf
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% (a) If refcount.ins is present:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% (c) If you insist on using LaTeX
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% latex \let\install=y\input{refcount.dtx}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% (quote the arguments according to the demands of your shell)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Documentation:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% (a) If refcount.drv is present:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% The class ltxdoc loads the configuration file ltxdoc.cfg
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% if available. Here you can specify further options, e.g.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% use A4 as paper format:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \PassOptionsToClass{a4paper}{article}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Programm calls to get the documentation (example):
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Installation:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \def\x{LaTeX2e}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\expandafter\endgroup
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\ifcase 0\ifx\install y1\fi\expandafter
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \ifx\csname processbatchFile\endcsname\relax\else1\fi
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \ifx\fmtname\x\else 1\fi\relax
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\else\csname fi\endcsname
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{************************************************************************}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* Installation}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* Package: refcount 2008/08/11 v3.1 Data extraction from references (HO)}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{************************************************************************}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\askforoverwritefalse
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\let\MetaPrefix\relax
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannThis is a generated file.
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannCopyright (C) 1998, 2000, 2006, 2008 by
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann Heiko Oberdiek <oberdiek@uni-freiburg.de>
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannThis work may be distributed and/or modified under the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannconditions of the LaTeX Project Public License, either
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannversion 1.3 of this license or (at your option) any later
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannversion. The latest version of this license is in
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannand version 1.3 or later is part of all distributions of
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannLaTeX version 2005/12/01 or later.
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannThis work has the LPPL maintenance status "maintained".
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannThis Current Maintainer of this work is Heiko Oberdiek.
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannThis work consists of the main source file refcount.dtx
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannand the derived files
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann refcount.sty, refcount.pdf, refcount.ins, refcount.drv.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\let\MetaPrefix\DoubleperCent
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \file{refcount.ins}{\from{refcount.dtx}{install}}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \file{refcount.drv}{\from{refcount.dtx}{driver}}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \file{refcount.sty}{\from{refcount.dtx}{package}}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{************************************************************************}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* To finish the installation you have to move the following}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* file into a directory searched by TeX:}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* And install the following script file:}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* To produce the documentation run the file `refcount.drv'}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* through LaTeX.}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{* Happy TeXing!}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\Msg{************************************************************************}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\NeedsTeXFormat{LaTeX2e}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann [2008/08/11 v3.1 Data extraction from references (HO)]%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\documentclass{ltxdoc}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\usepackage{holtxdoc}[2008/08/11]
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\begin{document}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\end{document}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \CheckSum{198}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \CharacterTable
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% {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
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Lower-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
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Digits \0\1\2\3\4\5\6\7\8\9
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Exclamation \! Double quote \" Hash (number) \#
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Dollar \$ Percent \% Ampersand \&
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Acute accent \' Left paren \( Right paren \)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Asterisk \* Plus \+ Comma \,
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Minus \- Point \. Solidus \/
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Colon \: Semicolon \; Less than \<
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Equals \= Greater than \> Question mark \?
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Commercial at \@ Left bracket \[ Backslash \\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Right bracket \] Circumflex \^ Underscore \_
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Grave accent \` Left brace \{ Vertical bar \|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Right brace \} Tilde \~}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \title{The \xpackage{refcount} package}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \date{2008/08/11 v3.1}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{abstract}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% References are not numbers, however they often store numerical
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% data such as section or page numbers. \cs{ref} or \cs{pageref}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% cannot be used for counter assignments or calculations because
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% they are not expandable, generate warnings, or can even be links,
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% The package provides expandable macros to extract the data
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% from references. Packages \xpackage{hyperref}, \xpackage{nameref},
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \xpackage{titleref}, and \xpackage{babel} are supported.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{abstract}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \tableofcontents
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \section{Usage}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Setting counters}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% The following commands are similar to \LaTeX's
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{setcounter} and \cs{addtocounter},
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% but they extract the number value from a reference:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{setcounterref}, \cs{addtocounterref}\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{setcounterpageref}, \cs{addtocounterpageref}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% They take two arguments:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{...counter...ref} |{|\meta{\LaTeX\ counter}|}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |{|\meta{reference}|}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% An undefined references produces the usual LaTeX warning
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% and its value is assumed to be zero.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\begin{verbatim}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\newcounter{ctrA}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\newcounter{ctrB}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\refstepcounter{ctrA}\label{ref:A}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\setcounterref{ctrB}{ref:A}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\addtocounterpageref{ctrB}{ref:A}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\end{verbatim}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Expandable commands}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% These commands that can be used in expandible contexts
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% (inside calculations, \cs{edef}, \cs{csname}, \cs{write}, \dots):
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{getrefnumber}, \cs{getpagerefnumber}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% They take one argument, the reference:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{get...refnumber} |{|\meta{reference}|}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% The default for undefined references can be changed
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% with macro \cs{setrefcountdefault}, for example this
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% package calls:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{setrefcountdefault}|{0}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Since version 2.0 of this package there is a new
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{getrefbykeydefault} |{|\meta{reference}|}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |{|\meta{key}|}| |{|\meta{default}|}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% This generalized version allows the extraction
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% of further properties of a reference than the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% two standard ones. Thus the following properties
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% are supported, if they are available:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{tabular}{@{}l|l|l@{}}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Key & Description & Package\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \meta{empty} & same as \cs{ref} & \LaTeX\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |page| & same as \cs{pageref} & \LaTeX\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |title| & section and caption titles & \xpackage{titleref}\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |name| & section and caption titles & \xpackage{nameref}\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |anchor| & anchor name & \xpackage{hyperref}\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |url| & url/file & \xpackage{hyperref}/\xpackage{xr}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{tabular}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Undefined references}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Because warnings and assignments cannot be used in
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% expandible contexts, undefined references do not
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% produce a warning, their values are assumed to be zero.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\begin{verbatim}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\label{ref:here}% somewhere
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\refused{ref:here}% see below
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\ifodd\getpagerefnumber{ref:here}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% reference is on an odd page
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% reference is on an even page
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\end{verbatim}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% In case of undefined references the user usually want's
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% to be informed. Also \LaTeX\ prints a warning at
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% the end of the \LaTeX\ run. To notify \LaTeX\ and
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% get a normal warning, just use
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \cs{refused} |{|\meta{reference}|}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% outside the expanding context. Example, see above.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Notes}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{itemize}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% The method of extracting the number in this
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% package also works in cases, where the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% reference cannot be used directly, because
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% a package such as \xpackage{hyperref} has added
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% extra stuff (hyper link), so that the reference cannot
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% be used as number any more.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% If the reference does not contain a number,
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% assignments to a counter will fail of course.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{itemize}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \StopEventually{
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \section{Implementation}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{macrocode}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\NeedsTeXFormat{LaTeX2e}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\ProvidesPackage{refcount}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann [2008/08/11 v3.1 Data extraction from references (HO)]%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\setrefcountdefault#1{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \def\rc@default{#1}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\setrefcountdefault{0}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \def\@car#1#2\@nil{#1} % defined in LaTeX kernel
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@cartwo#1#2#3\@nil{#2}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% generic check without babel support
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\long\def\rc@refused#1{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\ifx\csname r@#1\endcsname\relax
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \protect\G@refundefinedtrue
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \@latex@warning{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann Reference `#1' on page \thepage\space undefined%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% user command, add babel support
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\refused}[1]{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \csname @safe@activestrue\endcsname
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \rc@refused{#1}{}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Generic command for "\{set,addto}counter{page,}ref":
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #1: \setcounter, \addtocounter
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #2: \@car (for \ref), \@cartwo (for \pageref)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #3: LaTeX counter
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #4: reference
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@set#1#2#3#4{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \csname @safe@activestrue\endcsname
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \rc@refused{#4}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\rc@@set\csname r@#4\endcsname{#1}{#2}{#3}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #1: \r@<...>
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #2: \setcounter, \addtocounter
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #3: \@car (for \ref), \@cartwo (for \pageref)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #4: LaTeX counter
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@@set#1#2#3#4{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann #2{#4}{\rc@default}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter#3#1\rc@default\rc@default\@nil
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% user commands:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\setcounterref}{\rc@set\setcounter\@car}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\addtocounterref}{\rc@set\addtocounter\@car}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\setcounterpageref}{\rc@set\setcounter\rc@cartwo}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\addtocounterpageref}{\rc@set\addtocounter\rc@cartwo}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\getrefnumber}[1]{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\ifx\csname r@#1\endcsname\relax
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\expandafter\expandafter\@car
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \csname r@#1\endcsname\@nil
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\getpagerefnumber}[1]{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\ifx\csname r@#1\endcsname\relax
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\expandafter\expandafter\rc@cartwo
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \csname r@#1\endcsname\rc@default\rc@default\@nil
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\newcommand*{\getrefbykeydefault}[2]{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\rc@getrefbykeydefault
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \csname r@#1\expandafter\endcsname
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \csname rc@extract@#2\endcsname
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #1: \r@<...>
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #2: \rc@extract@<...>
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@getrefbykeydefault#1#2#3{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann % reference is undefined
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann % extract method is missing
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\rc@generic#1{#3}{#3}{#3}{#3}{#3}\@nil#2{#3}%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #1: first item in \r@<...>
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #2: remaining items in \r@<...>
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% #3: \rc@extract@<...>
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@generic#1#2\@nil#3#4{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann #3{#1\TR@TitleReference\@empty{#4}\@nil}{#1}#2\@nil
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@extract@{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\@car\@gobble
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@extract@page{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\@car\@gobbletwo
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@extract@name{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\@car\@gobblefour\@empty
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@extract@anchor{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\@car\@gobblefour
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@extract@url{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \expandafter\expandafter\expandafter\@car\expandafter
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \@gobble\@gobblefour
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@extract@title#1#2\@nil{%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann \rc@@extract@title#1%
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann\def\rc@@extract@title#1\TR@TitleReference#2#3#4\@nil{#3}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{macrocode}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \section{Installation}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Download}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Package.} This package is available on
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{description}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \item[\CTAN{macros/latex/contrib/oberdiek/refcount.dtx}] The source file.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \item[\CTAN{macros/latex/contrib/oberdiek/refcount.pdf}] Documentation.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{description}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Bundle.} All the packages of the bundle `oberdiek'
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% are also available in a TDS compliant ZIP archive. There
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% the packages are already unpacked and the documentation files
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% are generated. The files and directories obey the TDS standard.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{description}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \item[\CTAN{install/macros/latex/contrib/oberdiek.tds.zip}]
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{description}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \emph{TDS} refers to the standard ``A Directory Structure
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% with \xfile{texmf} in their name are usually organized this way.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Bundle installation}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% TDS tree (also known as \xfile{texmf} tree) of your choice.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Example (linux):
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |unzip oberdiek.tds.zip -d ~/texmf|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Script installation.}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Check the directory \xfile{TDS:scripts/oberdiek/} for
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% scripts that need further installation steps.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Package \xpackage{attachfile2} comes with the Perl script
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \xfile{pdfatfi.pl} that should be installed in such a way
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% that it can be called as \texttt{pdfatfi}.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Example (linux):
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Package installation}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \docstrip\ archive. The files are extracted by running the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \xfile{.dtx} through \plainTeX:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{TDS.} Now the different files must be moved into
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% the different directories in your installation TDS tree
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% (also known as \xfile{texmf} tree):
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% refcount.sty & tex/latex/oberdiek/refcount.sty\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% refcount.pdf & doc/latex/oberdiek/refcount.pdf\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% refcount.dtx & source/latex/oberdiek/refcount.dtx\\
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{tabular}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \sbox0{\t}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\linewidth
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \advance\linewidth by\leftmargin
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \advance\linewidth by\rightmargin
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \edef\x{\endgroup
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \def\noexpand\lw{\the\linewidth}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \def\lwbox{^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \hbox to \linewidth{^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \kern-\leftmargin\relax
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \kern-\rightmargin\relax
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\lw
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \sbox0{\small\t}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\linewidth
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\lw
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \sbox0{\footnotesize\t}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\linewidth
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\lw
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \sbox0{\scriptsize\t}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\linewidth
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\lw
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \sbox0{\tiny\t}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \ifdim\wd0>\linewidth
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% TDS installing feature, then some files can already be in the right
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% place, see the documentation of \docstrip.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Refresh file name databases}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% If your \TeX~distribution
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% these. For example, \teTeX\ users run \verb|texhash| or
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \verb|mktexlsr|.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \subsection{Some details for the interested}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Attached source.}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% The PDF documentation on CTAN also includes the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \xfile{.dtx} source file. It can be extracted by
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% AcrobatReader 6 or higher. Another option is \textsf{pdftk},
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% e.g. unpack the file into the current directory:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \verb|pdftk refcount.pdf unpack_files output .|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Unpacking with \LaTeX.}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% The \xfile{.dtx} chooses its action depending on the format:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{description}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \item[\plainTeX:] Run \docstrip\ and extract the files.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \item[\LaTeX:] Generate the documentation.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{description}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% If you insist on using \LaTeX\ for \docstrip\ (really,
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \docstrip\ does not need \LaTeX), then inform the autodetect routine
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% about your intention:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \verb|latex \let\install=y\input{refcount.dtx}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Do not forget to quote the argument according to the demands
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% of your shell.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \paragraph{Generating the documentation.}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% the documentation. The process can be configured by the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% configuration file \xfile{ltxdoc.cfg}. For instance, put this
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% line into this file, if you want to have A4 as paper format:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \verb|\PassOptionsToClass{a4paper}{article}|
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% An example follows how to generate the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% documentation with pdf\LaTeX:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{quote}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\begin{verbatim}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann%\end{verbatim}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{History}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{Version}{1998/04/08 v1.0}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% First public release, written as answer in the
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% newsgroup \xnewsgroup{comp.text.tex}:
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \URL{``\link{Re: Adding a \cs{ref} to a counter?}''}^^A
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% {http://groups.google.com/group/comp.text.tex/msg/c3f2a135ef5ee528}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{Version}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{Version}{2000/09/07 v2.0}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Documentation added.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Package rewritten, new commands added.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{Version}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{Version}{2006/02/20 v3.0}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Support for \xpackage{hyperref} and \xpackage{nameref} improved.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Support for \xpackage{titleref} and \xpackage{babel}'s shorthands added.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% New: \cs{refused}, \cs{getrefbykeydefault}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{Version}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \begin{Version}{2008/08/11 v3.1}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% Code is not changed.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% URLs updated.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{Version}
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann% \end{History}