From Wiki
Revision as of 12:27, 27 June 2015 by Massifr (talk | contribs)
Jump to navigation Jump to search

< 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


Other useful commands for working with counters are

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

Coupling Counters

Two counters can be coupled by


For example


Default value of counter one: \getnumber[one]

We increment counter 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


Testing the Value of a Counter

If you need to test the value of a counter, use \rawcountervalue, not \getnumber:

 Strange, {\tt getnumber} worked.
 Using {\tt getnumber} does not work.

 Ok, the test with {\tt rawcountervalue} worked.
 Strange, {\tt rawcountervalue} failed.

Names of Commonly Used Counters

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