| 1 |
.nr PS 11 |
| 2 |
.nr VS 13 |
| 3 |
.TL |
| 4 |
MetaPost with groff |
| 5 |
.LP |
| 6 |
Since MetaPost is a picture-drawing language that outputs PostScript, |
| 7 |
it is necessary to use the |
| 8 |
.ft CW |
| 9 |
-mpspic |
| 10 |
.ft |
| 11 |
macro package, which is automatically included when \fIgroff\fR |
| 12 |
is invoked with the |
| 13 |
.ft CW |
| 14 |
-Tps |
| 15 |
.ft |
| 16 |
option to prepare output for PostScript printers or previewers. |
| 17 |
.PP |
| 18 |
Suppose you have written some figures in MetaPost and placed |
| 19 |
the input in a file \f(CWfigures.mp\fR. |
| 20 |
Running |
| 21 |
.nf |
| 22 |
.ft CW |
| 23 |
mp -T figures |
| 24 |
.ft |
| 25 |
.fi |
| 26 |
to invoke the MetaPost interpreter produces output files |
| 27 |
\f(CWfigures.1\fR, \f(CWfigures.2\fR, .\|.\|. |
| 28 |
which can be included in a \fIgroff\fR document via macro calls |
| 29 |
such as |
| 30 |
.nf |
| 31 |
.ft CW |
| 32 |
.PSPIC figures.1 width height |
| 33 |
.ft |
| 34 |
.fi |
| 35 |
as explained in the \fIgrops\fR(1) documentation. |
| 36 |
Note that the picture gets rescaled if the height and width |
| 37 |
in the \f(CW.PSPIC\fR command don't match \fImp\fR's idea of |
| 38 |
the picture dimensions. |
| 39 |
.PP |
| 40 |
For instance, |
| 41 |
.PSPIC figs.1 1.5i 1.08i |
| 42 |
this figure was derived from a file |
| 43 |
.ft CW |
| 44 |
figs.mp |
| 45 |
.ft |
| 46 |
and included at this point by invoking the \f(CW.PSPIC\fR macro |
| 47 |
with height 1.08 inches and width 1.5 inches. |
| 48 |
.PP |
| 49 |
The file |
| 50 |
.ft CW |
| 51 |
figs.mp |
| 52 |
.ft |
| 53 |
looks like this: |
| 54 |
.nf |
| 55 |
.ft CW |
| 56 |
.nr PS 9 |
| 57 |
.nr VS 11 |
| 58 |
prologues:=1; |
| 59 |
input boxes |
| 60 |
beginfig(1); |
| 61 |
pair shadowshift; shadowshift=(1,-1)*bp; |
| 62 |
|
| 63 |
def drawshadowed(text t) = |
| 64 |
forsuffixes $=t: |
| 65 |
fill bpath$ shifted shadowshift; |
| 66 |
unfill bpath$; |
| 67 |
drawboxed($); |
| 68 |
endfor |
| 69 |
enddef; |
| 70 |
|
| 71 |
boxit.a(btex \\s8A\\s+2 \\(lh a etex); |
| 72 |
circleit.b(btex $e sup {i omega t}$ etex rotated 20); |
| 73 |
b.w - a.e = (10bp,0); |
| 74 |
drawshadowed(a,b); |
| 75 |
draw a.e..b.w; |
| 76 |
|
| 77 |
draw bbox currentpicture dashed evenly; |
| 78 |
endfig; |
| 79 |
.nr PS 11 |
| 80 |
.nr VS 13 |
| 81 |
.ft |
| 82 |
.fi |
| 83 |
.PP |
| 84 |
Note that the typesetting commands in the |
| 85 |
\f(CWbtex\fR.\|.\|.\f(CWetex\fR blocks in the above example |
| 86 |
are processed by |
| 87 |
.nf |
| 88 |
.ft CW |
| 89 |
eqn -d\\$\\$ | troff -Tpost |
| 90 |
.ft |
| 91 |
.fi |
| 92 |
If a different \fItroff\fR pipeline is desired, it can be specified |
| 93 |
via the |
| 94 |
.ft CW |
| 95 |
TROFF |
| 96 |
.ft |
| 97 |
environment variable. For example, |
| 98 |
.nf |
| 99 |
.ft CW |
| 100 |
TROFF='tbl | eqn -d\\$\\$ | troff -Tpost' |
| 101 |
.ft |
| 102 |
.fi |
| 103 |
adds \fItbl\fR to the pipeline in addition to \fIeqn\fR. |
| 104 |
.PP |
| 105 |
Macro definitions and such can be added via the standard |
| 106 |
\f(CWverbatimtex\fR.\|.\|.\f(CWetex\fR mechanism that adds the |
| 107 |
given material to the \fItroff\fR input. Such material should |
| 108 |
not generate any output since this would get mixed up with the |
| 109 |
next \f(CWbtex\fR.\|.\|.\f(CWetex\fR block. Thus, newlines between |
| 110 |
\f(CWverbatimtex\fR and \f(CWetex\fR must be protected with \f(CW\\\fR. |
| 111 |
.PP |
| 112 |
Unfortunately, typesetting of \f(CWbtex\fR.\|.\|.\f(CWetex\fR blocks |
| 113 |
currently doesn't work with \fIgroff\fR and equires a UNIX |
| 114 |
\fItroff\fR implementation, because MetaPost's \f(CWdmp\fR |
| 115 |
post-processor can't handle \fIgroff\fR's extended font and output |
| 116 |
file formats documented in \fIgroff_font\fR(5) and \fIgroff_out\fR(5). |
| 117 |
Nevertheless, using \fItroff\fR to prepare figures with MetaPost |
| 118 |
and \fIgroff\fR to typeset them may still be a useful combination |
| 119 |
if your \fItroff\fR implementation doesn't provide the |
| 120 |
.ft CW |
| 121 |
-mpictures |
| 122 |
.ft |
| 123 |
macro packages. |
| 124 |
|