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 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|<rigid|x>>>
Storing a
This primitive is used to retrieve the arguments of a macro within
its body. For instance, <
This tag is similar to
The argument namespace is distinct from the environment, <
The value of
When more than one argument is 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 -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 -th child of var, where is the result of evaluating first. If last has been specified too, then we stop at the -th child of var (the -th child not being included), where is the result of evaluating last. In this last case, the arity of the returned tree is therefore .
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
Sets the arity to the given fixed value (literal integer).
Make it impossible to deactivate the tag with normal editor actions. Inaccessible children become effectively uneditable.
Make it impossible to position the caret within the tag when it is active, so children can only be edited when the tag is inactive.
Returns the label of the tree obtained when evaluating expression.
Returns the arity 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 accessibility 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 repeatedly 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 analogous 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 typeset value, as given by <
When retrieving (a subexpression of) a macro argument var,
one is usually interested in its typeset value, as given by <
Functional 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
Lower case Roman: <number|18|roman> xviii.
Upper case Roman: <number|18|Roman> XVIII.
Lower case letters: <number|18|alpha> r.
Upper case letters: <number|18|Alpha> R.
Arabic numbers: <number|18|arabic> 18.
Footnotes symbols: <number|2|fnsymbol> .
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.
Return the subtuple of expr starting at position start and ending at position end (not included). For instance, <range|<tuple|a|hola|hop|b|c>|2|4> evaluates to .
This primitive may be used to concatenate several tuples expr-1 until expr-n. For instance, <merge|<tuple|1|2>|<tuple|3|4|5>> produces .
The tags described in this section are used to control the rendering of style files and style file elements. It both contains markup for activation and deactivation of content and for the rendering of tags.
These tags can be used to temporarily or permanently change the activity of the content. In usual documents, tags are by default active. In style files, they are by default inactive. For instance, an activated fraction is rendered as
1 |
2 |
; when deactivated, it is rendered as <frac|1|2>.
The
The
<assign|love|<macro|from| from from.>>
This tag is used for the default inline rendering of an inactive tag
with a given name and arguments arg-1 until arg-n.
For instance, <inline-tag|foo|x|y>
produces <foo|x|y>. The style of the rendering
may be customized in the
These tags are similar to
<document|<open-tag|theorem>|<indent|The weather should be nice today.>|<close-tag|theorem>>
is rendered by default as
<\theorem|
The weather should be nice today.
>
The rendering may be customized in a similar way as in the case of
This tag may be used in order to temporarily modify the rendering of
inactive tags, by setting each environment variable var-i
to val-i in the local typesetting context
of body. When importing a style file,
each
This tag may be used in order to render an inactive tags as whether
we applied the macro
These tags are used only temporarily when entering special content.
When pressing Meta+Q, a
When pressing \, a
The
The rendering macros for source trees are built-in into TeXmacs. They should not really be considered as primitives, but they are not part of any style file either.
Typeset the body using some indentation.
Flush to the right. This macro is useful to make the end of a block environment run until the right margin. This allows for more natural cursor positioning and a better layout of the informative boxes.
These macros are used for the syntactic highlighting of source trees. They determine how to render subtrees which correspond to macro names, variable names, argument names, verbatim content, integers, lengths and error messages.
These macros are used for the identification of style files and
packages and their corresponding D.T.D.s. The
The
This primitive allows the user to implement macros in
The arguments arg-1 until arg-n
are evaluated and then passed as trees to scheme-foo.
When defining a macro which relies on extern scheme code, it is
therefore recommended to pass the macro arguments using the
<assign|inc-div|
<macro|x|y|<\extern|
(lambda (x y) ‘(frac ,x (concat "1+" ,y)))
|
<quote-arg|x>
|
<quote-arg|y>
>
>>
It has been foreseen that the accessibility of the macro arguments
x and y is
preserved for this kind of definitions. However, since TeXmacs does
not heuristically analyze your
Notice also that the
Adds content to the auxiliary section aux of the document. This tag is used for instance by <nocite|citekey> to add entries to the automatically generated bibliography at the end of the document, without inserting a citation in the text.
This tag is used to in order to inform the user about information
which is present in the document, but not visible when printed out.
TeXmacs displays such informative flags for labels, formatting
directives such as page breaks, and so on. In
The two-argument variant displays an informative flag with a given
content and color.
The content is only rendered when
selecting
The primitives in this section are merely for internal use by TeXmacs only. They are documented for the sake of completeness, but you should only use them if you really know what you are doing.
This primitive is mainly used for default uninitialized value of environment variables; the main advantage of this tag is to be distinct from the empty string.
This primitive is mainly used for default uninitialized value of environment variables; the main advantage of this tag is to be distinct from the empty string.
This value is less likely to be encountered than
This primitive should never appear in documents. It is provided as aid in tracking down invalid constructs. It is produced at evaluation time by any kind of primitive which is given improper operands.
The
This tag is included for future compatibility with XML. It is used for encoding XML-style attributes by TeXmacs trees. For instance, the fragment
<blah color="blue" emotion="verbose"> Some XML stuff </blah>
would typically be represented as
<blah|<attr|color|blue|emotion|verbose>|Some XML stuff>
Associate a special meaning to some content. Currently, no real use has been made of these tags.
Used to represent temporarily saved values on a stack.
This primitive is only intended for internal use by the
This internal primitive is used for rewriting an inactive tree into a new tree whose rendering corresponds to the rendering of the inactive tree. It may be successfully invoked from within a macro.
e.g. <assign|show-inactive|<macro|x|<rewrite-inactive|x|>>>
which might be invoked to show itself or another assigned variable
using
Yet to be implemented primitives for starting a new double page.
The identity macro is built-in into TeXmacs. It should not really be considered as a primitive, but it is not part of any style file either.
In addition to these primitives for internal use only, there are also
quite a few obsolete primitives, which are no longer being used by
TeXmacs, but whose names should be avoided when creating your own
macros. The full list of obsolete primitives is: