TeX Finally Made Functional

This is more of a computer programming post than a math post, but since we all use TeX, I thought it might be of general interest. I came across this paper by Heckman and Wilhelm, which describes how to implement TeX’s algorithm for typesetting math formulas in a functional language (namely, ML). We see the output of this algorithm every time we look at a math paper, but until now it lacked a precise formal description other than what was embedded Knuth’s Pascal code. Since Knuth wrote TeX back when computers were much slower and compilers were much dumber, the code contains many hand optimizations that make the logic hard to follow. (The algorithm itself is too complicated to lend itself to a purely verbal description.) By rewriting it in a functional language, the authors are able to turn the algorithm into a well-defined mathematical function.

5 Responses to “TeX Finally Made Functional”

  1. bcater says:

    For easy-to-use TeX, you should try MonkeyTeX, available at http://www.monkeytex.com. It’s a fully-functional web-based version of LaTeX featuring groups and collaboration, spellcheck, and more. Best of all, it’s free!

  2. Shorel says:

    I want a mix between (La)TeX and Wordperfect 5.1 for DOS.

    That is, I want a WYSIWYG editor with a WP51 revealcodes function and the ‘codes’ all being (La)TeX.

    And I write just a letter in (La)TeX code and I see the result immediately in screen (as long as it parses).

    That’s the ideal word processor. And this functional implementation makes it possible. I’m happy.

  3. Daniel Faken says:

    A PDF of the paper is available at Citeseer: http://citeseer.ist.psu.edu/251273.html

  4. [...] Via Ars Mathematica, I came across a paper describing TeX’s math layout algorithm and offering an implementation of it in Standard ML. Sweet! I only wish I had come across this paper (it is about 10 years old) when I was daydreaming about a WYSIWYG gui interface that worked for multiple CASes. If I ever get back around to it, this will be really useful. [...]

  5. Graham Toal says:

    Lucas Cardelli and Nick Rothwell implemented a function version of TeX called “PaperBox” at Edinburgh back in the late 70’s/early 80’s. I’m fairly sure it was written in ML. Let me Google it … ah yes, here it is… 1982 - “PaperBox: an applicative text formatter”.

Leave a Reply