Environment and variables

The evaluation and typesetting processes are controlled by variables. The environment is the collection all variables and values at a given point in the document, we also sometime call it the context.

Production of boxes is controlled by a number of typesetter variables. For example the text color is set by the color variable:

Some colored text.

(concat "Some " (with "color" "dark red" "colored") " text.")

Variables are also used for computational purposes during the evaluation step.

  1. Weirdly

    numbered list

(enumerate (document
  (concat (item) "Weirdly")
  (concat (assign "itemnr" "3") (item) "numbered list")))

The typesetting language uses dynamic scoping of variables. That means that macros the procedures defining non-primitive markup can access and modify variables in their calling context. In the previous example, the enumerate macro initializes itemnr to 0 and the item macro increments it by one and show its value.

In additions to variables set by primitives and markup inside a document, some variables are defined in the initial environment. This is the environment at the point (0 0) of the document, the start of the first paragraph.

Default initial values
are set by the document style and packages. The default initial environment is the collection of all default initial values defined by the typesetter, the document style and the document packages.
Document initial values
are stored out-of-band like the document style, they do not show in the editor window using Scheme functions like init-env . The document initial environment is the default initial environment modified by the document initial values.

Some variables, like header and footer variables, must be set inside the document, their initial environment value is ignored. Generally, they should be set by header and sectioning markup.

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