Customizing numbered textual environments

TeXmacs provides three standard types of numbered textual environments: theorem-like environments, remark-like environments and exercise-like environments. The following aspects of these environments can be easily customized:

Defining new environments

First of all, new environments can be added using the meta-macros new-theorem, new-remark and new-exercise. These environments take two arguments: the name of the environment and the name which is used for its rendering. For instance, you may wish to define the environment experiment by

<new-theorem|experiment|Experiment>

When available in the TeXmacs dictionaries, the text “Experiment” will be automatically translated when your document is written in a foreign language. In the section about how to define new environments, it is also explained how to define other numbered textual environments (besides theorems, remarks and exercises).

Customization of the rendering

The principal rendering of the environments can be customized by redefining the render-theorem, render-remark and render-exercise macros. These macros take the name of the environment (like “Theorem 1.2”) and its body as arguments. For instance, if you want theorems to appear in a slightly indented way, with a slanted body, then you may redefine render-theorem as follows:

<assign|render-theorem|<macro|which|body|<document|<padded-normal|1fn|1fn|<surround|<theorem-name|which<theorem-sep>>||<with|font-shape|slanted|par-left|<plus|par-left|1.5fn>|body>>>>>>

This redefinition produces the following effect:

Theorem 1.

This is a theorem which has been typeset in a slanted font.

By default, the theorems are rendered as remarks with the only difference that their bodies are typeset in an italic font. Hence, redefining the render-remark macro will also affect the rendering of theorems. The default render-proof macro is also based on render-remark.

Instead of redefining the entire rendering, the user might just wish to customize the way names of theorems are rendered or redefine the separator between the name and the body. As the user may have noticed by examining the above redefinition of render-theorem, these aspects are controlled by the macros theorem-name and theorem-sep. For instance, consider the following redefinitions:

<assign|theorem-name|<macro|name|<with|color|dark red|font-series|bold|name>>>

<assign|theorem-sep|<macro|: >>

Then theorem-like environments will be rendered as follows:

Proposition 2: This proposition is rendered in is a fancy way.

Customization of the numbering

In the sections about counters and counter groups, it is explained how to customize the counters of numbered environments for particular purposes. For instance, by redefining inc-theorem, you may force theorems to reset the counter of corollaries:

<\quasi|

<\assign|

inc-theorem

|

<macro|<compound|<unquote|inc-theorem>><reset-corollary>>

>

>

Notice the trick with quasi and unquote in order to take into account additional action which might have been undertaken by the previous value of the macro inc-theorem.

The following code from number-long-article.ts is used in order to prefix all standard environments with the number of the current section:

<assign|section-clean|<macro|<reset-subsection><reset-std-env>>>

<assign|display-std-env|<macro|nr|<section-prefix>nr>>

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".