
\title{Notes on graphics in \TeX}
Getting pictures onto the printed page is a problematic process, 
basically because the quality you can achieve depends so heavily on 
the cost of the hardware at your disposal. This militates against 
portability, and is one of the reasons why \TeX\ (the ultimately 
portable DTP system) has trouble with graphics. What follows is 
in no sense state-of-the-art graphics typesetting. It is simply an 
account of how a \TeX\ {\it user}, having a variety of types of 
picture and needing to transport files between different machines, 
came up with some {\it ad hoc} solutions. Probably nobody else will
have exactly the same requirements as I had, but the opportunities
may have wider relevance.

\section{Diagrams}
There is a deep structure underlying large areas of mathematics, and 
manifesting itself in various ways, which is conventionally described 
by diagrams called {\it Coxeter-Dynkin diagrams}. Most of these 
consist of a number of nodes in a line, consecutive nodes joined by 
single or double bonds. However, there are some diagrams which have a 
three-way branch (one of the arms having length~1), such as $E_6$, 
which looks like this:
$$\esix$$
The straight-line diagrams can be drawn easily enough, using the 
{\tt\char`\\circ} character for nodes and rules for the arcs joining them.
I found that some kerning was necessary. This had to be done by trial 
and error, with the disadvantage that what looks right on the screen 
may not do so on the laser printer (presumably a defect in the \dvi\ 
drivers). Perhaps this could be improved by turning off the glue; but 
I decided that what I had was good enough.

Recently, geometers have begun using these and similar diagrams to 
describe strange new geometries. It has become customary to attach 
labels to both nodes and arcs; in the case of nodes, different labels 
above and below carry different information. In Norbert Schwarz's {\sl
Introduction to \TeX\ }[2], I found a macro for optional arguments.
(There it is also used for superscripts and subscripts, though the 
details of the printing are a bit different). Using it, I can print 
diagrams like this one (a bit cluttered, for demonstration purposes):
$$\node^{\rm point}_s \darc \node^{\rm line}_t \arc 
\node^{\rm quad}_q \stroke{L} \node^{\rm symp}_r$$
Here, the superscripts and subscripts on the nodes are entered in the 
standard \TeX\ manner: for example, the input for the above diagram is
\begintt
$$\node^{\rm point}_s \darc 
  \node^{\rm line}_t  \arc 
  \node^{\rm quad}_q  \stroke{L} 
  \node^{\rm symp}_r$$
\endtt

This also enables the production of the three-way branching diagrams 
like $E_6$; just subscript a node with a little construction 
consisting of a vertical line with a node at the end.

It's not perfect. Better kerning, and the possibility of changing 
the node character (e.g.\ to a filled or crossed circle) would be 
desirable.



\section{Figures}
Elementary geometry requires figures consisting of lines and circles 
intersecting in various ways. Graph theory needs figures a bit like 
the diagrams just discussed, but with much greater flexibility about 
where the nodes are placed and the slopes of the lines.

\LaTeX\ provides a {\tt picture} environment for drawing such 
diagrams. It doesn't handle circles adequately (only very small sizes are
available), but accurate lines are drawn. The difficulty is the famous
restriction on the slopes of the lines. Any line which is not 
horizontal or vertical must have rational slope with numerator and 
denominator between 1 and 6 inclusive (possibly negative). Thus, just 
48 slopes are allowed.

For simple pictures, this is OK: draw the picture in rough, choose 
slopes for the lines from the allowed set, and then work out where the
points must be, by elementary coordinate geometry. There are a couple 
of programs available which take all the calculation out: you draw 
your picture using the mouse, and it is automagically compiled into 
\LaTeX\ source. But for more complicated figures, mathematical insight
or computational power may be required. For example, consider the 
following ruled quadric.


$$\hbox{%
\setlength{\unitlength}{0.02mm}
\picture(1200,1800)(-600,-100)
\put(707,-141){\Line(0,1){1697}}
\put(-707,-141){\Line(0,1){1697}}
\put(-834,-110){\Line(1,6){282}}
\put(834,-110){\Line(-1,6){282}}
\put(-552,-167){\Line(-1,6){282}}
\put(552,-167){\Line(1,6){282}}
\put(-929,-74){\Line(1,3){558}}
\put(929,-74){\Line(-1,3){558}}
\put(-371,-186){\Line(-1,3){558}}
\put(371,-186){\Line(1,3){558}}
\put(-986,-33){\Line(1,2){822}}
\put(986,-33){\Line(-1,2){822}}
\put(-164,-197){\Line(-1,2){822}}
\put(164,-197){\Line(1,2){822}}
\put(69,-200){\Line(-2,3){1067}}
\put(-69,-200){\Line(2,3){1067}}
\put(-998,14){\Line(2,3){1067}}
\put(998,14){\Line(-2,3){1067}}
\put(1000,0){\Line(-5,6){1338}}
\put(-1000,0){\Line(5,6){1338}}
\put(338,-188){\Line(-5,6){1338}}
\put(-338,-188){\Line(5,6){1338}}
\put(924,-76){\Line(-1,1){1631}}
\put(-924,-76){\Line(1,1){1631}}
\put(707,-141){\Line(-1,1){1631}}
\put(-707,-141){\Line(1,1){1631}}
\endpicture}$$

The obvious way to draw this is to take two horizontal circles, one 
above the other; take equally spaced points on one, and join them to 
the points a fixed angle in front or behind on the other, and then 
work out the plane projection in the usual way. With \LaTeX, it is 
necessary to work out a formula for the angle which will give the 
projected line a given slope, and solve it for various admissible 
slopes.

An added complication here is that my first serious use of this 
mechanism was for a book [1] for which my co-author sent me his part
(by email) in \AmSTeX. Converting it to plain \TeX\ was straightforward,
but took time; I was not prepared to take the further step to 
\LaTeX. Malcolm Clark had told me that it was easy enough to convert 
the \LaTeX\ picture commands to plain \TeX; I couldn't find his 
version in the Aston archive, so I took him at his word and did it 
myself. Look at the book and judge the result!

I learnt too late that \PiCTeX\ might have helped me here. But I 
believe that simpler tools have their place.

\section{Pictures}
Suppose you want to include in your document a picture not made up of 
geometric elements. If you are a \PS\ programmer or a \dvi\ 
wizard, anything is possible; but the result will not be portable. I 
would like to be able to preview, print in draft on a 9-pin dot matrix
printer, and send the file over the network to the laser printer.

My terminal and my machine at home are both Atari STs. The commonest 
picture format for DTP on this machine, also used in the PC world, is 
the dreaded {\tt.img}. After combing the public domain for information on 
the {\tt.img} file format, I wrote a program to translate a {\tt.img} file into 
\TeX\ input consisting of long sequences of boxes and rules.

It doesn't work on all inputs (I've never met anyone who claims to 
have a program which handles all {\tt.img} files!), but seems fine on mono 
screen snapshots. The \TeX\ file is liable to be very big, so this is 
only recommended for small images (logos, signatures, etc.) The result
is (of course) as portable as any plain \TeX\ input, and can be re-%
scaled by setting two pixel size parameters at the start of the file. 
Here, for example, is an image probably familiar to all GEM-based 
computer users.

\input tiger
$$\tiger$$

{\frenchspacing
\def\item#1{\par\hangindent1.5em\hangafter1{\noindent
\hbox to 1.5em{#1\hfil}}}
\def\bibitem#1#2{\item{{#1}}{#2}}
\section{Bibliography}
\bibitem{1}{{\sc P J Cameron \& J H van Lint,} {\sl Designs, Graphs, Codes and their
Links}, London Math. Soc. Student Texts {\bf 22}, Cambridge Univ. Press,
1991.}
\bibitem{2}{{\sc Norbert Schwarz,} {\sl Introduction to \TeX}\ (transl. {\sc J Krieger}),
Addison-Wesley, 1990.}
\author{Peter Cameron}}


\endinput Cameron}
}


\endinput90.}}

\author{Peter Cameron}
\endinputtle to be very big, so this is 
only recommended for small images (logos, signatures, etc.) The result
is (of course) as portable as any plain \TeX\ input, and can be re-%
scaled by setting two pixel size parameters at the start of the file. 
Here, for example, is an image probably familiar to all GEM-based 
computer users.

\input tiger

$$\tiger$$

\medbreak

\noindent{\sl References}
\frenchspacing

1. P. J. Cameron \& J. H. van Lint, {\sl Designs, Graphs, Codes and their
Links}, London Math. Soc. Student Texts {\bf 22}, Cambridge Univ. Press,
1991.

2. N. Schwarz, {\sl Introduction to \TeX}\ (transl. J. Krieger),
Addison-Wesley, 1990.

\medskip

\line{\hfill\sl Peter Cameron}

\bye


