![]() |
The style-sheet language | ![]() |
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.
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
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>
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
<assign|chapter-nr|2>
The operand must be a literal string and is interpreted as a
file name. The content of this file is typeset in place of the
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
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.
This primitive evaluates the current value of the environment variable var (literal string). This is useful to display counters and generally to implement environment-sensitive behavior.
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.
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
Macros can be used to define new tags and to build procedural abstractions in style files.
Older versions of TeXmacs used to make a distinction between macros
(all children accessible) and functions (no accessible child). In
modern TeXmacs there are only macros: the accessibility of children
is determined heuristically and can be controlled with
This primitive returns a macro (the TeXmacs analogue of a λ-expression) with n arguments, named after the literal strings var-1 until var-n.
New tags are defined by storing macros in the environment.
Most of the time, macros are stored without scope with
<assign|abbr|<macro|x|<group|x>>>
Storing a
This primitive is used to retrieve the arguments of a macro
within its body. For instance, <
This tag is similar to
When more than one arguments are specified, <
This primitive returns a macro (the TeXmacs analogue of a
λ-expression) capable of taking any number of arguments.
The arguments are stored in the macro variable with name var (a literal string) during the
evaluation of the body. The
i-th individual argument can then be accessed using
<
This primitive evaluates to a tree whose root is labeled by root and whose children are the result of applying the macro foo to the children of the macro argument with name var.
By default, the macro foo is applied to all children. If first has been specified, then we rather start at the i-th child of var, where i is the result of evaluating first. If last has been specified to, then we stop at the j-th child of var (the j-th child not being included), where j is the result of evaluating last. In this last case, the arity of the returned tree is therefore j - i.
Stated otherwise,
The
The
<assign|comma-extra|<macro|x|,
x>>
<
assign
|
comma-separated
|
<
xmacro
|
args
|
<\concat|
<arg|args|0>
<map-args|comma-extra|concat|args|1>
This primitive evaluates to the tree with the same label as the expansion of the argument var and whose subtrees are the result of the evaluation of the subtrees of the expansion of var.
This primitive is useful to expand macros which are the result
of a computation: it applies the macro which is the result of
the evaluation of foo to the
arguments arg-1 until arg-n.
The
Actually, in the current implementation, foo may either evaluate to a macro or to a literal string which gives the name of a macro. However, we discourage users to rely on the second case.
In the code below, <
<
assign
|
filter
|
<
macro
|
pred
|
t
|
<\if|
<equal|<length|t>|0>
<tuple>
<\merge|
<\if|
<compound|pred|<look-up|t|0>>
<tuple|<look-up|t|0>>
<tuple>
<filter|pred|<range|t|1|<length|t>>>
As an application, we may define a macro <
<assign|evens|<macro|t|<filter|<macro|x|<equal|<mod|x|2>|0>>|t>>>
The arity and children accessibility of tags defined by macros
are determined heuristically by default. The
Returns the label of the tree obtained when evaluating expression.
Returns the label of the tree obtained when evaluating expression.
This primitive can be used to typeset if-body only if the condition is satisfied. If the optional else-body is specified, then it is typeset if and only if the condition fails.
<macro|x|<if|<visibility-flag>|x>>
the macro argument x is accessible if and only if <visibility-flag> evaluates to true. This condition cannot necessarily be checked a priori. For certain editing operations, like searches or spell checking, the incorrect determination of the accessability may lead to the positioning of the cursor at unaccessible places, or to the ignorance of certain markup. In the future, we plan to improve this aspect of the editor, but it is better to avoid conditional markup whenever another solution can be found.
<assign|cold|<macro|x|<with|color|blue|x>>>
<assign|hot|<macro|x|<with|color|red|x>>>
<assign|adaptive|<macro|x|<compound|<if|<summer>|hot|cold>|x>>>
These commands are respectively equivalent to
<if|cond-1|body-1|⋯<if|cond-n|body-n>>
<if|cond-1|body-1|⋯<if|cond-n|body-n|else-body>>
This construct maybe used in order to repeatly execute a given body while a given condition is satisfied. For instance, when declaring
<
assign
|
count
|
<
macro
|
from
|
to
|
<
with
|
i
|
from
|
<\concat|
<while|<less|i|to>|i,
<assign|i|<plus|i|1>>>
to
the code <count|1|50> produces
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50
This section describes several primitives for controlling the way
expressions in the style-sheet language are evaluated. The
primitives are analoguous to the
Typeset the result of the evaluation of expr.
This primitive is usually combined with a tag like
Evaluation of the expression <
This tag is a variant of the
<assign|hello|<quasiquote|<macro|name|<unquote|<localize|Hello>> name.>>>
may be used to define a macro
<assign|hello|<macro|name|Bonjour
name.>>
Notice however that it is usually better not to use the
<assign|hello|<macro|name|<localize|Hello> name.>>
the typesetting of <hello|Name> would naturally adapt itself to the current
language, while the above version would always use the
language at the moment of the definition of the macro.
Nevertheless, the first form does have the advantage that the
localization of the word “Hello” only has to be
computed once, when the macro is defined. Therefore, the
This tag is used in combination with
This tag is similar to
<
assign
|
fun
|
<
xmacro
|
x
|
<\quasi|
<tree|dup|<unquote*|<quote-arg|x>>|<unquote*|<quote-arg|x>>>
Then <fun|a|b|c> is typeset as
This tag is a shortcut for <
<assign|new-theorem|<macro|name|text|<quasi|<assign|<unquote|name>|<macro|body|<surround|<no-indent><strong|<unquote|text>.
>|<right-flush>|body>>>>>>
may be used in order to define new theorem-like environments.
When retrieving an environment variable var,
one is usually interested in its typesetted value, as given by
<
When retrieving (a subexpression of) a macro argument var, one is usually interested in its
typesetted value, as given by <
Funcational operators are used for computational purposes during the
typesetting phase, such as increasing counters, localizing strings
like “theorem” and so on. A fundamental set of basic
functional operators are built-in primitives. New functional
operators can easily be added using the
If expr is a string, the length of the string is returned. For instance, <length|Hello> evaluates to 5.
Return the substring of expr starting at position start and ending at position end (not included). For instance, <range|hottentottententententoonstelling|9|15> evaluates to tenten.
This primitive may be used to concatenate several strings expr-1 until expr-n. For instance, <merge|Hello|World> produces HelloWorld.
Renders a number in a specified way. Supported values for render-as are
Returns the current date in a specified format
(which defaults to a standard language-specific format when
empty) and a specified language
(which defaults to English). The format is similar to the one
used by the
Returns the translation of a string what of the language from into the language into, using the built-in TeXmacs dictionaries. The languages should be specified in lowercase letters. For instance, <translate|File|english|french> yields “Fichier”.
The list of currently available languages can be checked in
the
$TEXMACS_PATH/languages/natural/dic
When attempting to use a non-existing dictionary, the program
may quit. For most purposes, it is more convenient to use the
Add or subtract numbers or lengths. For instance, <plus|1|2.3|5> yields 8.3 and <plus|1cm|5mm> produces . In the case of subtractions, the last argument is subtracted from the sum of the preceding arguments. For instance, <minus|1> produces -1 and <minus|1|2|3|4> yields 2.
Multiply two numbers expr-1 until expr-n. One of the arguments is also allowed to be a length, in which case a length is returned. For instance, <times|3|3> evaluates to 9 and <times|3|2cm> to .
Divide the product of all but the last argument by the last argument. For instance, <over|1|2|3|4|5|6|7> evaluates to 102.857, <over|3spc|7> to , and <over|1cm|1pt> to 28.4528.
Compute the result of the division of an integer expr-1 by an integer expr-2, or its remainder. For instance, <div|18|7>=2 and <mod|18|7>=4.
Return the result of the comparison between two numbers or lengths. For instance, <less|123|45> yields false and <less|123mm|45cm> yields true.
Returns the result of the boolean or/and on the expressions expr-1 until expr-n. For instance, <or|false|<equal|1|1>|false> yields true.
Returns the exclusive or of two expressions expr-1 and expr-2, i.e. <xor|true|true> yields false.
Returns the negation of expr.
Forms a tuple from the expressions expr-1 until expr-n.
Tests whether a given expression expr evaluates to a tuple.
If expr is a tuple, then we return its arity. For instance, <length|<tuple|hop|hola>> evaluates to 2.
Returns the element with index which in tuple. For instance, <look-up|<tuple|a|b|c>|1> yields b.