Counters and counter groups

In TeXmacs, all automatic numbering of theorems, sections, etc. is done using “counters”. Such counters may be individual counters (like equation-nr) or belong to a group of similar counters (like in the case of theorem-nr). TeXmacs allows for the customization of counters on an individual or groupwise basis. Typically, you may redefine the rendering of a counter (and let it appear as roman numerals, for instance), or undertake special action when increasing the counter (such as resetting a subcounter).

New individual counters are defined using the following meta-macro:

<new-counter|x>

Defines a new counter with name x. The counter is stored in the numerical environment variable x-nr and in addition, the following macros are defined:

<the-x>

Retrieve the counter such as it should be displayed on the screen.

<reset-x>

Reset the counter to 0.

<inc-x>

Increase the counter. This macro may also be customized by the user so as to reset other counters (even though this is not the way things are done in the standard style files).

<next-x>

Increase the counter, display the counter and set the current label.

For the purpose of customization, the new-counter macro also defines the following macros:

<display-x|nr>

This is the macro which is used for transforming the numerical value of the counter into the value which is displayed on the screen.

<counter-x|x>

This internal macro is used in order to retrieve the name of the environment variable which contains the counter. By default, this macro returns “nr-x”, but it may be redefined if the counter belongs to a group.

As noticed in the introduction, TeXmacs uses counter groups in order to make it possible to treat similar counters in a uniform way. For instance the counter group theorem-env regroups the counters theorem, proposition, lemma, etc.. New counter groups and are defined using:

<new-counter-group|g>

Create a new counter group with name g. This results in the creation of the following macros:

<display-in-g|x|nr>

<counter-in-g|x>

These macros are similar to the macros display-x and counter-x from above, but relative to the counter group. The name x of the counter in consideration is passed as an argument.

New counters can be added to the group using:

<add-to-counter-group|x|g>

Defines a new counter x and add it to the counter group g. For counters in groups, the macros display-x and counter-x are replaced with the corresponding macros display-in-g and counter-in-g for their groups. Nevertheless, two new macros ind-display-x and ind-counter-x are defined which may take over the roles of display-x and counter-x in the case when the group consists of individual counters.

At any moment, you may decide whether the counters of a group share a common group counter, or whether they all use their individual counters. This feature is used for instance in order to switch between American style numbering and European style numbering:

<group-common-counter|g>

Use a common counter for the group (which is stored in the environment variable g-nr).

<group-individual-counters|g>

Use an individual counter for each member of the group (this is the default).

We notice that group counters may recursively belong to super-groups. For instance, the following declarations are from env-base.ts:

<document|<new-counter-group|std-env>>

<new-counter-group|theorem-env>

<add-to-counter-group|theorem-env|std-env>

<group-common-counter|theorem-env>

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".