Home | Download | Help | Contribute | Plug-ins | About | Contact | Search
Standard environment variables
Manual | Top | Previous | Next

The way TeXmacs typesets documents is influenced by so called environment variables. The style-sheet language uses a so called environment (or context) to store both environment variables and macros. The environment variables are subdivided into two catagories: built-in variables and additional variables provided by style files. Built-in variables usually affect the layout, while additional variables mostly serve computational purposes. In the next sections of this chapter, we will describe all built-in environment variables.

A typical built-in environment variable is color. The value of an environment variable may be changed permanently using assign and temporarily using the with primitive:

Some colored text.

Some <with|color|dark red|colored> text.

Counters are typical environment variables defined in style-sheets.

  1. A weirdly

    numbered list...

<enumerate|<document|<item>A weirdly|<assign|item-nr|3><item>numbered list...>>

The typesetting language uses dynamic scoping of variables. That means that macros can access and modify variables in their calling context. In the previous example, the enumerate macro locally initializes item-nr to 0 (uses with) and the item macro increments it by one and shows its value. Since enumerate locally redefines item-nr, the original value of item-nr is restored on exit.

Each document comes with an initial environment with the initial values of environment values, i.e. their values just before we typeset the document. If an environment variable does not occur in the initial environment, then its initial value defaults to its value after typesetting the document style and possible additional packages. The initial environment before typesetting the style files and packages is built-in into the editor.

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.

1.General environment variables

modetext
(major mode)

This very important environment variable determines the current mode. There are four possible values: text (text mode), math (mathematical mode), prog (programming mode) and src (source mode). The behaviour of the editor (menus, keystrokes, typesetting, etc.) depends heavily on the mode. For example, the following code may be used in order to include a mathematical formula inside text:

The formula a2 + b2 = c2 is well known.

The formula <with|mode|math|a<rsup|2>+b<rsup|2>=c<rsup|2>> is well known.

Some other environment variables (mainly the language and the font) also depend on the current mode (in this context, the source mode always behaves in a similar way as the text mode). During copy&paste and search&replace operations, TeXmacs tries to preserve the mode.

languageenglish

math-languagetexmath

prog-languagescheme
(language)

A second major environment variable is the current language. In fact, there are three such environment variables: one for each mode. The language in which content is written is responsible for associating a precise semantics to the content. This semantics is used for different purposes:

At the moment, the current language is mainly used as a hint for indicating the semantics of text: it is not required that a text written in English contains no spelling errors, or that a formula written in a mathematical language is mathematically or even syntactically correct. Nevertheless, the editor is intended to enforce correctness more and more, especially for mathematics.

The language may be specified globally for the whole document in DocumentLanguage and locally for a piece of text in FormatLanguage.

prog-sessiondefault
(name of programming session)

This environment variables is used in addition to the prog-language variable in order to determine a concrete implementation as well as a particular instance of the current programming language. For instance, in case of the Maxima language, different implementation may be used fooor the underlying Lisp. Similarly, one may wish to run two different instances of Maxima in parallel.

magnification1
(magnification)

This variable determines the magnification which is applied to all content. Magnifications bigger than one are typically useful for presentations (from slides or from a laptop):

normal
big
huge

normal<htab|5mm><with|magnification|2|big><htab|5mm><with|magnification|3|huge>

The magnification should not be confused with the font size: contrary to the magnification, the font size may also affect the shapes of the glyphs. The magnification is usually specified for the entire document in DocumentMagnification.

bg-colorwhite
(background color)

The background color for your document, as specified in DocumentColorBackground.

colorblack
(foreground color)

The current foreground color of text and graphics, as specified in DocumentColorForeground or FormatColor.

preamblefalse
(edit source tree?)

This flag determines whether we are editing normal text or a style-sheet. The source tree or preamble mode may be selected in DocumentViewEdit source tree.

info-flagshort
(informative flags style)

This variable controls the rendering of informative flags, which are for instance used to indicate the locations of otherwise invisible labels or typesetting directives. The info-flag may take the values none, short and detailed:

Label 1, Label 2, Label 3.

<with|info-flag|none|Label 1<label|flag-label-1>>, <with|info-flag|short|Label 2<label|flag-label-2>>, <with|info-flag|detailed|Label 3<label|flag-label-3>>.

Usually, the rendering of informative flags is specified document-wide in DocumentViewInformative flags.

