UK TeX FAQ -- question 92

### Making MetaPost output display in ghostscript

MetaPost ordinarily expects its output to be included in some context where the 'standard' Metafont fonts (that you've specified) are already defined - for example, as a figure in TeX document. If you're debugging your MetaPost code, you may want to view it in ghostscript (or some other PostScript previewer). However, the PostScript 'engine' in ghostscript doesn't ordinarily have the fonts loaded, and you'll eperience an error such as

      Error: /undefined in cmmi10

There is provision in MetaPost for avoiding this problem: issue the command `prologues := 2;` at the start of the `.mp` file.

Unfortunately, the PostScript that MetaPost inserts in its output, following this command, is incompatible with ordinary use of the PostScript in inclusions into (La)TeX documents, so it's best to make the `prologues` command optional. Furthermore, MetaPost takes a very simple-minded approach to font encoding: since TeX font encodings regularly confuse sophisticated minds, this can prove troublesome. If you're suffering such problems (the symptom is that characters disappear, or are wrongly presented) the only solution is to view the 'original' metapost output after processing through LaTeX and dvips.

Conditional compilation may be done either by inputting MyFigure.mp indirectly from a simple wrapper MyFigureDisplay.mp:

      prologues := 2;
      input MyFigure

or by issuing a shell command such as

      mp '\prologues:=2; input MyFigure'

(which will work without the quote marks if you're not using a Unix shell).

A suitable LaTeX route would involve processing MyFigure.tex, which contains:

      \documentclass{article}
      \usepackage{graphicx}
      \begin{document}
      \thispagestyle{empty}
      \includegraphics{MyFigure.1}
      \end{document}

Processing the resulting DVI file with the dvips command

      dvips -E -o MyFigure.eps MyFigure

would then give a satisfactory Encapsulated PostScript file.