The joy of TeX

Few computer products thrive for over 30 years: the Mac, Unix in its many guises, and TeX each spring to mind.

We celebrated the Mac’s entry into middle age last year, and every OS X and iOS user should wish Unix another 46 vigorous and innovative years ahead on its birthday, 20 April. But unless you have worked with technical documentation, you may never have heard of TeX, its X pronounced as the ‘ch’ is in Scottish ‘loch’.

Disappointed by poor galley proofs for a volume of his seminal work “The Art of Computer Programming” in 1977, Stanford Professor Don Knuth decided to write software to enable text documents marked up using a new scheme, TeX, to be typeset from a PDP-10 mainframe computer.

The first version that many came across was written in Knuth’s variant of the Pascal language, and published in print to open its source to the world (another pioneering move). Markup languages were still relatively new at the time, the first being implemented around 1969. A companion vector-based font description language, Metafont, was released in 1979, its source code also being published, and predated PostScript fonts by more than three years.

For decades TeX and its more popular derivative LaTeX have dominated academic, scientific, and particularly mathematical publishing. Although the ‘desktop publishing’ revolution led by the Mac, PostScript, and the Apple LaserWriter empowered us to design and produce properly laid-out pages integrating text and graphics, they have never been as successful with mathematical content.

Even today, with a rich choice of layout and diagramming tools and over 30 years of PostScript development, and some pleasant add-on tools designed for the purpose, there are many who cannot faff around trying to get them to handle technical notation.

Recently my explorations in linguistics have taken me to construction grammar, which uses potentially full-page ‘attribute-value matrices’ (AVMs), with multi-line square and angle brackets, to define the pronunciation, syntax, and more of language structures. Laying each up in a conventional page layout app is a nightmare, as every AVM must be drawn out individually. I have tried cheating and set them in tabular form, which is much quicker but far inferior.

Thanks to a free LaTeX style sheet, I can rapidly turn marked-up text into AVMs every bit as clear and beautiful as those printed by specialist publishers. Furthermore, just as with HTML and XML markup, I can exchange data with databases and other apps. Perhaps if I had learned PostScript more thoroughly I could have done this via PDF, but unlike TeX, PostScript was never intended to be handcoded in this way.

This example may appear pretty incomprehensible, but once you start setting up a few of these, it is surprisingly straightforward:
{\avmoptions{active}
\avm
{
[ \rm \it sort-label \\
phon & \rm /phonology/ \\
form & \< \rm \it word, list \> \\
syn & {[ \rm \it syn-obj \\
cat & {[\rm \it verb \\
vf & \rm \it fin \\
select & \rm \it none \\
xarg & \rm NP\[{\it nom}\]$_{i}$ \\
lid & {[\rm \it label-fr \\
label & \rm {\it l$_{n}$} \\
sit & \rm \it s \\
s-srce & \rm \it i \\
]} \\
]} \\
val & \< \> \\
mrkg & \rm \it unmk ]} \\
arg-st & <subj, dir-obj, indir-obj, obl, gen, obj-of-comp> \\
sem & {[ \rm \it sem-obj \\
ind & \rm \it s \\
ltop & @2 \\
frames & {<[\rm \it label-fr \\
label & \rm {\it l$_{n}$} \\
bv & \rm \it s \\
restr & \rm {\it l$_{n}$} \\
scope & \rm {\it l$_{n}$} \\
], ... >} \\
]} \\
cntxt & {[ \rm \it context-obj \\
backgrnd & {<[\rm \it label-fr \\
label & \rm {\it l$_{n}$} \\
entity & \rm \it i \\
name & \<\rm {\it name}\> \\
], ... >} \\
]} \\
]}
\endavm

which magically turns into this:

Try setting this up in InDesign - particularly when the book calls for several dozen of them.
Try setting this up in InDesign – particularly when the book calls for several dozen of them.

Macs and iOS devices are superb platforms for TeX and LaTeX, with complete implementations available at little or no cost, and apps like TeX Writer that even allow you to write and render long documents on your iPhone. My only sadness is that Textures, an exceptional commercial implementation for Mac OS ‘Classic’, was been abandoned after the deaths of its developers, Barry Smith and Gordon Lee.

TeX is not only alive and well on OS X and iOS, but now flourishes in novel apps like Archimedes, which combines the latest lightweight markup language Markdown with LaTeX for crafting fine mathematical content. If you still think it preferable to slave over equations and expressions character by character in an app like InDesign, you should explore the thoroughly modern aids that Archimedes provides to mark up using Don Knuth’s still precocious invention, TeX.

Between the three of them, my Mac, its Unix heart, and TeX, I count a total of 114 years of innovation.

Updated from the original, which was published in MacUser volume 30 issue 05, 2014.