Difference between revisions of "Counters"

From Wiki
Jump to navigation Jump to search
m (corrected misspelt ConTeXt name)
Line 1: Line 1:
 
< [[Main Page]] | [[Inside ConTeXt]] >
 
< [[Main Page]] | [[Inside ConTeXt]] >
  
Countext provides a higher layer of API to access various counters. For example, to set the page number to a certain value use
+
ConTeXt provides a higher layer of API to access various counters. For example, to set the page number to a certain value use
  
 
<texcode>
 
<texcode>

Revision as of 16:52, 21 June 2013

< Main Page | Inside ConTeXt >

ConTeXt provides a higher layer of API to access various counters. For example, to set the page number to a certain value use

 \setnumber[page]{1}

Other useful commands for working with counters are

    \resetnumber    [page]
    \incrementnumber[page]
    \decrementnumber[page]
    \savenumber     [page]
    \restorenumber  [page]
    \getnumber      [page]

Coupling Counters

Two counters can be coupled by

 \definenumber[one]
 \definenumber[two][one]

For example

\definenumber[one]
\definenumber[two][one]


Default value of counter one: \getnumber[one]

We increment counter two
\incrementnumber[two]

New value of counter one: \getnumber[one]

By default counters are reset with each new chapter. To have a counter which isn’t reset one needs “way=bytext" and to remove the chapter number from the \getnumber result one has to add “prefix=no”.

An example definition is

\definenumber[examplecounter][way=bytext,prefix=no]

Names of Commonly Used Counters

  • page for pagenumbers
  • formula for formulanumbers
  • table for tables
  • figure for figures