![]() |
Getting started with TeXmacs | ![]() |
This short guide is designed to help you master some of the fundamental notions of TeXmacs.
Please move the cursor inside this piece of bold text. You will observe a cyan box that appears around it. On the status bar, at the bottom right of your window, you may also notice the word “strong”. These two things reveal part of the structure of your document. In this case, the bold text was produced using the tag (also called markup element or environment) strong and the box indicates the scope of this tag.
TeXmacs comes with hundreds of tags for different purposes. The strong tag is used to highlight important pieces of text. Most tags refer to intent (like highlighting important text) rather than layout (like printing the characters in boldface). TeXmacs makes use of customizable style files in order to translate intent into layout. This allows you to easily switch to another presentation (e.g. italic instead of bold text) if you change your mind.
Tags can be nested. Move the cursor just before the number 2 (for the square) in the formula below and observe that four boxes are displayed : three light grey boxes (one for the entire equation, one for the expression inside the parentheses, and one for the fraction), plus a cyan box for the superscript. The cyan box is always used for the innermost tag with respect to cursor position, and it is called the focus.
| \(\displaystyle z = a \left( b + \frac{c^2}{d} \right) .\) | (1) |
Let us examine more closely the status bar, located at the very bottom of this window, below the editing region. When moving the cursor around in this document, you will notice that the right hand side of the status bar shows the character just before the cursor. Now move the cursor back in the above equation, right after the number 2 and inside the superscript (check that the cyan box is displayed around the number 2). As you see, the status bar lists all englobing environments in order, from the outermost to the innermost one. Experiment by moving the cursor around in the formula while keeping an eye on the status bar. You will soon get comfortable using the feedback from the colored boxes and from the status bar while navigating in documents.
There is an invisible character in the formula after the \(a\) and before the parenthesis in the equation: can you position the cursor and read off what it is from the status bar? You are right, it is an invisible multiplication. In mathematical formulas, you should refrain yourself from using a space if what you really mean is a multiplication. Remember that TeXmacs expects you to write down what you mean, not how it should be displayed. Multiplications should be invisible in the printed version of your document, but you might find it convenient to show them when editing your document. This can be done using the menu Document\(\rightarrow\)Informative flags\(\rightarrow\)Detailed.
Again position your cursor inside the above equation, and try moving around using the arrow keys ← → ↑ ↓. For instance, can you move the cursor from before to \(d\) to after the \(2\) and then after the invisible multiplication? Quickly, the cursor movements will probably feel very natural. Remember that the boxes (and in particular the cyan one) indicate where the cursor is located in the document structure.
As an exercise, here is a word that uses a different layout for each one of its characters:
crazy
Experiment adding characters to this word: observe how the exact cursor position determines in which environment a new character gets inserted. Can you insert a second strong letter ‘c’ and a second lowered letter ‘z’ with only two mouse clicks and two keystrokes?
The graphical user interface of TeXmacs is highly context sensitive. In particular, the menus and the toolbars depend on the cursor position. Roughly speaking, the three toolbars serve the following purposes:
the icons
, ...,
are used for the insertion of
“large environments” that structure your document,
like sections, theorems, item lists, etc.
the icons
, ...,
are for common textual markup
(emphasis, verbatim, color).
the icons
, ...,
are specific to the tmdoc style used by this particular document (they provide
acccess to some macros that are useful when writing TeXmacs
documentation, and you can ignore them for the moment).
the icons
, ...,
are for the insertion of special types
of markup, such as equations, tables, images, hyperlinks,
animations, or interactive sessions.
Observe how the focus bar changes when the cursor is moved; try
clicking on the
icon when the focus is
on the above bullet list (but not immediately after a bullet) and
observe what happens. The same mechanism allows displayed formulas to
be numbered: go ahead and try it with the ones in this document!
It is now time to type your first formula, say
Here is how we did it (go ahead and try whether you can repreduce the example):
Click on the
icon in the
mode-dependent icon toolbar to insert a displayed formula
(i.e. a large centered formula).
The integral sign can be found under the
icon, available when the cursor is inside a formula. When hovering
the mouse over the button with \(\int\), a help balloon allows you
to discover the corresponding keyboard shortcut ⇧F5⇧I.
If you know LaTeX, then you may also use the LaTeX command \INT
followed by ↩.
The subscripts and superscripts can be obtained using the
icon in the toolbar, or using the keys
^
and _.
Make sure you exit the subscript environment before creating a
superscript, otherwise you will be creating a superscript inside
the subscript: remember that the cyan box is here to help you
figure out the exact cursor position.
The prime can be inserted directly from the corresponding key '.
Note that typing an opening parenthesis ( automatically creates the matching parenthesis as well. To exit the parentheses, use the arrow → or ).
Before the subexpression \(\mathrm{d} x\), an invisible multiplication is required: simply use the * key. The status bar will confirm that the multiplication sign has been entered correctly.
The upright ‘\(\mathrm{d}\)’ from differential calculus is obtained via the shortcut D⇥⇥. Here ⇥ stands for the tab-key and you should press D without using the shift key.
TeXmacs uses two simple but powerful mechanisms for entering mathematical symbols:
Basic symbols can be juxtaposed to obtain more complex ones. For instance, typing -> (two successive keystrokes here) yields \(\rightarrow\). Can you guess how to insert a symbol \(\pm\) before the \(b\) in the formula below?
Such sequences of keystrokes are designed to be intuitive and easy to remember. Guess how to change the formula above to \(a \leqslant \pm b\), \(a \rightarrow \pm b\) or even \(a \rightrightarrows \pm b\)?
Variants of a symbol can be obtained using the tab-key ⇥, as demonstrated by the differential ‘\(\mathrm{d}\)’ earlier. When several variants are available, pressing ⇥ repeatedly cycles through them. In the formula above, type < between \(a\) and \(b\), and immediately after this press ⇥ repeatedly (if you are not sure what a symbol represents, keep an eye on the status bar). This mechanism can be used in particular to obtain Greek letters: try replacing \(g\) and \(b\) by \(\gamma\) and \(\beta\), respectively, in the expression of the Lorentz factor from special relativity,
The two mechanisms can be combined: can you guess how the mathematical symbol \(\Updownarrow\) can be obtained? Hint: it is a variant of \(\Leftrightarrow\).
Don't forget entering math mode before trying to insert
mathematical symbols or markup. New formulas can be inserted using
icon on the mode-dependent icon
toolbar or using the keyboard shortcuts $ (inline formula) or
⌃$
(displayed equation).