Content area
Full text
AN INCREASING NUMBER of scholarly books include listings of computer programs, commands, or data files. Typesetting such material poses special challenges, and blunders are common in otherwise well - produced material. In this article I will briefly review some technical requirements and stylistic conventions for typesetting computer programs. For further details of the languages themselves, see a textbook on the relevant language or a general handbook such as Tucker's Programming Languages.(f.1)
LISTINGS IN TYPE
The simplest way to typeset a computer program is to reproduce the text file as it would appear on the screen, using monospace type (figure 1). Here immediately the book designer collides with one of computerdom's most time - honoured traditions: the eighty - character line. Most monospace fonts are too wide to accommodate eighty, or even sixty, characters within a reasonable page width. After all, the usual text line is about sixty characters, and monospace is wider than proportional roman. Figure 2 compares the width of several monospace fonts with that of Times Roman.(f.2)
Not only is Courier unusually wide, it is also often too light, and thus doubly unsuitable. Originally, Courier was an IBM typewriter font designed to remain legible on carbon copies, poor photocopies, and the like. The typewriter ribbon contributed weight to it. IBM used Courier in early laser printers, and it has somehow become the default monospace font on modern laser printers - a thinned - out ghost of its former self.
Letter Gothic (also originally an IBM typewriter font) is narrower and bolder but has, to my taste, an unappealing appearance. Lucida Sans Typewriter, designed by Charles Bigelow, is an improvement, with subtle weighting rather than a constant line width. (There is also a Lucida Sans Typewriter Condensed, not shown.) The 'Line Printer' font on Hewlett - Packard laser printers also resembles Letter Gothic.
My favourite font for program listings is Computer Modern Typewriter, which was designed by D.E. Knuth for precisely this job - typesetting sample programs in books about computing - and is included in Knuth's T'Symbol not transcribed'EX software package.(f.3) If you are using T'Symbol not transcribed'EX with fonts other than its basic set, take care that Computer Modern Typewriter is not replaced by Courier.(f.4)
Do the lines really have to be...





