diff options
author | Karl Berry <karl@freefriends.org> | 2009-09-04 00:58:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-09-04 00:58:29 +0000 |
commit | 8fda9c296233009102ded664a7386ef0f035a76b (patch) | |
tree | 35c70328acca054d8ef441a14f83ecb0bb79ed95 /Master/texmf-dist/tex/latex/chngcntr | |
parent | 3f5a3b753720b2b4acb4c94ec6966886da93803d (diff) |
chngcntr update (2sep09)
git-svn-id: svn://tug.org/texlive/trunk@15064 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chngcntr')
-rw-r--r-- | Master/texmf-dist/tex/latex/chngcntr/chngcntr.sty | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/chngcntr/chngcntr.sty b/Master/texmf-dist/tex/latex/chngcntr/chngcntr.sty new file mode 100644 index 00000000000..1550016a02a --- /dev/null +++ b/Master/texmf-dist/tex/latex/chngcntr/chngcntr.sty @@ -0,0 +1,110 @@ +% chngcntr.sty +% +% Provides commands to change the resetting of counters. +% Instructions for use are at the end of this file. +% +% Author: Peter Wilson, Herries Press +% Maintainer: Will Robertson (will dot robertson at latex-project dot org) +% Released under the Latex Project Public License +% +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{chngcntr}[2009/09/02 v1.0a change counter resetting] +% +% This package uses David Carlisle's \@removefromreset command as +% specified in the remreset package available from CTAN as +% macros/latex/contrib/supported/carlisle/remreset.sty +% It is \provided here as a convenience to the user, and with +% David Carlisle's permission. +% START OF DAVID CARLISLE'S CODE +\providecommand{\@removefromreset}[2]{{% + \expandafter\let\csname c@#1\endcsname\@removefromreset + \def\@elt##1{% + \expandafter\ifx\csname c@##1\endcsname\@removefromreset + \else + \noexpand\@elt{##1}% + \fi}% + \expandafter\xdef\csname cl@#2\endcsname{% + \csname cl@#2\endcsname}}} +% END OF DAVID CARLISLE'S CODE + +%%\@ifbothc@t@s{<package>}{<counter>}{<within>}{<code when both are counters>} +\newcommand{\@ifbothc@t@s}[4]{% + \@ifundefined{c@#2}{% counter undefined + \PackageError{#1}{#2 is not a counter}{\@eha}}% + {% else counter is defined + \@ifundefined{c@#3}{% within undefined + \PackageError{#1}{#3 is not a counter}{\@eha}}% + {% else both counter and within are defined + #4}}} + +%%\counterwithout*{<counter>}{<within>} +\newcommand{\counterwithout}{\@ifstar{\c@t@soutstar}{\c@t@sout}} +\newcommand{\c@t@soutstar}[2]{% + \@ifbothc@t@s{chngcntr}{#1}{#2}{\@removefromreset{#1}{#2}}} +\newcommand{\c@t@sout}[2]{% + \@ifbothc@t@s{chngcntr}{#1}{#2}{\@removefromreset{#1}{#2}% + \@namedef{the#1}{\arabic{#1}}}} + + +%%\counterwithin*{<counter>}{<within>} +\newcommand{\counterwithin}{\@ifstar{\c@t@sinstar}{\c@t@sin}} +\newcommand{\c@t@sinstar}[2]{% + \@ifbothc@t@s{chngcntr}{#1}{#2}{\@addtoreset{#1}{#2}}} +\newcommand{\c@t@sin}[2]{% + \@ifbothc@t@s{chngcntr}{#1}{#2}{\@addtoreset{#1}{#2}% + \@namedef{the#1}{\@nameuse{the#2}.\arabic{#1}}}} + + +\endinput + +%%%%%%%%%%%%%%%%%% +% USAGE +%%%%%%%%%%%%%%%%%% +% +% In LaTeX, a new counter called, say `ctr', is created by the command +% \newcounter{ctr}[within]. If the optional within argument is given +% the the counter `ctr' is reset to zero each time the counter `within' +% changes. The command \thectr typesets the value of the counter ctr. +% This is automatically defined by \newcounter and is initialised +% to typeset arabic numerals. +% +%%%%%%%%%%%%%%%%% +% \counterwithin +% \counterwithin* +%%%%%%%%%%%%%%%%% +% It is sometimes desireable to change a counter that has been defined +% by \newcounter{ctr} to act as though it had been defined as +% \newcounter{ctr}[within]. The package provides the command +% \counterwithin{ctr}{within} that accomplishes this. By default, +% it also redefines the \thectr command so that it typesets values +% in the style \thewithin.\arabic{ctr}. The starred version of the +% command suppresses the redefinition of \thectr +% (e.g., \counterwithin*{ctr}{within}). +% +%%%%%%%%%%%%%%%%%% +% \counterwithout +% \counterwithout* +%%%%%%%%%%%%%%%%%% +% Likewise, the command \counterwithout{ctr}{within} changes a +% counter that has been created by \newcounter{ctr}[within] to act +% as though it had been created by \newcounter{ctr}. By default it +% also redefines the \thectr command so that it just typesets an arabic +% numeral. The starred version of the command suppresses the redefinition +% of \thectr. +% +% Any number of \counterwithin{ctr}{...} and \counterwithout{ctr}{...} +% commands can be issued for a given counter, ctr, if you wish to toggle +% between the two styles. The current value of ctr is unaffected by +% \counterwithin and \counterwithout. If you want to change the value +% after one of these commands, use \setcounter{ctr}{...}, and to change +% the typeseting style use \renewcommand{\thectr}{...}. +% +% +% Peter W. +% 2001/03/30 +% +% Change History: +% v1.0a - New maintainer (Will Robertson) +% + |