Monday 26 April 2010

The Tex & I

In the summer of 2009 I took on the task of re-typesetting a book I had originally co-authored with my PhD supervisor, colleague and friend Professor Vyvyan Howard. We had originally published Unbiased Stereology in 1998 and it had sold steadily enough that by 2004 another publisher had picked up the rights and we made and published a second edition.

By early 2009 our publishers had sold all the copies of the second edition and had hit on the idea of making a Print On Demand (POD) version that allowed them to keep selling copies of the second edition, but not have to pay upfront for a print run of thousands. This also made sense to us as authors because the book was still current and widely read – by early 2009 it had a total of about 800 citations from other papers and books.

Unfortunately, the overall POD quality was poor. Although the glossy book cover looked good ,the print quality of the figures looked like cheap photocopies and more importantly for us as technical authors the scaling of key images was unpredictable and thus unacceptable in the book. Vyvyan and I decided to pull out of the POD route and walked away from the publisher – prompted by my assertion that I could ‘do it myself’.

I knew that many, many academic scientists active in physics and maths routinely used the TeX and LaTeX systems to prepare papers and books, but I had never learnt how to use these systems myself and previously had been put off teaching myself because of the learning curve and because I thought using MS Word was good enough.

The following is based on my experience of going from a complete novice at  TeX  to someone with a fully typeset 296 page book finished and printed. In the process I have recently learnt a huge amount about fonts, typography and book design.

The TeX program was created by computer scientist Donald Knuth in 1984 driven by his own inquisitiveness and talents. Within two years Leslie Lamport had created a set of macros called LaTeX that made TeX easier to use and since then a myriad of unnamed Open Source programmers have extended and furthered the vision that Knuth had when he first created TeX. In the process over the past 10 years there has been a quiet, but nevertheless remarkable, revolution in how text is printed onto paper to make physical books.

The latest version of LaTeX is one of the very best things you can get for free, on Mac, Linux or PC. Once downloaded and installed a modern LaTeX  system (depending on the one you choose it will have either a fancy text editor or a a plain one and will have a LaTeX  engine that creates PDF output) will allow you to create a whole book of professionally typeset text, figures and equations.  Virtually all of the defaults help you do something sensible, or better, and hundreds of years of the art and craft of typography, typesetting and page design is opened up.  

The output above is some classic advice on typography from Beatrice Warde. It was created with the raw text file  which has the content text and a small number of TeX commands - to format the text in the same way that a typesetter would have done in the past with physical cast metal text.

The example uses the excellent memoir class which allows you to compose a whole book worth of type. The LaTeX system is pretty complete and comes with a number of useful high quality fonts as standard. I have used both Palatino (for the example here) and a Robert Slimbach designed font called Utopia.

Note that the Crystal Goblet piece has clever hyphenation and justification of the text -  LaTeX uses a hyphenation algorithm based on work by Donald Knuth and Michael F. Plass and further enhanced by Frank Liang. This method considers a paragraph as a whole to decide where to add line breaks and language specific patterns to decide hyphenation patterns. More recent developments enable LaTeX to move characters slightly into the margin to generate optically straight margins. These are cleverly NOT geometrically straight but when read they look straight. These computer algorithms are able to simulate the decision making of master typesetters of the past.

Equipped with LaTeX an amateur typesetter can begin to learn about typesetting by  practicing on eitiher their own text or using some existing electronic files (Project Gutenberg has hundreds of classic books in flat text files you can be Charles Darwins typesetter if you wish). If you have Robert Bringhurst's, Elements of typographic Style available and a couple of Edward Tufte books for inspiration you can really get going on more sophisticated things.

The LaTeX  memoir class was developed by Peter Wilson, it is a professional strength typesetting package that is capable of managing all aspects of a complete book project. As well as page by page typesetting it does chapter headings, layout on the paper size of choice, and gives incredible flexibility. Just by using default settings in memoir you can easily give you great page design and typesetting. For example, the command \medievalpage will use the paper size you have selected and produce a medieval page layout based on classic proportions such as those of the 13th century French architect Villard de Honnecourt who devised an ingenious method of setting out optimum proportions for margins and text block on a book page. Other simple commands deliver Robert Bringhurst layouts. If necessary you can set up your own or use a whole class that implements the iconic book layout of Edward Tufte’s books on information design.

And there is a worldwide community of like minded souls. For example, in a thoughtful essay by an Australian philosopher called Adrian Heathcote on how using free, robust and clever LaTeX typesetting programs can help small printers in the UK and Australia make better, more beautiful, books, you can find the following:

There are, however, many other aspects of LATEX that facilitate high quality typesetting. For one, the lines are not justified individually, as they are in Pagemaker and Quark, but in entire paragraph blocks. This simulates the decision making of the master typesetters of old, who would set a page so as to get the greatest evenness of word spacing. LaTeX - or rather the underlying TeX hyphenation-justification algorithm - is able to produce that evenness automatically. This has been so successful an implementation of this old technique that it has been borrowed now for Adobe's InDesign program, where it is called the multi-line composer.

So not only is LaTeX free, but it is also remarkably sophisticated. Donald Knuth knew something when he created TeX – that although computers are a modern science, in the end placing marks on paper is an old art and all art requires craft.