![]() |
TeXmacs trees | ![]() |
All TeXmacs documents or document fragments can be thought of as trees. For instance, the tree
typically represents the formula
| \(\displaystyle x + y + \frac{1}{2} + \sqrt{y + z}\) | (1) |
Each of the internal nodes of a TeXmacs tree is a string symbol and each of the leafs is an ordinary string. A string symbol is different from a usual string only from the efficiency point of view: TeXmacs represents each symbol by a unique number, so that it is extremely fast to test whether two symbols are equal.
Currently, all strings are represented using the universal TeXmacs encoding. This encoding coincides with the Cork font encoding for all characters except “<” and “>”. Character sequences starting with “<” and ending with “>” are interpreted as special extension characters. For example, <alpha> stands for the letter \(\alpha\). Characters which have no Cork code and no symbolic name are represented by extension characters of the form <#hex>, where hex is the hexadecimal Unicode code point; for instance, <#4E2D> stands for a Chinese character. The semantics of characters in the universal TeXmacs encoding does not depend on the context. In other words, the universal TeXmacs encoding may be seen as an analogue of Unicode, into which it can be converted without loss of information.
The string leafs either contain ordinary text or special data. TeXmacs supports the following atomic data types:
Either true or false.
Sequences of digits which may be preceded by a minus sign.
Specified using the usual scientific notation.
Floating point numbers followed by a length unit, like 29.7cm or 2fn.
When storing a document as a file on your hard disk or when copying a document fragment to the clipboard, TeXmacs trees have to be represented as strings. The conversion without loss of information of abstract TeXmacs trees into strings is called serialization and the inverse process parsing. TeXmacs provides three ways to serialize trees, which correspond to the standard TeXmacs format, the XML format and the Scheme format.
However, it should be emphasized that the preferred syntax for modifying TeXmacs documents is the screen display inside the editor. If that seems surprising to you, consider that a syntax is a way to represent information in a form suitable to understanding and modification. The on-screen typeset representation of a document, together with its interactive behaviour, is a particularly concrete syntax. Moreover, in the Document menu, you may find different ways to customize the way documents are viewed, such as different levels of Informative flags and a “source tree” mode (Document\(\rightarrow\)Source\(\rightarrow\)Edit source tree) for editing style files.