![]() |
Mathematical formulas | ![]() |
One of the main purposes of TeXmacs is to edit mathematical formulas.
If the cursor is inside a formula (i.e. inside
“math mode”), then the mode sensitive menus and toolbars
provide buttons for entering common mathematical constructs.
Similarly, as will be detailed in this section, the bahaviour of the
keyboard changes so as to allow for the rapid typing of mathematical
symbols. For instance, typing - > inserts the arrow
.
Starting with version 1.0.7.10, TeXmacs also incorporates several features for the “semantic” editing of mathematical formulas, which will be described at the end of this section. When used appropriately, this allows you to write documents in which all formulas are at least correct from a syntactical point of view. A “syntax corrector” is included to assist you with this task. Documents with more semantics are for instance useful when using formulas as inputs for a computer algebra system. Such documents are also less likely to contain “typos”. Other interesting features, such as semantic search and replace, should be developed in the feature.
TeXmacs provides three main ways in order to enter a mathematical formulas into the main text:


This entry corresponds to small inline formulas like
inside a textual paragraph. Note that formulas
are typeset specially so they do not take too much vertical space.
For example, limits are always displayed on the left. Limits can
be displayed below in formulas with 



This entry is used for entering bigger displayed equations, like
which are typeset in a paragraph of their own. You may use the shortcut in order to give the equation a number (or to remove the number of an equation). Also, allows you to switch between inline formulas and displayed equations.


This entry allows you to create an
The first column is centered to the right, the second one at the
middle and the last one at the left. An other typical use of the
in which many entries of the left column are left open.
The Greek characters are obtained in TeXmacs using the -key.
For instance, math:greek a yields
and math:greek G yields
.
Similarly, , ,
and can be
used in order to type bold, calligraphic, fraktur and blackboard bold
characters. For instance,
yields
, S-F6 R yields
and yields
.
Greek characters can also be obtained as “variants” of
Latin characters using the var-key. For instance,
p var yields
. The
var-key is also used for obtaining variants of the
Greek letters themselves. For instance, both math:greek p
var and p var var yield
.
An alternative way to enter blackboard bold characters is to type the
same capital twice. For instance, Z Z yields
.
Some symbols admit many variants. For instance, <
yields
, < var yields
, < var var yields
, < var var var yields
, and so on. You may “cycle back” among the
variants using S-var. For instance, < var
var S-var is equivalent to < var.
Many other mathematical symbols are obtained by “natural”
key-combinations. For instance, - > yields
, - - > yields
and > = yields
. Similarly,
| var - yields
, | -
> yields
and - > <
- yields
. The following general rules
hold in order to enter mathematical symbols:
, but > =
var yields
. Similarly, <
var var yields
, < var var
= yields
and < var var =
var yields
. Also, P
var yields
and e
var yields the constant
.
and @
x yields
. Similarly, @ var
+ yields
.
and < = / yields
. Notice that < = var var / yields
, while < = var var / var
yields
.
, but - - > ! ^ x yields
.
The logical relations
and
are obtained using & and %. The
operators
and
are
natural variants & var and % var.
Various miscellaneous symbols can be optained using the
prefix.
Notice that certain symbols with a different mathematical meaning are
sometimes denoted in a similar way; such symbols are called
homoglyphs. For instance, the vertical bar
can be used as a separator for defining sets
,
but also as the binary relation “divides”
.
Often, but not always, homoglyphs admit a different spacing. The most
annoying ambiguity is between invisible multiplication
and function application
, which
are entered using the shortcuts * resp.
space.
In order to facilitate certain automated treatments of your documents, such as mathematical syntax checking, we incite authors to pay attention to the homoglyph problem when entering formulas. For more information on this issue and how TeXmacs can assist you to use the appropriate notations, we refer to our section on the semantics of mathematical symbols.
The main mathematical objects are created using the math prefix as follows:
|
||||||||||||||||||
Primes, subscripts and superscripts are created as follows:
|
|||||||||||||||||||||
Some important mathematical constructs are actually tabular constructs and are documented separately.
Brackets inside mathematical formulas should always match: as soon as
you enter an opening bracket “(
”,
TeXmacs will automatically insert the matching closing bracket
“
)”. You may disable this feature
using 



