TeXmacs - A convenient layout program for your text documents

Type Tool


If you need to lay out a text document, you can opt for a WYSIWYG application, like OpenOffice, or a genuine layout system such as TeX. TeXmacs combines the advantages of both approaches: premium document quality and intuitive controls.

By Hagen Höpfner

smile4mone, photocase.com

Text-based document markup systems such as LaTeX play a leading role in creating premium-quality scientific documents. LaTeX, which is based on the TeX typesetting program, lets the author focus on the content without having to worry about the layout. However, learning the layout language involves a considerable learning curve.

At the opposite end of the typesetting scale are graphics-based WYSIWYG editors, such as OpenOffice. The WYSIWYG interface makes common functions like type formatting, table layouts, or image placement much more easily accessible. However, features such as the typeface quality are typically inferior to the alternatives that are produced by a tool such as LaTeX.

The TeXmacs editing tool closes the gap between these two worlds. TeXmacs is a WYSIWYG editor that uses fonts provided by TeX (Figure 1).

Figure 1: TeXmacs offers an intuitive interface, similar to that you would expect from a word processor.

Ready for Layout

The TeXmacs project homepage [1] has an RPM package, TeXmacs-1.0.6.6-1. i386.rpm, for i386-based distributions like Fedora, Mandriva, or SUSE. After downloading, you can install as follows, assuming you have already installed teTeX [2]:

rpm -Uhv TeXmacs-1.0.6.6-1.i386.rpm

teTeX is a TeX distribution that any recent Linux distribution should have. As previously mentioned, TeXmacs relies on the teTex fonts. The TeXmacs page also has a TeXmacs-extra-fonts-1.0-1.noarch.rpm package with additional fonts. Unfortunately, I was unable to install the RPM package on SUSE 10.1 because SUSE uses different package names, and the dependency on tetex-fonts could not be resolved.

The source code section of the TeXmacs homepage has a solution. Besides the TeXmacs source code, you will also find the TeXmacs-extra-fonts-1.0-noarch.tar.gz font archive, which you can install on SUSE as follows:

mkdir ~/.TeXmacs && tar -C ~/.TeXmacs/ -xvzf TeXmacs-extra-fonts-1.0-noarch.tar.gz

This command line creates a .TeXmacs folder below your home directory and drops the package into it. TeXmacs will automatically discover the new fonts when you launch the program and integrate them. Users with Debian-based distributions can install TeXmacs with apt-get install texmacs.

Getting Started

After launching TeXmacs (by entering texmacs), you should see the dialog shown in Figure 1. As the name suggests, TeXmacs controls are based on the popular Emacs editor, and most Emacs shortcuts will work.

If you prefer to point and click, you'll find a menu bar, along with a number of toolbars, for critical tasks. Bubble help is available for the various icons, so if you don't understand what a button does, you can just let your mouse hover over the icon to find out.

To load a document, you select File | Load, click the icon (the second from the left), and press the Emacs keyboard shortcut Ctrl+X+F or use the TeXmacs shortcut, F2.

As I mentioned, TeXmacs lends itself to intuitive use. After creating a new document, you can start typing. To set attributes like font color, italics, or bold type, you just select the passage you want to change: you can hold down the left mouse button and drag the mouse over the text or double-click a word to select it. In contrast to most other editors, TeXmacs does not change the background color to highlight the selection but draws a red frame around the selection instead (Figure 2). If you click a text block again after applying an attribute, a turquoise frame will show you how far underlining, for example, goes.

Figure 2: A red frame is drawn around selected text, and a turquoise rectangle marks the border of a text block you have modified.

Users who are familiar with LaTeX can keep to their preferred style of writing. For instance, Shift+4 ("$") toggles TeXmacs to math mode, in which you can type \alpha (for example) and then press Enter to display the first letter of the Greek alphabet.

Tables, Images, and Source Code

Of course, TeXmacs can handle more than simple text. The menu below Insert has a number of items for inserting tables, images, links, animations, mathematical formulas, or even interactive source code. When you need to edit an object of this kind, TeXmacs switches to an appropriate special mode.

For example, Insert | Table | Large Table will first create a container with the table caption, but without creating a single cell. You can then select Insert | Table | Normal tabulator mode to create a column in the table within the container. At the same time, TeXmacs switches to table mode, as demonstrated by the appearance of more buttons in the button bar (Figure 3).

Figure 3: When you edit a table, TeXmacs automatically displays additional icons for inserting and manipulating table cells.

The same principle applies to inserting images, which can be in EPS, FIG, JPG, PDF, PNM, PNG, PPM, PS, SVG, TIF, or XMP format. After creating an image container, by selecting Insert | Image | Small image, you need to select Insert | Image | Link to image... to actually display the image in the document. You can select a large or small container for both text and images. A large container will take up the whole width of the document, whereas a small container will just take up whatever space it needs. TeXmacs also has a small drawing program, which you can enable by selecting Insert | Image | Draw Image.

Developers in particular will love the TeXmacs session feature. The session feature gives programmers the ability to copy text in a variety of programming languages, including Bash, Scheme, and Python. You can also run scripts in an interactive session while you are typing. To do this, you need to launch a session from within the document by selecting Insert | Session | Python (Figure 4).

Figure 4: TeXmacs not only displays the source code but can run it within a document.


Scheme: The Scheme programming language, a LISP dialect, uses lists as a basic structure element to represent data and programs.

Import and Export

Although the internal TeXmacs file format is well-documented [3], it is not really used anywhere apart from in TeXmacs. If you need to manipulate existing documents from other sources with TeXmacs, the File menu has two items for importing and exporting documents.

Because TeXmacs cooperates with (La)TeX, it will export to the PDF and Postscript formats. You can also export files to HTML, text only (via File | Export | Literal), LaTeX source code, or Scheme notation. On the import side, you'll find support for HTML, Text, Scheme, and LaTeX, but not for PDF or PS.

Because the LaTeX world is so colorful, vast, and variable, importing from LaTeX format often entails some manual repairs. This is particularly true of LaTeX documents that do not use a standard document type.

Figure 5: You might need to manually polish imported LaTeX documents (left). Exported PS files have excellent type quality (right).

Conclusions

TeXmacs gives users the ability to create high-quality layouts without sacrificing the convenience of icons and menus. Although Lyx [4] does something similar and has been around much longer, TeXmacs has some neat extras, such as interactive editing of source code in integrated sessions.

For more information on TeXmacs, you can examine the user manual online [3] or select Help | Manual.

INFO
[1] TeXmacs: http://www.texmacs.org
[2] teTeX: http://www.tug.org/tetex/
[3] TeXmacs Manual: http://www.texmacs.org/tmweb/manual/web-manual.en.html
[4] Lyx: http://www.lyx.org/
THE AUTHOR

Dr. Hagen Höpfner is a Lecturer for Databases and Information Systems at the International University in Germany (http://www.i-u.de) in Bruchsal, and coauthored the only German-language book on mobile databases and information systems.