The Unknown Picture Environment
Total Page:16
File Type:pdf, Size:1020Kb
The unknown picture environment Claudio Beccari Abstract handbook announces the extensions and discusses the eliminated drawbacks; these extensions were The old picture environment, introduced by Leslie eventually realized only in 2003 by Gäßlein and Lamport into the LAT X kernel almost 20 years ago, E Niepraschk, (Gäßlein et al., 2009). In 2004 the appears to be neglected in favor of more modern same authors released a stable version. In 2009, and powerful LAT X packages that eliminate all E with the contribution of the third author Tkadlec, drawbacks of the original environment. Neverthe- they released an enhanced versions that added less it is still being used behind the scenes by a quite a few new commands that substantially ex- number of other packages. Lamport announced tend the picture environment functionality. But, an extension in 1994 that should have removed except the latest additions of the year 2009, every- all the limitations of the original environment; in thing else was already documented by Lamport in 2003 appeared the first version of this extension, in his handbook second edition. 2004 it was released the first stable version; in 2009 Not longer than a few days ago a forum partici- it was actually expanded to new functionalities. pant asked how he could draw a square wave and Nowadays the picture environment can perform a saw tooth wave of suitable size for setting them as most simple drawing programs do, but it has in line with his text: and . special features that make it invaluable. The whole thing required to produce two sim- ple commands by resorting to the recent pict2e Sommario extension package new commands: L’ambiente picture, introdotto da Leslie Lamport \newcommand*\sqwave[1][0.125ex]{{% nel nucleo di LATEX quasi 20 anni fa, sembra essere \unitlength=#1\relax trascurato a favore di pacchetti LATEX più moderni \picture(20,10) e più potenti che eliminano tutti gli inconvenien- \polyline(0,0)(6.5,0)(6.5,15)(13,15)% ti della versione originale. Tuttavia esso è ancora (13,0)(19.5,0) usato oggigiorno dietro le quinte da numerosi altri \endpicture}} pacchetti. Nel 1994 Lamport annunciò un pacchet- to di estensione che avrebbe dovuto rimuovere ogni \newcommand*\sawtooth[1][0.125ex]{{% inconveniente; solo nel 2003 apparve una prima \unitlength=#1\relax versione; nel 2004 questa estensione divenne sta- \picture(20,10) bile; e nel 2009 essa è stata arricchita di nuove \polyline(0,0)(6.5,0)(6.5,15)(13,0)% funzionalità. Oggi l’ambiente picture si comporta (19.5,0) come qualsiasi altro semplice programma di dise- \endpicture}} gno, ma presenta alcune particolarità uniche che lo rendono insostituibile. Most of the time suggestions are given by and to the forum participants to use external drawing 1 Introduction programs; or to use the sophisticated PSTricks or TikZ packages. The former solution is generally to The plain TEX, as described in the TEXbook, be avoided, because if some lettering is needed, it (Knuth, 1990), contained a simple way to draw requires more work to use the same fonts as those simple graphics with tex; when LATEX was first used in the document. The latter two packages are published in 1984, it contained an environment really capable of doing marvellous and complicated suitable for relatively complex graphics; Lamport’s drawings, but require a long documentation time handbook, (Lamport, 1994) described its work- and a steep learning curve. ings and commands. But all this seems to be fallen But there is a unique feature to the picture en- in complete oblivion. vironment: it can produce drawings of zero width Most users of LATEX related forums keep asking and/or height. This special feature makes them pre- questions such as “How can I produce such and cious for packages such as eso-pic,(Niepraschk, such symbol”; I keep answering “Use the picture 2010), crop,(Franz, 2003), layout,(McPherson, environment”. Apparently nobody follows my sug- 2000), layouts,(Wilson e Robertson, 2009), and gestions, which of course they are free not to; but others. These packages draw things on the page they would save time if they spent no more than that do not require any external package, and 15 minutes in reading the environment description therefore don’t have any dependency; these draw- on Lamport’s handbook; the second edition of this ings occupy no space, although they have a specific 57 Claudio Beccari ArsTEXnica Nº 11, Aprile 2011 position on the page; their contents reach whatever format became available; some drawing packages point on the page, as background images or marks (again curves) exploited the \special command that do not interfere with the positioning of other in order to write on the output file raw PostScript page elements. drawing commands, so that the actual action of In particular eso-pic (and similar packages for drawing was demanded on the screen or printer setting watermarks) and crop exploit this function- driver. Nevertheless powerful extensions in this ality exactly for setting a background picture or directions, such as PSTricks appeared much later. the crop marks in the correct positions without Drawing with external programs and importing interfering with the other elements of the page. the resulting artwork was therefore a necessity, but At the same time within the picture environment not an easy task. it is possible to use the cubic Bézier curves and to Things evolved in the right direction when per- draw polygons, arcs and sectors, oval frames whose sonal computers, having become the universal com- corner curvature can be freely specified, white or plement of any person needing to write anything, filled circles of any dimension. The \polyline started having a more user friendly interface, larger macro used in the above simple examples makes RAMs, larger hard disks, and better programs, the it very easy to draw polylines with any number of TEX system included. The nineties, besides the corners and any segment slope, to the point that important passage from TEX2.x to TEX3.0, gave if the nodes are sufficiently close, it is possible to us LATEX 2ε, PostScript fonts, and the drawing in- draw “smooth” curves whose point may be calcu- strument METAPOST. This program used more lated with any number-crunching personal or main or less the same philosophy that led Knuth to frame computer. develop METAFONT, in order to draw the TEX system default fonts; METAPOST produced a sim- 2 In detail plified output PostScript code that was understood also by the new born typesetting program pdftex. Everybody can agree that the original picture en- METAPOST was, and still is, fully compatible with vironment, created by Lamport with its very first the rest of the TEX system typesetting engines, A version of LTEX, was pretty rudimentary but there so that all the TEX and LATEX features could be was practically nothing else to use in its place. The used for putting any lettering on the METAPOST straight lines could have slopes that were ratios of output files. relatively prime integer numbers not exceeding 6 Meanwhile LATEX went on with its small draw- in absolute value. For vectors the limitation was ing environment, without exploiting the new pos- even stricter; the slopes could not be specified with sibilities with the PostScript format and the PDF integer numbers larger than 4 in absolute value. portable document format, until Gäßlein and Why there were such strange limitations? because Niepraschk wrote the picture extension announced straight lines were made up through the juxtaposi- by Lamport some ten years before. tion of small segments 10pt ( 3mm) long taken ≈ Let see what are the enhancements introduced by from a special font; this same special font contained the extension realized by Gäßlein and Niepraschk; also the vector arrow tips that occupied a large part of the available positions; and, remember, at 1. First of all the enhancements rely on the that time the typesetting engine could deal only drivers that are being used to display or to with 128-glyph fonts, so that the available short print the document. More precisely when the segments and arrow tips, plus a selection of closed latex program is used, the \special com- and filled circles and/or quarter circles required mands to the driver contain only PostScript strict limitations on the drawing performances. language commands; this implies a transforma- Patient programmers made up extension pack- tion of the resulting DVI file into PostScript ages such as curves,(Maclaine-cross, 2008), that one by means of dvips, and possibly a second could overcome such limitations by drawing lines transformation to the PDF format by means of any slope and circles of any diameter by juxta- of ps2pdf . On the opposite, if the document is processed with pdflatex, then the \special posing an “infinity” of small dots. For plain TEX there existed another package, PicTeX,(Wichura, commands contain only the PDF language 1987), that with a suitable interface could work commands. Therefore the extension is fully compatible with the typical output formats also with LATEX. That package performed very well on large mainframes with large memory capabil- provided by the most popular typesetting en- ities, but worked very poorly on the desktops of gines; but this performance is fully automatic that age, the eighties, when a 20MiB hard disk was and users need not bother about these details. a luxury and a 640KiB RAM was almost the max- 2. The output file size very often is smaller imum available. These packages mostly saturated since the actual drawing computations are the RAM and drawing was virtually impossible on performed by the suitable drivers. personal computers. Some progress was made when the PostScript 3.