2.Specifying the current font

In this section, we describe the environment variables which control the rendering of fonts. Several parameters may be defined independently for each mode (the font name, variant, series and shape), whereas other parameters are uniform for all modes. Font properties may be controlled globally for the whole document in DocumentFont and locally for document fragments in FormatFont.

From an abstract point of view, a font is defined to be a graphically consistent way of rendering strings. Fonts are usually made up from glyphs like “x”, “ffi”, “α”, “∑”, etc. When rendering a string, the string is decomposed into glyphs so as to take into account ligatures (like fi, fl, ff, ffi, ffl). Next, the individual glyphs are positioned while taking into account kerning information (in “xo” the “o” character is slightly shifted to the left so as to take profit out of the hole in the “x”). In the case of mathematical fonts, TeXmacs also provides a coherent rendering for resizable characters, like the large brackets in

((())).

Similarly, a font family is a family of fonts with different characteristics (like font weight, slant, etc.), but with a globally consistent rendering. One also says that the fonts in a font family “mix well together”. For instance, the standard computer modern roman font and its bold and italic variants mix well together, but the computer modern roman font and the Avant Garde font do not.

Remark 1. For the future, it is planned to replace the font variant and font shape variables by a larger range of properties to individually control the slant, serifs, small-caps, and so on. It is also planned to systematically use Unicode fonts with possible additional glyphs for mathematics. This should automatically enable the use of Cyrillic characters inside Russian text and similarly for other languages.

fontroman

math-fontroman

prog-fontroman
(font name)

These variables control the main name of the font, also called the font family. For instance:

Computer modern roman, Pandora, Chancery, Palatino

Similarly, TeXmacs supports various mathematical fonts:

Roman: a2 + b2 = c2

Adobe: a2 + b2 = c2

New roman: a2 + b2 = c2

Concrete: a2 + b2 = c2

font-familyrm

math-font-familymr

prog-font-familytt
(font variant)

This variable selects a variant of the major font, like a sans serif font, a typewriter font, and so on. As explained above, variants of a given font are designed to mix well together. Physically speaking, many fonts do not come with all possible variants (sans serif, typewriter, etc.), in which case TeXmacs tries to fall back on a suitable alternative font.

Typical variants for text fonts are rm (roman), tt (typewriter) and ss (sans serif):

roman, typewriter and sans serif

In maths mode, a distinction is made between the mathematical variants mr (roman), mt (typewriter) and ms (sans serif) and textual variants rm (roman), bf (bold), etc. In the first case, variables and operators are usually rendered in a different slant, contrary to the second case:

ms: sin (x + y) = sin x cos y + cos x sin y

ss: sin (x + y) = sin x cos y + cos x sin y

font-seriesmedium

math-font-seriesmedium

prog-font-seriesmedium
(font weight)

The font series determines the weight of the font. Most fonts only provide regular and bold font weights. Some fonts also provide light as a possible value.

medium, bold

font-shaperight

math-font-shapenormal

prog-font-shaperight
(font shape)

The font shape determines other characters of a font, like its slant, whether we use small capitals, whether it is condensed, and so on. For instance,

upright, slanted, italic, left slanted, Small Capitals, proportional typewriter, bold condensed, flat sans serif, long

font-base-size10
(font base size)

The base font size is specified in pt units and is usually invariant throughout the document. Usually, the base font size is 9pt, 10pt, 11pt or 12pt. Other font sizes are usually obtained by changing the magnification or the relative font-size.

9pt, 10pt, 11pt, 12pt

font-size1
(font size)

The real font size is obtained by multiplying the font-base-size by the font-size multiplier. The following standard font sizes are available from FormatSize:

size multiplier size multiplier
Tiny 0.59 Very small 0.71
Small 0.84 Normal 1
Large 1.19 Very large 1.41
Huge 1.68 Really huge 2

Table 1. Standard font sizes.

From a mathematical point of view, the multipliers are in a geometric progression with factor sqrt4 (2). Notice that the font size is also affected by the index level.

dpi600
(fonts rendering quality)

The rendering quality of raster fonts (also called Type 3 fonts), such as the fonts generated by the Metafont program is controlled through its discretization precision in dots per inch. Nowadays, most laser printers offer a printing quality of at least 600dpi, which is also the default dpi setting for TeXmacs. For really high quality printing, professionals usually use a precision of 1200dpi. The dpi is usually set once and for all for the whole document.

