# GNU TeXmacs

GNU TeXmacs is a scientific word processor and typesetting component of the GNU Project. It was inspired by TeX and GNU Emacs, though it shares no code with those programs. TeXmacs does use TeX fonts.[3] It is written and maintained by Joris van der Hoeven and a group of developers[4]. The program produces structured documents with a WYSIWYG user interface. New document styles can be created by the user. The editor provides high-quality typesetting algorithms and TeX and other fonts for publishing professional looking documents.

Developer(s) TeXmacs collage 2019 GNU Project 1.99.11 (July 29, 2019) [±] Linux, Windows, macOS, Unix-like[1] X86, X86-64 Word processor GNU GPLv3[2] texmacs.org

## Features

TeXmacs can handle mathematical formulas and is used as a front-end to a number of computer algebra systems such as Maxima and SageMath. TeXmacs also supports a Scheme extension language called Guile for customizing the program and writing extensions.

Like many WYSIWYG editors (such as Microsoft Word), authors manipulate a document on screen which should print to a similar looking paper copy. The goal of TeXmacs is to provide a WYSIWYG editor that nevertheless makes it possible to write correctly structured documents with aesthetically pleasing typesetting results. TeXmacs is not a front-end to LaTeX[5] but TeXmacs documents can be converted to either TeX or LaTeX. LaTeX also can be imported (to some extent), and both import from HTML, Scheme, "Verbatim", and XML and export to them is provided.[6] There is a converter for MathML as well, and TeXmacs can output PDF and PostScript for printing.[7]

TeXmacs currently runs on most Unix-based architectures including Linux, FreeBSD, Cygwin and macOS. Along with the Cygwin version, a native port is available for Microsoft Windows.

TeXmacs also features a presentation mode and a small technical drawing editor and there are plans to evolve towards a complete scientific office suite with spreadsheet capacities.

### Mathematical typography

TeXmacs facilitates the inputting of mathematical formulas by mapping sequences of keyboard symbols to symbols. For example, the symbol ${\displaystyle \Rightarrow }$ can be input by typing =>.

Some symbols have no such representation (${\displaystyle \Uparrow }$ for instance). These can be input with tab key. This keyboard-based entry differs from other formulae editors, that tend to provide point-and-click menus for this task.[8]

### Batch processing

It is possible to use TeXmacs as a batch processor (which is LaTeX's usual operation mode), using X virtual framebuffer to avoid opening unwanted windows while processing. For example, the command

`xvfb-run texmacs --convert article.tm article.pdf --quit`

generates a PDF file "article.pdf" from a TeXmacs document "article.tm".

## The TeXmacs format

All TeXmacs documents or document fragments can be thought of as trees. For instance, the tree

represents the formula

TeXmacs trees are represented in TeXmacs files as strings, and in the TeXmacs editor as the typeset representation of the document together with its interactive behaviour.[9] In the on-screen representation of the TeXmacs tree, the cursor movement represents the movement inside the tree. On disk, three representations of the TeXmacs format exist: a native representation, an XML representation and a Scheme representation; the Scheme representation is useful for the interfacing with Scheme programs.

## Typesetting and document control

The typesetting process converts TeXmacs trees into boxes[10]. Evaluation of TeXmacs trees proceeds by reduction of the primitives, that is by evaluation of macro applications. The typesetting primitives are designed to be very fast and are built-in into the editor; the rendering of many of the primitives can be customized through the built-in environment variables; the stylesheet language allows users to write new primitives as macros on top of the built-in primitives.

### Document control

Documents can be controlled through a native macro system and through Guile-Scheme. It is possible to customize the editor's menus and keybindings and to act programmatically on the document tree.

#### TeXmacs macros

TeXmacs macros provide a means of structured input (as in TeX/LaTeX) and they are immediately typeset, at the same time maintaining editable input fields.

#### Document control through Scheme

Scheme is embedded in TeXmacs through Guile; the editor itself can be controlled in this way[10]: menus and keybindings can be customized. Scheme commands can be invoked interactively inside TeXmacs documents, can be invoked from the command line and from inside TeXmacs macros. TeXmacs trees can be passed to Scheme in different forms: as "passive trees" (convenient to manipulate content directly using standard Scheme routines on lists), as "active trees" (keep track of the position of the tree inside the global document tree and can be used to programmatically modify documents), and in a "hybrid" representation.

#### Graphics

Graphics objects are also part of the TeXmacs format and can be manipulated programmatically from Scheme. An example of TeXmacs graphics generated in a TeXmacs Scheme session is shown below together with the session which generated the image; images generated programmatically can also be edited using the internal drawing editor.

```Scheme]  (define pi (acos -1))
;; A function to define a point in the TeXmacs graphics format using two coordinates
Scheme]  (define (pt x y)
‘(point ,(number->string x) ,(number->string y)))
;; Set points
Scheme]  (define xC (- (* 2 (cos (/ pi 3)))))
Scheme]  (define yC (* 2 (sin (/ pi 3))))
Scheme]  (define pA (pt -2 0))
Scheme]  (define pB (pt 2 0))
Scheme]  (define pC (pt xC yC))
Scheme]  (define tA (pt -2.3 -0.5))
Scheme]  (define tB (pt 2.1 -0.5))
Scheme]  (define tC (pt (- xC 0.2) (+ yC 0.2)))
;; Generate graphics
Scheme]  (stree->tree
‘(with "gr-geometry" (tuple "geometry" "400px" "300px" "center")
(graphics
(with "color" "blue"  (text-at (TeXmacs) ,(pt -0.55 -0.75)))
(with "color" "black" (arc ,pA ,pC ,pB))
(with "color" "black" (line ,pA ,pB))
(with "color" "red"   (cline ,pA ,pB ,pC))
(with "color" "black" (text-at "A" ,tA))
(with "color" "black" (text-at "B" ,tB))
(with "color" "black" (text-at "C" ,tC)))))
```

## Supported back ends

TeXmacs has back-ends supporting many technologies.

Programming languages: CLISP, CMUCL, Python, QCL, R, Shell

Computer algebra systems: Axiom, Giac, Macaulay 2, Mathematica, Maxima, MuPAD, PARI/GP, Reduce, SageMath, Yacas

Numeric matrix systems: GNU Octave, Matlab, Scilab

Plotting packages: gnuplot, Graphviz, XYpic, Mathemagix

Other: DraTeX, Eukleides, GTybalt, Lush, Juris-M or Zotero (research citation references and bibliography manager.)