docs/Development-Case

annotate chngcntr.sty @ 3:5084c6cb99f2

added short explanations to all workflows; german names for workflows, etc; minor stuff
author meillo@marmaro.de
date Mon, 14 Jan 2008 20:48:46 +0100
parents
children
rev   line source
meillo@0 1 % chngcntr.sty
meillo@0 2 %
meillo@0 3 % Provides commands to change the resetting of counters.
meillo@0 4 % Instructions for use are at the end of this file.
meillo@0 5 %
meillo@0 6 % author: Peter Wilson (CUA)
meillo@0 7 % (now at peter.r.wilson@boeing.com)
meillo@0 8 % Released under the Latex Project Public License
meillo@0 9 %
meillo@0 10 %
meillo@0 11 \NeedsTeXFormat{LaTeX2e}
meillo@0 12 \ProvidesPackage{chngcntr}[2001/03/30 v1.0 change counter resetting]
meillo@0 13 %
meillo@0 14 % This package uses David Carlisle's \@removefromreset command as
meillo@0 15 % specified in the remreset package available from CTAN as
meillo@0 16 % macros/latex/contrib/supported/carlisle/remreset.sty
meillo@0 17 % It is \provided here as a convenience to the user, and with
meillo@0 18 % David Carlisle's permission.
meillo@0 19 % START OF DAVID CARLISLE'S CODE
meillo@0 20 \providecommand{\@removefromreset}[2]{{%
meillo@0 21 \expandafter\let\csname c@#1\endcsname\@removefromreset
meillo@0 22 \def\@elt##1{%
meillo@0 23 \expandafter\ifx\csname c@##1\endcsname\@removefromreset
meillo@0 24 \else
meillo@0 25 \noexpand\@elt{##1}%
meillo@0 26 \fi}%
meillo@0 27 \expandafter\xdef\csname cl@#2\endcsname{%
meillo@0 28 \csname cl@#2\endcsname}}}
meillo@0 29 % END OF DAVID CARLISLE'S CODE
meillo@0 30
meillo@0 31 %%\@ifbothc@t@s{<package>}{<counter>}{<within>}{<code when both are counters>}
meillo@0 32 \newcommand{\@ifbothc@t@s}[4]{%
meillo@0 33 \@ifundefined{c@#2}{% counter undefined
meillo@0 34 \PackageError{#1}{#2 is not a counter}{\@eha}}%
meillo@0 35 {% else counter is defined
meillo@0 36 \@ifundefined{c@#3}{% within undefined
meillo@0 37 \PackageError{#1}{#3 is not a counter}{\@eha}}%
meillo@0 38 {% else both counter and within are defined
meillo@0 39 #4}}}
meillo@0 40
meillo@0 41 %%\counterwithout*{<counter>}{<within>}
meillo@0 42 \newcommand{\counterwithout}{\@ifstar{\c@t@soutstar}{\c@t@sout}}
meillo@0 43 \newcommand{\c@t@soutstar}[2]{%
meillo@0 44 \@ifbothc@t@s{chngcntr}{#1}{#2}{\@removefromreset{#1}{#2}}}
meillo@0 45 \newcommand{\c@t@sout}[2]{%
meillo@0 46 \@ifbothc@t@s{chngcntr}{#1}{#2}{\@removefromreset{#1}{#2}%
meillo@0 47 \@namedef{the#1}{\arabic{#1}}}}
meillo@0 48
meillo@0 49
meillo@0 50 %%\counterwithin*{<counter>}{<within>}
meillo@0 51 \newcommand{\counterwithin}{\@ifstar{\c@t@sinstar}{\c@t@sin}}
meillo@0 52 \newcommand{\c@t@sinstar}[2]{%
meillo@0 53 \@ifbothc@t@s{chngcntr}{#1}{#2}{\@addtoreset{#1}{#2}}}
meillo@0 54 \newcommand{\c@t@sin}[2]{%
meillo@0 55 \@ifbothc@t@s{chngcntr}{#1}{#2}{\@addtoreset{#1}{#2}%
meillo@0 56 \@namedef{the#1}{\@nameuse{the#2}.\arabic{#1}}}}
meillo@0 57
meillo@0 58
meillo@0 59 \endinput
meillo@0 60
meillo@0 61 %%%%%%%%%%%%%%%%%%
meillo@0 62 % USAGE
meillo@0 63 %%%%%%%%%%%%%%%%%%
meillo@0 64 %
meillo@0 65 % In LaTeX, a new counter called, say `ctr', is created by the command
meillo@0 66 % \newcounter{ctr}[within]. If the optional within argument is given
meillo@0 67 % the the counter `ctr' is reset to zero each time the counter `within'
meillo@0 68 % changes. The command \thectr typesets the value of the counter ctr.
meillo@0 69 % This is automatically defined by \newcounter and is initialised
meillo@0 70 % to typeset arabic numerals.
meillo@0 71 %
meillo@0 72 %%%%%%%%%%%%%%%%%
meillo@0 73 % \counterwithin
meillo@0 74 % \counterwithin*
meillo@0 75 %%%%%%%%%%%%%%%%%
meillo@0 76 % It is sometimes desireable to change a counter that has been defined
meillo@0 77 % by \newcounter{ctr} to act as though it had been defined as
meillo@0 78 % \newcounter{ctr}[within]. The package provides the command
meillo@0 79 % \counterwithin{ctr}{within} that accomplishes this. By default,
meillo@0 80 % it also redefines the \thectr command so that it typesets values
meillo@0 81 % in the style \thewithin.\arabic{ctr}. The starred version of the
meillo@0 82 % command suppresses the redefinition of \thectr
meillo@0 83 % (e.g., \counterwithin*{ctr}{within}).
meillo@0 84 %
meillo@0 85 %%%%%%%%%%%%%%%%%%
meillo@0 86 % \counterwithout
meillo@0 87 % \counterwithout*
meillo@0 88 %%%%%%%%%%%%%%%%%%
meillo@0 89 % Likewise, the command \counterwithout{ctr}{within} changes a
meillo@0 90 % counter that has been created by \newcounter{ctr}[within] to act
meillo@0 91 % as though it had been created by \newcounter{ctr}. By default it
meillo@0 92 % also redefines the \thectr command so that it just typesets an arabic
meillo@0 93 % numeral. The starred version of the command suppresses the redefinition
meillo@0 94 % of \thectr.
meillo@0 95 %
meillo@0 96 % Any number of \counterwithin{ctr}{...} and \counterwithout{ctr}{...}
meillo@0 97 % commands can be issued for a given counter, ctr, if you wish to toggle
meillo@0 98 % between the two styles. The current value of ctr is unaffected by
meillo@0 99 % \counterwithin and \counterwithout. If you want to change the value
meillo@0 100 % after one of these commands, use \setcounter{ctr}{...}, and to change
meillo@0 101 % the typeseting style use \renewcommand{\thectr}{...}.
meillo@0 102 %
meillo@0 103 %
meillo@0 104 % Peter W.
meillo@0 105 % 2001/03/30
meillo@0 106 %
meillo@0 107