Sometimes, you do not want the closing bracket, or you may want to
replace it by another closing bracket. No problem: if your cursor is
just before the closing bracket inside
, then
pressing ] will turn the expression into
. Alternatively, deletion of a bracket will actually turn
it into an invisible bracket, after which you can replace
it by an arbitrary opening or closing bracket.
By default, the sizes of the brackets are adjusted to the expression between the brackets. Small delimiters, which are created using the -prefix, keep their sizes independently of the enclosed expression. Alternatively, you may use in order to toggle between large and small delimiters.
For some delimiters, such as
, the opening and
closing delimiters coincide. For instance, entering a vertical bar
| will produce an absolute value. The (small)
bar-separator
is obtained using , or as a variant using | var.
The big bar-separator is entered using . In TeX and LaTeX, such large separators do not
exist; they are used for producing the vertical bars in formulas like
There may be as many middle delimiters between a left and a right delimiter as one wishes. Notice that there are still another number of variants of vertical bars. For instance, the binary relation “divides” is entered using or | var var var var.
In TeXmacs, large delimiters may either be “left
delimiters”, “right delimiters” or “middle
delimiters”. By default,
and
are left delimiters,
and
are right delimiters. But there status can be
changed using the ,
and key combinations. For instance,
math:left ) produces
,
considered as a large left delimiter.
Sometimes you may want large delimiters of a particular size, instead
of self-adjusting ones. This can be achieved by resizing the
expression in between the brackets using 

Notice that it is possible to insert a pair of invisible brackets using . This is for instance useful in computational contexts, in which formulas should admit a precise, not merely visual semantics. Alternatively, one may put the formula inside a “rigid box” using , which additionally prevents the formula from being hyphenated.
The following key-combinations are used in order to create big symbols:
|
||||||||||||||||||||||||||||
The scopes of big operators are indicated visually, through the light cyan boxes around the tags which contain the cursor.
The big integral signs admit two variants, depending on where you want to place subscripts and superscripts. By default, the scripts are placed as follows:
The alternative rendering “with limits”
is obtained using symbol L I. Similarly, you may type
symbol L O in order to obtain
with limits.
The table below how to type mathematical accents above symbols or entire formulas. Indeed, some of these accents automatically become as wide as the formulas below them.
|
|||||||||||||||||||||||||||||||||||
The same accents may be inserted below the expressions using the prefix. For instance, math:under B x +
y can be used in order to enter
.
Starting with version 1.0.7.10, TeXmacs incorporates several features
for the “semantic” editing of mathematical formulas. When
used appropriately, this allows you to write documents in which all
formulas are at least correct from a syntactical point of view. For
instance, in the formulas
, the computer will
understand that
is an operator which applies
to the arguments
and
.
Notice that our “semantics” does not go any further:
TeXmacs is unaware of the mathematical nature of addition.
Semantic editing does require additional efforts from the user, at least a little adaptation. For instance, it is the user's job to enter multiplications using the shortcut * and function applications using space. Indeed, from the graphical point of view, these operations cannot be distinguished, since they are both printed as invisible whitespace. However, the semantics of these operations is clearly very different.
Although semantically correct documents are usually not very different from informal presentation-oriented documents as far as typesetting is concerned, the additional user effort may pay off for several reasons:
Furthermore, other semantic facilities might be integrated in the feature, such as semantic search and replace, or semantic search on the web.
In order to activate the semantic editing facilities, please toggle



The semantic focus is useful for several reasons. First of all, it is displayed in green if the formula is syntactically correct and in red if you made an error. This allows to quickly notice any typos while entering a formula. Secondly, if you have any doubt on the precedence of a mathematical operator or relation, then the semantic focus will inform you on the default interpretation: by putting your cursor right next to your operator, the subexpression to which the operator applies will be highlighted. In the case of an addition, or a more general associative operator, all summands are highlighted.
By default, the semantic editing mode “understands” most classical mathematical notations. This is achieved through the use of a carefully designed grammar for mainstream mathematics. Obviously, the use of a fixed grammar may cause the following problems:
. In such cases, the user
should explicitly annotate the appropriate parts of the
formula in order to make them semantically meaningful.
Besides these intrinsically hard to avoid problems, the following common and “easy-to-make” mistakes are a further source of trouble for associating semantics to mathematical formulas:
is indicated through
the use of an italic slant and special spacing. However, in the
formula
it is easy to type the closing
bracket outside the formula, with no visual difference.
would usually be understood as
, whereas
rather corresponds to
a function application. In the semantic editing mode, the user is
expected to resolve this ambiguity by hand by entering
multiplications using * and spaces using
space. The multiply/apply ambiguity is one of the
main sources of syntax errors, since many users do not pay attention
to invisible differences. Similarly, the
glyph could be the “logical and” or the “wedge
product”. This “homoglyph” issue will be adressed
in more detail in the section on the semantics of
mathematical symbols.
, should we
interpret the second bracket as a closing bracket? This is indeed
the standard french notation for an interval with an open right end.
More generally, all problems that we have mentioned so far tend to
be present simultaneously when trying to associate semantics to
existing documents.
After activation of the semantic editing mode, you may check whether a
formula is correct by positioning your cursor inside it and looking at
the color of the bounding box of the semantic focus: a
green color corresponds to a correct formula and a red color indicates
an error in the formula. Alternatively, you may select 


