[metapost] Labels cause errors in the postscript file.

Laurence Finston lfinsto1 at gwdg.de
Sun Dec 19 17:10:17 CET 2004


> 
> I saved this in trial.mp. Then I executed mpost trial. I got the output  
> file trial.30 without any error messages. But when I try to open  
> trial.30 in gv or ggv I get several Postscript error messages. If I  
> remove dotlabel statements, then there are no error messages. What is  
> the problem? Please help.
> 

MetaPost outputs Encapsulated PostScript files by default.
It's possible to get it to output structured PostScript files by setting
`prologues := 1;'.  This is documented in John Hobby's _A User's Manual for
MetaPost_, pp. 21-22.  However, this won't work work with TeX fonts, so it's
probably not what you want, since you use math mode in your labels.  

There are various solutions to this problem.  I use `dvips', which provides
TeX macros for including EPS files, including `\epsffile'.
So you can include `trial.30' in a TeX file like this:

\input epsf
\def\epsfsize#1#2{#1}

\epsffile{trial.30}

You can put the graphic in boxes like this (or any other way you like):

\vbox to \vsize{\vfil
\line{\hskip 2cm\epsffile{trial.30}\hss}
\vss}

The easiest way I've found to make a structured PS file containing a graphic
only, perhaps with a margin, that contains TeX labels, is to put it in a box
in a TeX file, use the `\wd', `\ht', and perhaps `\dp' of the box to set
`\vsize' and `\hsize', run TeX, and then `dvips'.  Other forms of conversion
seem to have difficulty with TeX's fonts.  I've written a trivial Emacs-Lisp
function to automate this.  If you want it, I'll put it in the CVS repository
for GNU 3DLDF on the GNU Savannah website.

Laurence Finston
http://www.gnu.org/software/3dldf/LDF.html



More information about the metapost mailing list