GNU TeXmacsUser manualReferenceAboutEnglishยทDeutsch
Environment primitives

The current environment both defines all style parameters which affect the typesetting process and all additional macros provided by the user and the current style. The primitives in this section are used to access and modify environment variables.

<assign|var|val>
(variable mutation)

This primitive sets the environment variable named var (string value) to the value of the val expression. This primitive is used to make non-scoped changes to the environment, like defining markup or increasing counters.

This primitive affects the evaluation process —through value, provides, and macro definitions— and the typesetting process —through special typesetter variables.

Example 1. Enabling page breaking by style.

The page-medium is used to enable page breaking. Since only the initial environment value for this variable is effective, this assignation must occur in a style file, not within a document.

<assign|page-medium|paper>

Example 2. Setting the chapter counter.

The following snippet will cause the immediately following chapter to be number 3. This is useful to get the the numbering right in book style when working with projects and include.

<assign|chapter-nr|2>

The var operand is evaluated and must yield a string. When var designates a paragraph or page layout variable, the change is transmitted to the paragraph or page typesetter.

<provide|var|val>
(default definition)

This primitive is similar to assign, except that the assignment only takes place if the environment variable var is not yet defined. It is useful for providing default definitions in packages, which can be overridden by previously loaded packages.

<with|var-1|val-1|\(\cdots\)|var-n|val-n|body>
(variable scope)

This primitive temporarily sets the environment variables var-1 until var-n (in this order) to the evaluated values of val-1 until val-n and typesets body in this modified environment. All non-scoped change done with assign to var-1 until var-n within body are reverted at the end of the with.

This primitive is used extensively in style files to modify the typesetter environment. For example to locally set the text font, the paragraph style, or the mode for mathematics.

<value|var>
(variable value)

This primitive evaluates the current value of the environment variable var (whose name is itself evaluated). This is useful to display counters and generally to implement environment-sensitive behavior. See also quote-value for retrieving the value without evaluating it.

<or-value|var-1|\(\cdots\)|var-n>
(first defined value)

Evaluates to the value of the first variable among var-1 until var-n which is defined and not uninitialized; the last variable is taken if it is defined. If none of the variables is defined, then the result is the empty string.

<provides|var>
(definition predicate)

This predicate evaluates to true if the environment variable var (string value) is defined, and to false otherwise.

That is useful for modular markup, like the session environments, to fall back to a default appearance when a required package is not used in the document.

<new-theme|theme|var-1|\(\cdots\)|var-n>

<copy-theme|theme|theme-1|\(\cdots\)|theme-n>

<select-theme|theme|theme-1|\(\cdots\)|theme-n>

<apply-theme|theme>
(themes)

Themes are named collections of values for environment variables, which are used for instance by the presentation and poster styles. The new-theme primitive declares a new theme for the variables var-1 until var-n: for each variable v it saves the current value in a variable theme-v, and it defines a macro with-theme which sets v to the value of theme-v. When some var-i is itself the name of a theme (that is, with-var-i exists), then the new theme inherits from it. The copy-theme primitive creates a new theme with the same variables and values as the existing themes theme-1 until theme-n, and select-theme sets the values of the variables of the existing theme to those of theme-1 until theme-n. Finally, apply-theme assigns the values of a theme to the corresponding environment variables, in a non-scoped way. The names of the themes are literal strings. These primitives are implemented in

Typeset/Env/env_exec.cpp

(edit_env_rep::exec_new_theme and following).

For more information on how the environment is implemented, see the chapter on macro expansion, and in particular the section on the typesetting environment.

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