Getting TeX labeling on graphics

Email from TeXhax Digest V89 #56. This is cited in M. Goosens, S. Rahtz, and F. Mittelbach, The LaTeX Graphics Companion (Addison-Wesley, 1997).
Date: Wed, 24 May 89 12:32:22 PDT
From: KARNEY%PPC.MFENET@CCC.MFECC.LLNL.GOV
Subject: Getting TeX labeling on graphics
Keywords: graphics, TeX

Most of my graphics is generated by scientific programs and so would be most easily included in a TeX document via a \special which pulled in a graphics file. Unfortunately, no scientific graphics packages do their labeling in TeX. Furthermore the labeling of most packages is very ugly. My current solution is to get the graphics package to produce a plot with NO labels, include this via a \special within a LaTeX picture environment and use \put (or \multiput for axis labels) to insert the TeX labels. This is of course rather labor intensive, and becomes infeasible with complicated plots where the positions of the labels are variable (for example, a contour plot with the contours labeled). A step towards a more streamlined solution is as follows: Assume that the graphics package can output alphanumeric labels and each label has associated with it a position on the plot (and possibly a writing direction if rotated text is to be supported). Assume also that the DVI driver can locate these labels and their corresponding positions and directions. In the LaTeX file, you would include a series of commands, one for each label: \plotlabel[positioning]{alphanumeric-label}{TeX-label} [positioning] is one of the LaTeX positioning commands, e.g., [tl] for top left. This governs how the TeX'ed label is positioned relative to the current location (as given by the graphics file) {alphanumeric-label} is the label text as it appears in the graphics file, e.g., {alpha-squared}. {TeX-label} is the TeX'ed version, e.g., {$\alpha^2$}. \plotlabel would then do something like: \special{plotlabel-start tl alpha-squared}% \vbox to 0pt {\hbox to 0pt{$\alpha^2$\hss}\vss}% \special{plotlabel-end} The DVI file on encountering \special{plotlabel-start ...} would NOT typeset the following TeX box, but squirrel it away in a table under an index "alpha-squared". In a following \special calling for the inclusion of the graphics file, the labels would be looked up in the table and replaced with their TeX equivalent, correctly positioned (and maybe rotated appropriatedly). On complex plots with many numeric labels, I would imagine having a separate program that could scan the graphics file and extract the alpha-numeric labels into a file, which could be edited and inserted into the TeX file. None of this exists (as far as I know). And I am not volunteering to implement it! But with a committee looking at standards for \special, I thought it would be a good idea to air these ideas. Charles Karney Plasma Physics Laboratory Phone: +1 609 243 2607 Princeton University MFEnet: Karney@PPC.MFEnet PO Box 451 Internet: Karney%PPC.MFEnet@NMFECC.LLNL.GOV Princeton, NJ 08543-0451 Bitnet: Karney%PPC.MFEnet@LBL.Bitnet

Charles Karney (1989-05-24)
Back to index.