3.Typesetting mathematics

math-level0
(index level)

The index level increases inside certain mathematical constructs such as indices and fractions. When the index level is high, formulas are rendered in a smaller font. Nevertheless, index levels higher than 2 are all rendered in the same way as index level 2; this ensures that formulas like

x =
1 +
1
x + ⅇx
1 +
1
x +
1
x

remain readable. The index level may be manually changed in FormatIndex level, so as to produce formulas like

xyz

x<rsup|<with|math-level|0|y<rsup|<with|math-level|0|z>>>>

math-displayfalse
(display style)

This environement variable controls whether we are in display style or not. Formulas which occur on separate lines like

n
H1,…,αn)
=
1
α1
+ ⋯ +
1
αn

are usually typeset in display style, contrary to inline formulas like

n
H1,…,αn)
=
1
α1
+ ⋯ +
1
αn
. As you notice, formulas in display style are rendered using a wider spacing. The display style is disabled in several mathematical constructs such as scripts, fractions, binomial coefficients, and so on. As a result, the double numerators in the formula

H1 ,…,α n ) =
n
1
α1
+ ⋯ +
1
αn

are typeset in a smaller font. You may override the default settings using FormatDisplay style.

math-condensedfalse
(condensed display style)

By default, formulas like a + ⋯ + z are typeset using a nice, wide spacing around the + symbol. In formulas with scripts like ⅇa + ⋯ + z + ⅇα + ⋯ + ζ the readability is further enhanced by using a more condensed spacing inside the scripts: this helps the reader to distinguish symbols occurring in the scripts from symbols occurring at the ground level when the scripts are long. The default behaviour can be overridden using FormatCondensed.

math-vpos0
(position in fractions)

For a high quality typesetting of fraction, it is good to avoid subscripts in numerators to descend to low and superscripts in denominators to ascend to high. TeXmacs therefore provides an additional environment variable math-vpos which takes the value 1 inside numerators, −1 inside denominators and 0 otherwise. In order to see the effect the different settings, consider the following formula:

a
2
−1
+ a
2
0
+ a
2
1

<with|math-vpos|-1|<group|a

2
−1
>>+<with|math-vpos|0|<group|a
2
0
>>+<with|math-vpos|1|<group|a
2
1
>>

In this example, the grouping is necessary in order to let the different vertical positions take effect on each a

2
i
. Indeed, the vertical position is uniform for each horizontal concatenation.

4.Paragraph layout

par-modejustify
(paragraph alignment)

This environment variable specifies the alignment of the different lines in a paragraph. Possible values are left, center, right and justify:

This paragraph is aligned to the left. This paragraph is aligned to the left. This paragraph is aligned to the left.

This paragraph is has been centered. This paragraph is has been centered. This paragraph is has been centered.

This paragraph is aligned to the right. This paragraph is aligned to the right. This paragraph is aligned to the right.

This paragraph has been justified. Justification is the default alignment mode for paragraphs. So be it.

Table 2. The supported modes for alignment.

par-hyphennormal
(quality of hyphenation)

This parameter controls the quality of the hyphenation algorithm. Possible values are normal and professional. The professional hyphenation algorithm uses a global algorithm on the entire paragraph, whereas the normal one uses a faster first-fit algorithm.

The difference between the different hyphenation algorithms provided by TeXmacs is seen best for long paragraphs which are typeset into a narrow column. The professional hyphenation usually succeeds to minimize the number of ugly gaps between words.

The difference between the different hyphenation algorithms provided by TeXmacs is seen best for long paragraphs which are typeset into a narrow column. The professional hyphenation usually succeeds to minimize the number of ugly gaps between words.

Table 3. Comparison different hyphenation algorithms. At the left hand side, we have used the normal algorithm and on the right hand side the professional one. Even though there are some ugly gaps at the right hand side around “hyphenation”, the really bad gap around “The” on the left hand side has been avoided.

par-widthauto
(paragraph with)

This environment variable controls the width of paragraphs. By default, it is automatically determined as a function of the page (or screen) size and margins.

par-left0cm

par-right0cm
(left and right margins)

These environment variables specify absolute left and right margins for the paragraph, with respect to the default left and right margins (which are determined as a function of the page layout). For instance:

This text uses the default margins.

This text uses a left margin of 1cm

This text uses a left margin of 2cm

This text uses a left margin of 3cm

