Welcome to the TeXnik website (under construction) Counter - FAQ |
|||||||||||||||||||||||||||||||||||
|
Number of Figures/Pages/Tables/... in a Document The number of pages in a document is available with the command \ref{TotPages} from
package totpages from CTAN. If you want also write the total numbers of figures/tables/... at the beginning of your document, than try the following as an example for tables and documentclass book:
\newcommand*{\OrigChapter}{} \let\OrigChapter\chapter \newcounter{abstables} \renewcommand*{\chapter}{% \addtocounter{abstables}{\value{table}}% \OrigChapter } \newcommand*{\AbsTables}{0} \makeatletter \AtBeginDocument{% \AtEndDocument{% \addtocounter{abstables}{\value{table}}% \immediate\write\@mainaux{% \string\gdef\string\AbsTables{\number\value{abstables}}% }% }% } \makeatotherIn your document you can write at the beginning or anywhere: This doc has \AbsTables tables and \ref{TotPages} pages.The above code for the preamble is different, if you
Continuing Counting
Increment of Counters
New Counter in latex preamble in LaTeX the counter is named c@myCounter
Resetting a counter Removing a given reset
\@removefromreset{myCounter}{section}Now myCounter is no longer reset when a new section starts. Automatic reset
\@addtoreset{myCounter}{section}Manual reset \setcounter{mycounter}{0}myCounter maybe any predefined or new defined (with \newcounter) counter.
Predefined Counter The following counter are predefined by LaTeX:
mpfootnote is the counter for footnotes in minipages. Remember that these counters are only predefined if the environment is also defined! For example: there is no chapter-counter in document-class article, because there is no chapter environment.
Numbering of Counters Any counter can be printed with the prefix-command \the. A user defined counter myCounter can be printed with \themyCounter. The style can be changed with the \renewcommand. For example: in LaTeX preamble: \renewcommand{\thefigure}{\thechapter-\arabic{figure}} \renewcommand{\thetable}{\arabic{chapter}.\roman{table}.} \renewcommand{\theequation}{\thechapter-\arabic{equation}}Now the figures and equations are numbered like 2-5, means "chapter-number". This works only for book classes, because artice classes do not have chapters. The tables are numbered like 2.IV. |