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