The left and right margins of this text have both been set to 3cm.

Environments like itemize and quote-env which maybe nested usually compute new margins as a function of the old values by adding or subtracting some space:

< assign | quote-env | < macro | body |

<\surround|

<vspace*|0.5fn>

|

<right-flush><vspace|0.5fn>

|

<with|par-left|<plus|par-left|3fn>|par-right|<plus|par-right|3fn>|par-first|0fn|par-par-sep|0.25fn|body>

>

> >

par-first1.5fn
(first indentation)

The par-first parameter specifies the additional indentation which is used for the first line of the paragraph. The aim of first indentations is to indicate the starts of new paragraphs. An alternative technique is the use of vertical whitespace.

The article and book styles in TeXmacs indictate the starts of new paragraphs through the use of a first indentation.

The generic and letter styles rather use vertical whitespace.

The generic and letter styles in TeXmacs indictate the starts of new paragraphs through the use of vertical whitespace.

The article and book styles rather use a first indentation.

Table 4. Two classical ways to indicate the starts of new paragraphs.

par-sep0.2fn
(extra separation between successive lines)

The sum of the font size and par-sep determines the ideal distance between two successive base lines in a paragraph (also called the “base line skip”). Of course, when the lines contain large boxes, then this distance may need to be increased. When 1fn for par-sep, one may for instance produce documents with a double interline space:

A double interline space corresponds to par-sep1fn. Double interline spaces are often used by lazy people who want to pretend that they have written many pages. They generally do not care about tropical rain forests.

In the case when two successive lines use different base line skips, then the maximal value is used in order to compute the ideal distance between their baselines. This allows for a reasonable spacing when the font size is changed from one paragraph to another:

Normal text.

Some very large text.

And back to normal.

par-line-sep0.025fn*
(extra space between lines)

This parameter corresponds an additional stretchable amount of whitespace between successive lines in a paragraph. Setting par-line-sep to a small stretchable value which defaults to 0 allows the page breaker to correctly stretch pages which contain a very long textual paragraph. Indeed, par-line-sep vanishes, then the height of a textual paragraph is of the form a + b n, where a and b are constants and n is the number of lines. There is no reason why the usable height of a page should be of this form.

par-par-sep0.5fn*
(extra space between paragraphs)

The par-par-sep parameter specifies the amount of vertical whitespace which separates two successive paragraphs. This space is determined in stretchable length units. By default, TeXmacs does not use any whitespace between successive paragraphs, except when no nice page breaks could be found (this explains the use of the fn* length unit). Starts of new paragraphs are rather indicated through the use of first indentations (see table ?).

In the case when two successive paragraph use different paragraph separations, then the maximum of the two is taken. In fact, the par-par-sep length is added to both the vertical spacing before and the vertical spacing after the paragraph.

par-hor-sep0.5fn

par-ver-sep0.2fn
(minimal space between ink)

When a paragraph contains several exceptionally large boxes, then TeXmacs attempts to “shove successive lines into another” as long as none of the boxes collide:

Consider a fraction which decends more than usual like

1
x + 1
at the end of a line and an expression like ⅇ x which is higher than usual.

When these expressions occur at different places, then TeXmacs tries to render the successive lines in a compact manner.

In the case of a fraction

1
x + 1
and an exceptionally high expression at the wrong place, like the expression ⅇ x here, the boxes are separated by env-ver-sep .

As soon as the horizontal distance between two large boxes is less than par-hor-sep, then they are considered to be in collision. In that case, the vertical distance between them must be at least par-ver-sep. Also, the amount of showing never exceeds 1ex.

When using an interline space of 1.5 or 2, the default value of par-ver-sep allows the user to type larger formulas in the text while preserving a uniform layout. When using a small par-sep and a large par-ver-sep, the distance between two successive lines remains small, except when their contents are horizontally close. This may for instance be used to reduce the space between a short like followed by a centered equation.

par-fnote-sep0.2fn
(minimal space between different footnotes)

This parameter controls the amount of vertical space between successive footnotes.

par-columns1
(number of columns)

This environment variable specifies the number of columns into which the text is being typeset. Different numbers of columns may be used successively in the same document.

par-columns-sep2fn
(distance between columns)

This environment variable specifies the amount of horizontal whitespace which separates different columns in multi-column mode.

5.Page layout

