12.07.2015 Views

The memoir class - The UK TeX Archive

The memoir class - The UK TeX Archive

The memoir class - The UK TeX Archive

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

18.8. Changing counters18.8 CHANGING COUNTERSThis is effectively a bundling of the chngcntr package [Wil01e].\newcounter{〈ctr〉}[〈within〉]\thectrIn La<strong>TeX</strong> a new counter called, say ctr, is created by the \newcounter command as\newcounter{ctr}. If the optional 〈within〉 argument is given, the counter ctr is resetto zero each time the counter called within is changed; the within counter must existbefore it is used as the optional argument. <strong>The</strong> command \thectr typesets the value ofthe counter ctr. This is automatically defined for you by the \newcounter command totypeset arabic numerals.\counterwithin{〈ctr〉}{〈within〉}\counterwithin*{〈ctr〉}{〈within〉}<strong>The</strong> \counterwithin macro makes a 〈ctr〉 that has been initially defined by\newcounter{ctr} act as though it had been defined by \newcounter{ctr}[within].It also redefines the \thectr command to be \thewithin.\arabic{ctr}. <strong>The</strong> starredversion of the command does nothing to the original definition of \thectr.\counterwithout{〈ctr〉}{〈within〉}\counterwithout*{〈ctr〉}{〈within〉}<strong>The</strong> \counterwithout macro makes the ctr counter that has been initially defined by\newcounter{ctr}[within] act as though it had been defined by \newcounter{ctr}.It also redefines the \thectr command to be \arabic{ctr}. <strong>The</strong> starred version of thecommand does nothing to the original definition 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 twostyles. <strong>The</strong> current value of ctr is unaffected by these commands. If you want to changethe value use \setcounter, and to change the typesetting style use \renewcommand on\thectr.\letcountercounter{〈counterA〉}{〈counterB〉}\unletcounter{〈counterA〉}At times it is handy to ‘let’ one counter act as if it was a different counter. Say you havetwo constructions, each with their own counter A and B, now you want them to cooperate,counting in unison. This can be done using the \letcountercounter.\letcountercounter{〈counterA〉}{〈counterB〉} \lets (make the same) 〈counterA〉 to〈counterB〉. <strong>The</strong> original of 〈counterA〉 is kept, such that you can unlet it later.\unletcounter{〈counterA〉} restores 〈counterA〉 to its un\let condition.This feature can be quite handy. Say for instance you want figures and tables to counterwithin the same counter (say table), then we need each change to the figure counter toactually act on the table counter. \letcountercounter{figure}{table} solves theproblem.327

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!