![]() |
Customizing sectional tags | ![]() |
By default, TeXmacs provides the standard sectional tags from LaTeX part, chapter, section, subsection, subsubsection, paragraph, subparagraph, as well as the special tag appendix. TeXmacs also implements the unnumbered variants part*, chapter*, etc. and special section-like tags bibliography, table-of-contents, the-index, the-glossary, list-of-figures, list-of-tables.
Remark 1. Currently, the sectional tags take one argument, the section title, but a second argument with the body of the section is planned to be inserted in the future (see the experimental structured-section package). For this reason (among others), style files should never redefine the main sectional tags, but rather customize special macros which have been provided to this effect.
From a global point of view, an important predicate macro is sectional-short-style. When it evaluates to true, then appendices, tables of contents, etc. are considered to be at the same level as sections. In the contrary case, they are at the same level as chapters. Typically, articles use the short sectional style whereas book use the long style.
All standard sectional tags are defined in section-base using the meta-macro new-section; <new-section|<em|x>> defines the tags x and x* together with a counter x-nr and the customizable macros described below. The rendering of a sectional tag x is controlled through the macros x-sep, x-post-sep, x-title, x-unnumbered-title and x-numbered-title. The x-sep macro prints the separator between the section number and the section title. It defaults to the macro sectional-sep, which defaults in its turn to a wide space (<space|2spc>). Similarly, x-post-sep (which defaults to sectional-post-sep) is printed after the title. The predicate x-display-numbers (true by default) determines whether the tag x is numbered at all. For instance, after redefining
<assign|sectional-sep|<macro| – >> |
sectional titles would typically look like
1 – Hairy GNUs |
The x-unnumbered-title and x-numbered-title macros respectively specify how to render unnumbered and numbered section titles. Usually, the user only needs to modify x-title, since both x-unnumbered-title and x-numbered-title are based on x-title. However, if the numbers have to be rendered in a particular way, then it may be necessary to redefine x-numbered-title. For instance, consider the redefinition
<assign|subsection-numbered-title| <macro|name|<\sectional-normal| <with|font-series|bold|<the-subsection>. >name > >> |
This has the following effect on the rendering of subsection titles:
2.3. Very hairy GNUs |
Notice that the section-base package provides several useful helper macros like sectional-normal.
Remark 2. Sectional titles can either be rendered in a “short” or in the “long” fashion. By default, paragraphs and subparagraphs use the short rendering, for which the body starts immediately at the right of the title:
My paragraph
Blah, blah, and more blahs…
|
All other sectional tags use the long rendering, in which case the section title takes a separate line on its own:
My sectionBlah, blah, and more blahs… |
We do not recommend to modify the standard settings (i.e. to render paragraphs in a long way or sections in a short way). If you really want to do so, then we recommend to redefine the corresponding macros x-title using the helper macros sectional-short, sectional-normal, etc. (and their -bold and -italic variants) from section-base, rather than redefining the sectional tags themselves. This will ensure upward compatibility when sectional tags will take an additional argument (see remark ?).
Besides their rendering, several other aspects of sectional tags can be customized:
The call-back macro x-clean can be used for cleaning some counters when a new section is started. For instance, in order to prefix all standard environments by the section counter, you may use the following lines (this is what section-book does with chapters, and what the number-long-article package does with sections):
<document|<assign|section-clean|<macro|<reset-subsection><reset-std-env>>>|<assign|display-std-env|<macro|nr|<section-prefix>nr>>> |
The call-back macro x-header should be used in order to modify page headers and footers when a new section is started. Typically, this macro should call header-primary, or header-secondary, or do nothing.
The call-back macro x-toc should be used in order to customize the way new sections appear in the table of contents.