For the second kind of “easy-to-make” errors, TeXmacs
includes an automatic syntax corrector. Assuming that your cursor is
inside a formula, you may use 



The precise algorithms which are used for the correction may be
enabled or disabled from 


is replaced
by the binary set differences infix (as in
),
whenever appropriate.
From the 


After syntax correction, the remaining errors indicate genuine typos at worst or non standard or non supported notations at best. We also notice that “correct” formulas do not necessarily have the intended meaning. In order to check whether the operators indeed apply to the intended arguments, you should keep an eye on the current focus while typing your formulas.
The mathematical symbols in TeXmacs all come with a certain number of
properties which correspond to their intended meaning. For instance,
TeXmacs is aware that
is an infix operator,
whereas ! is rather a postfix, and , a separator.
TeXmacs has special symbols
,
and
for important mathematical constants,
which display differently from the mere characters
,
and
, and which can be
entered using the shortcuts , and . We recommend to systematically use these
shortcuts.
Inversely, semantically distinct symbols may display in a similar way.
For instance, the comma separator, as in
, is
different from the decimal comma, as in
.
Notice that the two symbols admit different spacing rules.
Semantically distinct symbols which are rendered by the same glyph are
called homoglyphs. Notice that our semantics is purely
syntactic: for instance, the
infix is commonly
used for addition, but sometimes also for the concatenation of
strings. Nevertheless, these two uses do not differ from a syntactical
point of view, since the
symbol remains a
binary infix with the same precedence with respect to other symbols.
The most confusing homoglyphs are the various invisible symbols supported by TeXmacs:
.
.
.
.
.
Again it is recommended that authors carefully enter these various
invisible symbols when appropriate. It is particularly important to
distinguish between multiplication and function application, since
there is no 100% safe automatic way to make this distinction (we
already mentioned the formulas
and
before).
TeXmacs supports two quite general schemes for entering homoglyphs. On
the one hand, we often rely on the standard variant system. For
instance,
and
are
obtained using
and . When applicable, we also support the following
convention: first type the character with a similar semantics and then
type the character which corresponds to the rendering. This convention
was already used above for the invisible homoglyphs, and often allows
for shorter shortcuts. In table ? we have given the
complete list of homoglyphs supported by TeXmacs.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
We have done our best to support most of the classical mathematical notations. Nevertheless, the user may sometimes want to define notations with a non standard semantics. Certain areas may also require special notations which are not supported by default.
TeXmacs provides a very simple 

For instance, if we enter
as the first
argument and
as the second one, then the
will be interpreted as a binary relation, exactly
in the same way as
. Moreover, the spacing
around
will be adapted, so as to mimick the
spacing around
. In this particular example, we
might have obtained the same result by using the
as its second argument. Most standard operator types are available
from 
The
.
It is likely that the inteded interpretation of
is
and not
. Therefore,
if we often use the constant
, then we might
want to define a macro
<assign|twopii|<macro|<syntax|
|
>>>
Such macros may be grouped together into a style package with the user's favourite notations. Future versions of TeXmacs might also provide style packages with notations dedicated to specific areas.
Let us finally notice that there are usually several ways for
redefining the semantics of a formula. For instance, an alternative
way to define the macro
<assign|twopii|<macro|
>>
where we inserted a pair of invisible brackets around
.
Similarly, in the formula
we may either select the whole formula and give it the semantics of an
ordinary symbol, by pressing .
However, a nicer solution is to only select the subformula
, and give it the semantics of an ordinary symbol. Yet
another example is the sign sequence
mentioned
earlier. This sequence can be interpreted correctly by inserting
invisible separators between the different signs using the ,
space shortcut.