![]() |
Standard environment variables | ![]() |
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
Some colored text.
Some <with|color|dark
red|colored>
text.
Counters are typical environment variables defined in style-sheets.
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
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.
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
language≔english
math-language≔texmath
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:
The language controls (among other parameters like the mode and the document format) the way content is being converted from one context to another.
Currently, no real language-dependent conversions have been implemented yet. But in the future one may imagine that copying a piece of English text to a document written in French will perform an automatic translation. Similarly, a mathematical document might be converted from infix to postfix notation.
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
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
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<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
The current foreground color of text and graphics, as specified in
This flag determines whether we are editing normal text or a
style-sheet. The source tree or preamble mode may be selected in
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:
<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
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
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.
font≔roman
math-font≔roman
These variables control the main name of the font, also called the font family. For instance:
Similarly, TeXmacs supports various mathematical fonts:
Roman: a2 +
b2 =
c2
Adobe: a2 +
b2 =
c2
New roman: a2 +
b2 =
c2
Concrete: a2 +
b2 =
c2
font-family≔rm
math-font-family≔mr
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
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-series≔medium
math-font-series≔medium
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-shape≔right
math-font-shape≔normal
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,
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
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
|
||||||||||||||||||||
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.
The rendering quality of raster fonts (also called Type 3 fonts),
such as the fonts generated by the
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
1 +
|
||||
1 +
|
remain readable. The index level may be manually changed in
x<rsup|<with|math-level|0|y<rsup|<with|math-level|0|z>>>>
This environement variable controls whether we are in display style or not. Formulas which occur on separate lines like
| n |
| H(α1,…,αn) |
| 1 |
| α1 |
| 1 |
| αn |
are usually typeset in display style, contrary to inline formulas like
| n |
| H(α1,…,αn) |
| 1 |
| α1 |
| 1 |
| αn |
| n | ||||
|
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
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:
| 2 |
| −1 |
| 2 |
| 0 |
| 2 |
| 1 |
<with|math-vpos|-1|<group|a
>>+<with|math-vpos|0|<group|a
2
−1
>>+<with|math-vpos|1|<group|a
2
0
>>
2
1
In this example, the grouping is necessary in order to let the
different vertical positions take effect on each
a
. Indeed, the vertical position is uniform for
each horizontal concatenation.
2
i
This environment variable specifies the alignment of the different lines in a paragraph. Possible values are left, center, right and justify:
|
||||
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.
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-left≔0cm
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
<
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>
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 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-sep≔1fn.
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.
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.
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-sep≔0.5fn
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
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
at the end of a line and an expression like
ⅇ
ⅇx
which is higher than usual.
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
.
1
x + 1
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.
This parameter controls the amount of vertical space between successive footnotes.
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.
This environment variable specifies the amount of horizontal whitespace which separates different columns in multi-column mode.
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.
Specify the size of a page when printing out. Most standard
formats are available in
The orientation of pages can be either portrait or landscape.
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
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>>>
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.
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.
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.
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.
This environment variable, which is initialized using
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
In automatic mode, this environement variable contains the width of the screen.
In automatic mode, this environement variable contains the height of the screen.
This flag specifies whether the screen margins are manually specified by the user, or whether they are the same as on paper.
page-screen-left≔5mm
page-screen-right≔5mm
page-screen-top≔15mm
When page-screen-margin is true, then these environment variables determine the margins which are to be used for rendering on the 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.
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-margin≔false