diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-12 23:58:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-12 23:58:22 +0000 |
commit | c6b827c6f5aab4beff40b7bef80e869c6815d826 (patch) | |
tree | 1ed61d883ba88897fbf68a71547b4a7286e57368 /Master/texmf-dist/tex/latex/ltxmisc/chngcntr.sty | |
parent | 7f9543ffaf295484b99beae71350a519562df613 (diff) |
ltxmisc
git-svn-id: svn://tug.org/texlive/trunk@1056 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ltxmisc/chngcntr.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxmisc/chngcntr.sty | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/ltxmisc/chngcntr.sty b/Master/texmf-dist/tex/latex/ltxmisc/chngcntr.sty new file mode 100644 index 00000000000..e1a6de835cf --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxmisc/chngcntr.sty @@ -0,0 +1,107 @@ +% chngcntr.sty +% +% Provides commands to change the resetting of counters. +% Instructions for use are at the end of this file. +% +% author: Peter Wilson (CUA) +% (now at peter.r.wilson@boeing.com) +% Released under the Latex Project Public License +% +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{chngcntr}[2001/03/30 v1.0 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 +% + |