In this section, we describe how TeXmacs fills pages with typesetted content. Besides specifying the settings on how to print a document, the user may also determine the way pages should be rendered on screen. It should be noticed that the number of environment variables is redundant in the sense that some variables are computed as a function of other ones. For instance, by default, the paragraph width is computed as a function of the page size and the left and right margins.

Paper specific variables

page-typea4
(the size of pages)

Specify the size of a page when printing out. Most standard formats are available in DocumentPageSize. By default, the paper size is the one of your printer (the default printer settings may be changed in EditPreferencesPrinter). When the page-type is set to user, then the page size is given by page-width and page-height.

page-orientationportrait
(page orientation)

The orientation of pages can be either portrait or landscape.

page-nr0
(current page number)

The current page number. This environment variable should be manipulated with care, since it is not yet available at typesetting time. For a reliable determination of page numbers, one may combine the label and page-ref primitives. Nevertheless, the page-nr variable can be used in the macros which render page headers and footers.

page-the-page
(display the page number)

This environment variable really contains the macro which is used for rendering the page-number. By default, it renders page-nr. The macro takes no arguments. In order to simulate a document whose first page number os 123, one may redefine

<assign|page-the-page|<macro|<plus|page-nr|122>>>

page-breakingoptimal
(page breaking algorithm)

This parameter specifies the page breaking algorithm. The default optimal algorithm takes into account the global document and tries hard to avoid bad page breaks. The alternative sloppy algorithm uses a fast first-fit algorithm, but produces bad page break with a higher probability. The medium quality algorithm is the same as the optimal algorithm, except for two column content.

page-flexibility1.0
(flexibility for stretching)

This parameter specifies how much stretchable spaces may be extended or reduced in order to fill pages which are too short or too long. A page flexibility of 1 allows spaces to be stretched to their minimal and maximal values. A page flexibility of 0 prevents spaces to be stretched. For other values of page-flexibility the behaviour is linear.

page-shrink1fn
(allowed amount of page shrinking)

In the case when it is very hard to find good page breaks, this parameter specifies an additional amount of space by which a page is allowed to be reduced.

page-extend0fn
(allowed amount of page extensions)

In the case when it is very hard to find good page breaks, this parameter specifies an additional amount of space by which a page is allowed to be extended.

Screen specific variables

page-mediumpapyrus
(the page medium)

This environment variable, which is initialized using DocumentPageType, specifies how pages are rendered on the screen. The following values are available:

paper

Page breaks are visually indicated on the screen. This mode is useful for ajusting the final version of a document before printing or sending it to a publisher. However, the use of this mode slows down the editor since every modification in the document triggers the page-breaking algorithm.

Notice also that the mere selection of this mode does not imply the screen margins and page decorations to be as on paper. In order to previsualize a document in a fully realistic way, you should also set DocumentViewPage layoutShow header and footer and DocumentViewPage layoutMargins as on paper.

papyrus
The paragraph width is the same as on paper, but page breaking is disabled. This mode is most useful during the editing phase of a document which will ultimately be printed out. It combines a reasonable editing speed with realistic line breaks.
automatic
The paragraph width is as large as possible so as to fit into the current window and page breaking is disabled. This setting, which makes optimal use of the available space on your screen, is useful for documents which are not intended to be printed out. It may for instance be selected when using TeXmacs as a browser or as an interface to computer algebra systems.

page-screen-width10cm
(width of the rendering window)

In automatic mode, this environement variable contains the width of the screen.

page-screen-height10cm
(height of the rendering window)

In automatic mode, this environement variable contains the height of the screen.

page-screen-margintrue
(special margins for screen editing?)

This flag specifies whether the screen margins are manually specified by the user, or whether they are the same as on paper.

page-screen-left5mm

page-screen-right5mm

page-screen-top15mm

page-screen-bot15mm
(left margin on screen)

When page-screen-margin is true, then these environment variables determine the margins which are to be used for rendering on the screen.

page-show-hffalse
(show headers and footers on screen?)

This flag determines whether the page headers and footers should be visible on the screen. When set to true, it should be noticed that the headers and footers are not always correctly updated when editing. In the case when you suspect them to be wrong, refreshing the display by scrolling down and up should display the correct values.

Specifying the margins

The parameters for page margins are represented schematically at the left hand side in figure ?. One may either specify the paragraph width as a function of the left and right margins, or vice versa. The left and right margins may depend on whether the page number is odd or even.

page-width-marginfalse