In LaTeX, the objects coming with an automatic numbering, such as tables, figures, footnotes, etc., contain an internal counter definition:
- \newcounter{counter_name}
- \newcounter{counter_name}[resetting_environment]
The second differs from the first by adding a resetting environment, which appears as once the environment changes, the counter will be reset to 0. That is why some counters are continuous across the whole document, while some others are reset at certain point.
Since the initialization of the counter is embedded in the definition of each object, which is really difficult to modify directly, so in order to be completely flexible on configuring the numbering, we can use the "chngcntr" package. There are basically a pair of commands that we can use:
- \counterwithin{1}{2} or \counterwithin*{1}{2}
- These commands help to add a resetting environment to a counter without it
- The first compulsory argument denotes the counter name, for instance "footnote" for footnotes, "table" for tables, "ExNo" for linguistic examples, etc.
- The second compulsory argument denotes the environment within which you want to reset the counter, for instance, "chapter", "section", etc.
- \counterwithout{1}{2} or \counterwithout*{1}{2}
- These commands help to eliminate a resetting environment for a counter under its influence
- Same as above, the first compulsory argument denotes the counter name
- Same as above, the second compulsory argument denotes the environment within which you want to eliminate the resetting effect for a counter
The starred version, "\counterwithin*" or "\counterwithout*" will suppress the redefinition of another counter-related command "\the{counter_name}", for more details, please look at the reference.
Reference:
http://mirrors.linsrv.net/tex-archive/macros/latex/contrib/chngcntr/chngcntr.pdf
http://en.wikibooks.org/wiki/LaTeX/Counters
没有评论:
发表评论