summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2006-11-28 13:24:53 +0000
committerTaco Hoekwater <taco@elvenkind.com>2006-11-28 13:24:53 +0000
commit2316028a0dedb2fa848c9e3bacaad4580dcc4290 (patch)
tree750b5fe86da1917f5482b7d0e643e77a3b31594e /Master/texmf-dist/doc
parentc8a7170337d602789e93f5b765c5b9c06f50b0d7 (diff)
MetaPost 0.992 plus support files
git-svn-id: svn://tug.org/texlive/trunk@2554 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc')
-rw-r--r--Master/texmf-dist/doc/metapost/base/grdemo-doc.pdfbin0 -> 7430 bytes
-rw-r--r--Master/texmf-dist/doc/metapost/base/grdemo.pdfbin8325 -> 3044 bytes
-rw-r--r--Master/texmf-dist/doc/metapost/base/mpgraph.pdfbin173873 -> 210090 bytes
-rw-r--r--Master/texmf-dist/doc/metapost/base/mpman.pdfbin466130 -> 481031 bytes
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/Makefile36
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/README6
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/ctabbing.sty4
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/examples.mp3
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/figs.mp3
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/grdemo-doc.ms184
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/grdemo.eps779
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/grdemo.mp37
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/manfig.mp15
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpgraph.bib9
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpgraph.mp12
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpgraph.tex57
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpintro.bib3
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpintro.tex2
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpman.bib5
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpman.ist3
-rw-r--r--Master/texmf-dist/doc/metapost/base/source/mpman.tex4221
21 files changed, 3555 insertions, 1824 deletions
diff --git a/Master/texmf-dist/doc/metapost/base/grdemo-doc.pdf b/Master/texmf-dist/doc/metapost/base/grdemo-doc.pdf
new file mode 100644
index 00000000000..4d11331f522
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/base/grdemo-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/metapost/base/grdemo.pdf b/Master/texmf-dist/doc/metapost/base/grdemo.pdf
index 2769c05b35a..faeaa99e6f3 100644
--- a/Master/texmf-dist/doc/metapost/base/grdemo.pdf
+++ b/Master/texmf-dist/doc/metapost/base/grdemo.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/metapost/base/mpgraph.pdf b/Master/texmf-dist/doc/metapost/base/mpgraph.pdf
index d4b2b3df1d0..ce2c6bcdc8e 100644
--- a/Master/texmf-dist/doc/metapost/base/mpgraph.pdf
+++ b/Master/texmf-dist/doc/metapost/base/mpgraph.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/metapost/base/mpman.pdf b/Master/texmf-dist/doc/metapost/base/mpman.pdf
index c9546984f9e..fdd20d6f4de 100644
--- a/Master/texmf-dist/doc/metapost/base/mpman.pdf
+++ b/Master/texmf-dist/doc/metapost/base/mpman.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/metapost/base/source/Makefile b/Master/texmf-dist/doc/metapost/base/source/Makefile
index ce7f3098a02..7c14b2d2b08 100644
--- a/Master/texmf-dist/doc/metapost/base/source/Makefile
+++ b/Master/texmf-dist/doc/metapost/base/source/Makefile
@@ -1,31 +1,31 @@
+# $Id: Makefile,v 1.4 2005/03/21 15:25:51 taco Exp $
# Makefile for mpman and mpgraph.
-# (../Makefile has rules for building grdemo and mpintro.)
+# Public domain.
#
-%.pdf: %.ps
- ps2pdf $< || rm -f $@
+# (In TeX Live, another Makefile has rules for building grdemo and mpintro.)
+#
-%.ps: %.dvi
- dvips -t letter $< -o $@ || rm -f $@
+pdflatex = pdflatex
+mpost = TEX=tex mpost
all: mpman.pdf mpgraph.pdf
-mpgraph.dvi: mpgraph.tex mpgraph.bib mpgraph.mp
- mpost mpgraph
- latex mpgraph
+mpgraph.pdf: mpgraph.tex mpgraph.bib mpgraph.mp
+ $(mpost) mpgraph
+ $(pdflatex) mpgraph
bibtex mpgraph
- latex mpgraph
- latex mpgraph
+ $(pdflatex) mpgraph
+ $(pdflatex) mpgraph
-mpman.dvi: mpman.tex mpman.bib mpman.ist manfig.mp
- mpost manfig
- latex mpman
+mpman.pdf: mpman.tex mpman.bib mpman.ist manfig.mp
+ $(mpost) manfig
+ $(pdflatex) mpman
bibtex mpman
- latex mpman
- latex mpman
+ $(pdflatex) mpman
+ $(pdflatex) mpman
makeindex -s mpman.ist mpman
- latex mpman
+ $(pdflatex) mpman
clean distclean:
- rm -f manfig.[0-9]* mpgraph.[0-9]*
- rm -f *.aux *.bbl *.blg *.dvi *.log *.mpx *.pdf *.ps
+ rm -f *.aux *.bbl *.blg *.dvi *.log *.mpx *.mps
rm -f *.idx *.ilg *.ind *.toc
diff --git a/Master/texmf-dist/doc/metapost/base/source/README b/Master/texmf-dist/doc/metapost/base/source/README
index 117f8773fa7..c482b64f0db 100644
--- a/Master/texmf-dist/doc/metapost/base/source/README
+++ b/Master/texmf-dist/doc/metapost/base/source/README
@@ -1,3 +1,6 @@
+$Id: README,v 1.2 2004/09/19 19:10:08 karl Exp $
+Public domain.
+
This is the source for the documentation for MetaPost, consisting of
"A User's Manual for MetaPost" and "Drawing Graphs with MetaPost",
written by John D. Hobby. They were converted to more modern LaTeX by
@@ -9,6 +12,9 @@ Hobby makes these requests:
- I request to be consulted before significant changes are made.
See the end of mpman.tex or mpgraph.tex for the precise conditions.
+Auxiliary files (and the MetaPost software itself) are public domain,
+including the data (.d) files here, which due to file format limitations
+cannot incorporate a license themselves.
Included files:
diff --git a/Master/texmf-dist/doc/metapost/base/source/ctabbing.sty b/Master/texmf-dist/doc/metapost/base/source/ctabbing.sty
index 2f60af48011..acc4c9c8df0 100644
--- a/Master/texmf-dist/doc/metapost/base/source/ctabbing.sty
+++ b/Master/texmf-dist/doc/metapost/base/source/ctabbing.sty
@@ -1,4 +1,6 @@
-
+% $Id: ctabbing.sty,v 1.2 2004/09/19 19:10:08 karl Exp $
+% Public domain.
+%
% The ctabbing environment is a centered tabbing environment suitable for
% displaying program fragments. The vertical spacing is exactly like that
% for normal text in a center environment. This is achieved by setting
diff --git a/Master/texmf-dist/doc/metapost/base/source/examples.mp b/Master/texmf-dist/doc/metapost/base/source/examples.mp
index 0e2a8dc0a65..2cd4cb6811b 100644
--- a/Master/texmf-dist/doc/metapost/base/source/examples.mp
+++ b/Master/texmf-dist/doc/metapost/base/source/examples.mp
@@ -1,3 +1,6 @@
+% $Id: examples.mp,v 1.2 2004/09/19 19:10:08 karl Exp $
+% Examples for MetaPost doc, by John Hobby. Public domain.
+
beginfig(1);
a=.7in; b=0.5in;
z0=(0,0); z1=(a,0); z2=(0,b);
diff --git a/Master/texmf-dist/doc/metapost/base/source/figs.mp b/Master/texmf-dist/doc/metapost/base/source/figs.mp
index 67c86a098d1..e71bf2a9f7f 100644
--- a/Master/texmf-dist/doc/metapost/base/source/figs.mp
+++ b/Master/texmf-dist/doc/metapost/base/source/figs.mp
@@ -1,3 +1,6 @@
+% $Id: figs.mp,v 1.2 2004/09/19 19:10:08 karl Exp $
+% Examples for MetaPost doc, by John Hobby. Public domain.
+
input boxes
beginfig(1);
pair shadowshift; shadowshift=(1,-1)*bp;
diff --git a/Master/texmf-dist/doc/metapost/base/source/grdemo-doc.ms b/Master/texmf-dist/doc/metapost/base/source/grdemo-doc.ms
new file mode 100644
index 00000000000..19c0ed030d7
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/base/source/grdemo-doc.ms
@@ -0,0 +1,184 @@
+.\" grdemo-doc.ms
+.\"
+.
+.nr PS 11
+.nr VS 13
+.
+.TL
+MetaPost with groff
+.
+.LP
+John Hobby's MetaPost program had an \f[I]AT&T troff\/\f[P]interface which
+have been changed to use \f[I]GNU troff\/\f[P] instead.
+.
+.
+.SH
+Usage
+.
+.LP
+Since MetaPost is a picture-drawing language that outputs PostScript, it is
+necessary to use the \f[CW]\%-mpspic\f[P] macro package, which is
+automatically included when \f[I]groff\/\f[P](1) is invoked with the
+\f[CW]\%-Tps\f[P] option to prepare output for PostScript printers or
+previewers.
+.
+.PP
+Suppose you have written some figures in MetaPost and placed the input in a
+file \f[CW]\%figures.mp\f[P].
+Running
+.
+.DS I
+.ft CW
+mp -T figures
+.ft
+.DE
+.
+to invoke the MetaPost interpreter produces output files
+\f[CW]\%figures.1\f[P], \f[CW]\%figures.2\f[P], \&.\|.\|.
+.
+.PP
+Standalone EPS pictures can be produced from such files by
+\f[CW]\%fixgrofffonts\f[P], that fixes comments according to
+Adobe Document Structuring Conventions (DSC), embeds
+font reencoding commands and non-standard fonts.
+.
+.DS I
+.nf
+.ft CW
+fixgrofffonts < figures.1 > figures1.eps
+fixgrofffonts < figures.2 > figures2.eps
+\&...
+.ft
+.fi
+.DE
+.
+.PP
+Before these figures can be included into \f[I]groff\/\f[P], they have to
+be processed with the \f[CW]\%fixmp\f[P] script:
+It adds an encoding vector for all text fonts back to the file (which
+MetaPost can't add itself) and changes the Adobe Document Structuring
+Conventions (DSC) comments to something \f[I]groff\/\f[P] can handle.
+.
+.DS I
+.nf
+.ft CW
+fixmp < figures.1 > figures.1ps
+fixmp < figures.2 > figures.2ps
+\&...
+.ft
+.fi
+.DE
+.
+Now the converted files can be included in a \f[I]groff\/\f[P] document via
+macro calls such as
+.
+.DS I
+.ft CW
+\&.PSPIC figures.1ps [width [height]]
+.ft
+.DE
+.
+as explained in the \f[I]grops\/\f[P](1) documentation.
+Note that the picture gets rescaled if the height and width in the
+\f[CW]\%.PSPIC\f[P] command don't match \f[I]mp\/\f[P]'s idea of the
+picture dimensions.
+.
+.
+.SH
+An example
+.
+.PSPIC grdemo.1ps
+.
+.LP
+This figure was derived from a file \f[CW]\%grdemo.mp\f[P] and included at
+this point by invoking the \f[CW]\%.PSPIC\f[P] macro (omitting the height
+and width parameters to avoid rescaling).
+.
+.PP
+The file \f[CW]\%grdemo.mp\f[P] looks like this:
+.
+.DS I
+.nf
+.ft CW
+.ps 9
+.vs 11
+verbatimtex
+\&.EQ
+delim $$
+\&.EN
+\e# etex
+
+input boxes
+
+beginfig(1);
+ pair shadowshift;
+ shadowshift = (1, -1) * bp;
+
+ def drawshadowed(text t) =
+ forsuffixes $=t:
+ fill bpath$ shifted shadowshift;
+ unfill bpath$;
+ drawboxed($);
+ endfor
+ enddef;
+
+ boxit.a(btex \e[12] \es8A\es+2 \e[lh] a etex);
+ circleit.b(btex $e sup {i omega t}$ etex rotated 20);
+
+ b.w - a.e = (10bp, 0);
+
+ drawshadowed(a, b);
+ draw a.e .. b.w;
+
+ label.top(btex \e[Cs] \e[Po] \e[Eu] etex, a.n);
+ label.llft(btex \e[Fn] etex, a.s);
+
+ draw bbox currentpicture dashed evenly;
+endfig;
+
+end
+.ps 11
+.vs 13
+.ft
+.fi
+.DE
+.
+.
+.SH
+Changing GNU troff pipeline
+.PP
+Note that, by default, the typesetting commands in the \f[CW]\%btex\f[P]
+\&.\|.\|.\& \f[CW]\%etex\f[P] blocks in the above example
+are processed by
+.
+.DS I
+.ft CW
+eqn -Tps -d\e$\e$ | troff -Tps
+.ft
+.DE
+.
+If a different \f[I]troff\/\f[P] pipeline must be used it can be
+specified via the \f[CW]\%TROFF\f[P] environment variable.
+For \f[I]groff\f[P], the following is recommended:
+.
+.DS I
+.ft CW
+TROFF='groff -teZ'
+.ft
+.DE
+.
+It adds \f[I]tbl\/\f[P] to the pipeline in addition to \f[I]eqn\f[P],
+producing output for \f[I]groff\/\f[P]'s default `ps' device. Note that
+you then have to specify the left and right delimiters of \f[I]eqn\/\f[P]'s
+in-line equations within the document (which is good practice anyway).
+.
+.PP
+Macro definitions and such can be added via the standard
+\f[CW]\%verbatimtex\f[P] \&.\|.\|.\& \f[CW]\%etex\f[P] mechanism that adds
+the given material to the \f[I]troff\/\f[P] input.
+Such material should not generate any output since this would get mixed up
+with the next \f[CW]\%btex\f[P] .\|.\|.\& \f[CW]\%etex\f[P] block.
+Note the comment escape right before the first \f[CW]\%etex\f[P] command in
+the above example to avoid an empty line.
+.
+.\" eof
diff --git a/Master/texmf-dist/doc/metapost/base/source/grdemo.eps b/Master/texmf-dist/doc/metapost/base/source/grdemo.eps
new file mode 100644
index 00000000000..ae476c19730
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/base/source/grdemo.eps
@@ -0,0 +1,779 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%BoundingBox: -6 -17 73 22
+%%HiResBoundingBox: -5.5 -16.14502 72.741 21.95007
+%%Creator: MetaPost 0.901
+%%CreationDate: 2006.03.12:1621
+%%Pages: 1
+%%DocumentNeededResources: font Times-Roman ZapfDingbats Times-Italic Symbol
+%%DocumentSuppliedResources: encoding groffEncoding
+%%+ font ZapfDingbats-Reverse Symbol-Slanted FreeEuro
+%%EndComments
+%%BeginSetup
+%%IncludeResource: font Times-Roman
+%%IncludeResource: font ZapfDingbats
+%%IncludeResource: font Times-Italic
+%%IncludeResource: font Symbol
+%%BeginResource: font Symbol-Slanted
+%!PS-Adobe-3.0 Resource-Font
+%%DocumentNeededResources: font Symbol
+/MakeTransformedFont{
+findfont dup maxlength dict begin
+{
+exch dup dup/FID ne exch/UniqueID ne and{
+exch def
+}{
+pop pop
+}ifelse
+}forall
+/FontBBox
+currentdict/FontBBox get
+4 array copy def
+FontBBox aload pop
+4 index transform 4 2 roll
+4 index transform 4 2 roll
+FontBBox astore pop
+FontMatrix exch matrix concatmatrix
+/FontMatrix exch def
+dup/FontName exch def
+currentdict end
+definefont pop
+}bind def
+%%IncludeResource: font Symbol
+/Symbol-Slanted
+[.89 0.0 15.5 dup sin exch cos div .89 0.0 0.0]
+/Symbol
+MakeTransformedFont
+%%EndResource
+%%BeginResource: font ZapfDingbats-Reverse
+%!PS-Adobe-3.0 Resource-Font
+%%DocumentNeededResources: font ZapfDingbats
+%%IncludeResource: font ZapfDingbats
+/ZapfDingbats findfont[-1 0 0 1 0 0]makefont
+dup length 1 add dict begin
+{
+exch dup dup/FID ne exch/UniqueID ne and{
+exch def
+}{
+pop pop
+}ifelse
+}forall
+/FontName/ZapfDingbats-Reverse def
+/Metrics 202 dict dup begin
+/space[0 -278]def
+/a1[-939 -974]def
+/a2[-926 -961]def
+/a202[-939 -974]def
+/a3[-945 -980]def
+/a4[-685 -719]def
+/a5[-754 -789]def
+/a119[-755 -790]def
+/a118[-756 -791]def
+/a117[-655 -690]def
+/a11[-925 -960]def
+/a12[-904 -939]def
+/a13[-520 -549]def
+/a14[-821 -855]def
+/a15[-876 -911]def
+/a16[-898 -933]def
+/a105[-876 -911]def
+/a17[-910 -945]def
+/a18[-939 -974]def
+/a19[-721 -755]def
+/a20[-811 -846]def
+/a21[-727 -762]def
+/a22[-726 -761]def
+/a23[-572 -571]def
+/a24[-641 -677]def
+/a25[-728 -763]def
+/a26[-725 -760]def
+/a27[-724 -759]def
+/a28[-719 -754]def
+/a6[-459 -494]def
+/a7[-517 -552]def
+/a8[-502 -537]def
+/a9[-542 -577]def
+/a10[-657 -692]def
+/a29[-751 -786]def
+/a30[-753 -788]def
+/a31[-753 -788]def
+/a32[-755 -790]def
+/a33[-758 -793]def
+/a34[-759 -794]def
+/a35[-781 -816]def
+/a36[-788 -823]def
+/a37[-754 -789]def
+/a38[-806 -841]def
+/a39[-788 -823]def
+/a40[-798 -833]def
+/a41[-781 -816]def
+/a42[-796 -831]def
+/a43[-888 -923]def
+/a44[-709 -744]def
+/a45[-688 -723]def
+/a46[-714 -749]def
+/a47[-756 -790]def
+/a48[-757 -792]def
+/a49[-660 -695]def
+/a50[-741 -776]def
+/a51[-733 -768]def
+/a52[-757 -792]def
+/a53[-724 -759]def
+/a54[-672 -707]def
+/a55[-673 -708]def
+/a56[-647 -682]def
+/a57[-666 -701]def
+/a58[-791 -826]def
+/a59[-780 -815]def
+/a60[-754 -789]def
+/a61[-754 -789]def
+/a62[-673 -707]def
+/a63[-651 -687]def
+/a64[-661 -696]def
+/a65[-654 -689]def
+/a66[-752 -786]def
+/a67[-752 -787]def
+/a68[-678 -713]def
+/a69[-756 -791]def
+/a70[-749 -785]def
+/a71[-756 -791]def
+/a72[-838 -873]def
+/a73[-726 -761]def
+/a74[-727 -762]def
+/a203[-727 -762]def
+/a75[-724 -759]def
+/a204[-724 -759]def
+/a76[-857 -892]def
+/a77[-857 -892]def
+/a78[-753 -788]def
+/a79[-749 -784]def
+/a81[-403 -438]def
+/a82[-103 -138]def
+/a83[-242 -277]def
+/a84[-380 -415]def
+/a97[-357 -392]def
+/a98[-358 -392]def
+/a99[-633 -668]def
+/a100[-632 -668]def
+/a101[-697 -732]def
+/a102[-488 -544]def
+/a103[-510 -544]def
+/a104[-875 -910]def
+/a106[-632 -667]def
+/a107[-725 -760]def
+/a108[-760 -760]def
+/a112[-741 -776]def
+/a111[-561 -595]def
+/a110[-659 -694]def
+/a109[-592 -626]def
+/a120[-753 -788]def
+/a121[-753 -788]def
+/a122[-753 -788]def
+/a123[-753 -788]def
+/a124[-753 -788]def
+/a125[-753 -788]def
+/a126[-753 -788]def
+/a127[-753 -788]def
+/a128[-753 -788]def
+/a129[-753 -788]def
+/a130[-753 -788]def
+/a131[-753 -788]def
+/a132[-753 -788]def
+/a133[-753 -788]def
+/a134[-753 -788]def
+/a135[-753 -788]def
+/a136[-753 -788]def
+/a137[-753 -788]def
+/a138[-753 -788]def
+/a139[-753 -788]def
+/a140[-753 -788]def
+/a141[-753 -788]def
+/a142[-753 -788]def
+/a143[-753 -788]def
+/a144[-753 -788]def
+/a145[-753 -788]def
+/a146[-753 -788]def
+/a147[-753 -788]def
+/a148[-753 -788]def
+/a149[-753 -788]def
+/a150[-753 -788]def
+/a151[-753 -788]def
+/a152[-753 -788]def
+/a153[-753 -788]def
+/a154[-753 -788]def
+/a155[-753 -788]def
+/a156[-753 -788]def
+/a157[-753 -788]def
+/a158[-753 -788]def
+/a159[-753 -788]def
+/a160[-859 -894]def
+/a161[-803 -838]def
+/a163[-982 -1016]def
+/a164[-423 -458]def
+/a196[-713 -748]def
+/a165[-889 -924]def
+/a192[-713 -748]def
+/a166[-883 -918]def
+/a167[-892 -927]def
+/a168[-893 -928]def
+/a169[-893 -928]def
+/a170[-799 -834]def
+/a171[-838 -873]def
+/a172[-793 -828]def
+/a173[-889 -924]def
+/a162[-889 -924]def
+/a174[-882 -917]def
+/a175[-895 -930]def
+/a176[-896 -931]def
+/a177[-428 -463]def
+/a178[-848 -883]def
+/a179[-801 -836]def
+/a193[-801 -836]def
+/a180[-832 -867]def
+/a199[-832 -867]def
+/a181[-661 -696]def
+/a200[-661 -696]def
+/a182[-839 -874]def
+/a201[-839 -874]def
+/a183[-725 -760]def
+/a184[-911 -946]def
+/a197[-737 -771]def
+/a185[-830 -865]def
+/a194[-737 -771]def
+/a198[-854 -888]def
+/a186[-932 -967]def
+/a195[-854 -888]def
+/a187[-796 -831]def
+/a188[-837 -873]def
+/a189[-892 -927]def
+/a190[-935 -970]def
+/a191[-884 -918]def
+/a205[-474 -509]def
+/a206[-375 -410]def
+/a85[-474 -509]def
+/a86[-375 -410]def
+/a87[-199 -234]def
+/a88[-199 -234]def
+/a89[-355 -390]def
+/a90[-355 -390]def
+/a91[-241 -276]def
+/a92[-241 -276]def
+/a93[-282 -317]def
+/a94[-282 -317]def
+/a95[-299 -334]def
+/a96[-299 -334]def
+end def
+/ZapfDingbats-Reverse currentdict end definefont pop
+%%EndResource
+%%BeginResource: font FreeEuro
+%!PS-AdobeFont-1.0: FreeEuro 001.001
+%%Title: FreeEuro
+%Version: 001.001
+%%CreationDate: Sun Jan 8 10:14:22 2006
+%%Creator: root
+%Copyright: Created by Werner Lemberg with PfaEdit 1.0
+%Copyright: (http://pfaedit.sf.net); the serif shapes are based on the
+%Copyright: Omega fonts created by Yannis Haralambous.
+% Generated by FontForge 20060105 (http://fontforge.sf.net/)
+%%EndComments
+
+FontDirectory/FreeEuro known{/FreeEuro findfont dup/UniqueID known{dup
+/UniqueID get 4166882 eq exch/FontType get 1 eq and}{pop false}ifelse
+{save true}{false}ifelse}{false}ifelse
+11 dict begin
+/FontType 1 def
+/FontMatrix [0.001 0 0 0.001 0 0 ]readonly def
+/FontName /FreeEuro def
+/FontBBox {4 -23 903 710 }readonly def
+/UniqueID 4166882 def
+/PaintType 0 def
+/FontInfo 10 dict dup begin
+ /version (001.001) readonly def
+ /Notice (Created by Werner Lemberg with PfaEdit 1.0 \050http://pfaedit.sf.net\051; the serif shapes are based on the Omega fonts created by Yannis Haralambous.) readonly def
+ /FullName (FreeEuro) readonly def
+ /FamilyName (FreeEuro) readonly def
+ /Weight (Medium) readonly def
+ /FSType 12 def
+ /ItalicAngle 0 def
+ /isFixedPitch false def
+ /UnderlinePosition -100 def
+ /UnderlineThickness 50 def
+end readonly def
+/Encoding 256 array
+ 0 1 255 { 1 index exch /.notdef put} for
+dup 0/Euro.symbol put
+dup 1/Euro.symbol.bold put
+dup 2/Euro.symbol.slanted put
+dup 3/Euro.symbol.bold.slanted put
+dup 4/Euro.serif put
+dup 5/Euro.serif.bold put
+dup 6/Euro.serif.italic put
+dup 7/Euro.serif.bold.italic put
+dup 8/Euro.sansserif put
+dup 9/Euro.sansserif.bold put
+dup 10/Euro.sansserif.slanted put
+dup 11/Euro.sansserif.bold.slanted put
+dup 12/Euro.mono put
+dup 13/Euro.mono.bold put
+dup 14/Euro.mono.slanted put
+dup 15/Euro.mono.bold.slanted put
+readonly def
+currentdict end
+currentfile eexec
+743F8413F3636CA85A9FFEFB50B4BB27302A5A63F932884E18BF5153AD36053037D1C6CD
+04294AF6A35612DB9108AC8514CB5C4A8469971B75A09F9E662068B0685490EA8C73F2DE
+2FBBCF85D15AB9385E529DAB15A40D408002E88D0C107F711BC66BF0F2E92FDDC6B188F9
+1EEB6B86050D5032E6ABCB11E343C6D795217B5973972E99A9420651ACF3B8FD4CAD1DA4
+B00642AD077A5B86240F89F2BC011009CB2CF173FF68E9A88F0018F187D5E036FE8D904F
+211842FF01AA7CAADDEB9E5A534FA3F90BDB8F6FFE24F7AC6E7BD0A74CF29EBBA51871F0
+D1FF3262EA3CAFF583545FAB762B8D9BF14C8845C4EDB387B1248A4BCCB70AEDC6C67CF6
+C4648FA00124C44166D66DE1573C926CD9C6AE4F8B89E5987035D23195432204B648D458
+39F1769201B7C68828B3E49DFEF3065D705C2EBFFFB05B8A865CE4888872146C99671EFA
+EE1F514B94B86A47AAA5F21A39786E77D443FA4CF8B525C98FC02459528C08410C679440
+CC3A160C40B14E03FAB3E267943E1FBACDD4C082777B31AD3591DAEA25DC60E0EE11AB59
+52C58879FCB35A54009A156730AF209A8D4F00CF7DD9870C8DC3E48C19BED68742376268
+0408FFD4A34A0D8659D44FADC9FC9D3084601C93FD9FCA770B1191500ECB12C8DBDB2032
+007CECE3C6A2CC8593386DC1464B94A09EA2A83438C71ACC7CAD72D074ABF6FB98EFC81B
+6A3D672D2DCC637F34ACF18D469ED29FE2C49062380E6A32850F696834FC8E46A924164A
+C64DF8F848D4D000EB6FD06A44D0320975A8EEE85173E4D7E39EC9DB03A8ED20DAED86D2
+73CE5762A5D35D1A81987F9CD9921E39C2C5CEDD661C3B3EE86B703C101C410E41648347
+7599C4CCB91234510ABAC16898D9D10E30B5FC1BABE78DF2A009E09E52816F2413899184
+AB8F942A496B56C9FDE630B13AD9F0996ADE29CABAF1443452B427A2280AD00B85F4657C
+65B47E929FB0A2A31F257B24FE4ECBAFC878C306094088E00DB2DA6D36CECE30971846B6
+39DA9BA989109507FF21FD7198736278ED1CD021BFE7689D93B425D8B6CCCF07D37C22D7
+966FB87EFBE8F6A86D4F0C4BD38F5F3A41DCEDA924FD5F0D8FF089A0F44DFD37498507D3
+2A383FC717537744CC6868EB913D5C08CD0A3F935145FD5D811F01870F6136F4EFF757C5
+D03E73FC22F88624116C08C225C1711C96A01656999AAF7414163E75548AB89F8AA85F20
+9FA6EC242ECDA0953DC61EAE4107610380DFE2807101BDBA51391685990B3D1FFEFEC97E
+0F0DE04283920370575AC06B8597EE756EEF7A3543A3E5F1B74343702A201C43411E7B76
+DC6422E2529E740A6BC6BD44ABAACD955406734AF0852471CC7B49325286AFFD2F9CFD04
+BB9CA4D0F6F0494CED1D2984E2C607FD2CE5C5A1F538CF9107771E691FAD51AE5DA70748
+F14F2FF7CE61292F6FA50D4510E4100360A4A2EBF7F9A03F7A4DAC981C6DE582BAFEBC23
+AD97EB56656A218B24D47C4345B398C14ECF5B76037D83FEB71E65F89C01133A5228496C
+DF4BCC8BD4C615C9725511A2376A01C80F1EF38757CF104DD0809121EF1A2B9F11B5BDC7
+8E4F5A1463F37E952891370E1887644D26751A261FB5EE78BEA745F4F44A9B00098EDC4E
+3547F5AE50DCBF29EF5BF82D653A148D340BC600EB411F4EA8A6A2D0B548D0B217E78943
+BDAED70072716A4406D685B55C2C0F490D2B472C49B278DB78E9914C3623825E595A541F
+509F0E7BB1A827F4E6B0EA42C668932AB48D7B4A21AC0DA7451924D1AA7CDBE80C94F109
+1A4D91C3B908060FEB07D1B454A4CE4A60F8FACA6930313E09D5F11D1D8437E6B65EEE5B
+B5570C3B66ABC491BD8CF63C2C62BC7B38A0CDFFE9D75627E6D3B23B608C7EEBD8FC655C
+D197D28E8EB319814EA71B6AD63A966DB61D9C3C7D788683559C49338D037A235FD56FA0
+059DDC6017F0919926C323327C204139F07810575A8749877FB2C0C53AF4E3962613A0E8
+7D7C37A9974105992FC6B754CF23017C2E5851BCC90F48D6847EF1EF59E42032AFE03A98
+DB363827CA07E337A5852BE832772A2981864B8C1EDAD8759ACBC132ADD0BB360F40BAFD
+FC7E5D32D724CF82FD3342D431F8F4CD9BDE2B07C8D8EED411E3A5889A8163CD1E2C2786
+F78AD3C1D9879FD6E93BD1FD8949DE47A8BCD219422B2F1316950B72E1E5170701795A0A
+80709E894C218AA64DF5684719830066B995785AB9F1603FFDCEA945FEC09F57BF886F01
+A95811C7D4200E11C7CB373AAA4301E58F74E77519E11A89751A338B38D115B365547271
+DB19E51B85B30D1EB8E3E0B95436262D52471D65BBCF5DD94F6FF1210BF09628191F8F04
+3ED7109DE2AD284954564A1C80811B9AF1686DB799D36B50EB095AF37B9117992BB6B8F9
+0CE43ED10F9D0CE4B8ED76549239A626809ECA3D5A90E23D3CFBC776D6D816A293F2A80B
+7267D1842FA102BAD77A2A775CB55473F40D3976AFC77ECDA131FF663A12795528A7EC15
+1D7854E759321709A8F4750716C949D71D332F9B0B80130916826F07E0165A5A1C5F3D8E
+EF8CDB4EE3F688867FDDD47B4D67AD677F3134D90E07A1F0A8690169AC2E176BCB7CF260
+A70E374F3EC834E3B83D19CE3A52883024D2976E8E02C0B320CFD7B8BF66D11FBBF49353
+647AC4AB23A2A5689506AB83AD60AF8783E04815CABE60A3243FC633FD12D6DA50036691
+D3A0FBD4AD1309289565FC0C449510AD58085356AD829538B97A501FA73CEB693F09D551
+8FEAE6DE59FD7871AAED96A27127286C09FDD5A1EAE421CC38F56A4AF6AD5FA9BF96BF00
+2BE0A49BE6F27636DEB364A0762BCFF054020850C9222940B0E8A08E6A77240E1A0F42DC
+07DAD0283BCD9DAC20E2A7542F5D74FC90D2661AD95350566F27125160C0525364D8B764
+E06FBC0F85531185F8B92B4ADE928B2CF0DD4736CAA76F6659D128E416E9792F24CB6B41
+CF369FF2BF9C360FA006938067DA606B2B19C8599FB28306FDACBF29841A169F6368384E
+32B6BAD4179E345AB2B3CAB35E29E154228DCDC3D4C3317295A050A8AA86273BF7178A07
+65B598EE7061AE13B11B670F2E5F90F9FDD2F09A84F247DF9C90698A44A29BEC87B3C606
+E46A35D94986363CFEB26524FD7FB88092978128B0D246934D93BF90CDD94F7D243113C0
+8BDD1E09E4AC9F6E7A5A4FDB89150632CA41E3320D6B5AC722B27984D238D29A20F69BFD
+1AB94BFA39EE52371CBEC64E16E37319ED189F2CC3992EC03A780AE4AFAEAC4FFB7A8340
+36F307F1BAB17477BF14809DA90E0AFBD0E3182D7E40A1EB1AABA8C64D9CA02044E85A82
+7FDB6C215F77FADC0443A04083E23DF21523DE178DF165F369E93AD21F34B4D72C24D5F4
+D6D19BE8F5B01AFCBBEC537C509FD7B388AA66A3E4CBCAA85601C20BEBBD2D3F11CE1CBC
+E7D8FA53FA83710A80D8795AA5FF3C2E7F063DC05DC002E8278DCC1FAF9909FFE55A633D
+86BE4C570BD9820327490CA61CA4FDDE381CDF70D97FF279F6A458E5D7B8DE5E1384F894
+3064F4F17D369F014D5A68C9F2E170BB59634AF060678CB4DC84450B94E34CA704B5DCE3
+67125FEE35A1B0A27F40E38D00CB779ACB34284080D5D78E30DE6233F0AD3FC22D170A60
+E2B7D4F206862D1890D16E3C9D720CCA05930814E00337AD8607098C68CBEB919504277D
+B3AB769CD77745B375945BC4246B813F828099DAB82512936FE106B368F189ACE1A2EAE1
+4CF5FE1C91BD0D79CE179D34A0E85F8F1BFDEF9F28C1F26924D630E845CAA19BADC44B7B
+ED9C6452C0AD01D108967D85E0779AEE557A9207164D22DFF7BCCE92D5CB9809ADFD332F
+9567C92510CFC94796AA5A312C4484183B66C44DED8476F974CE6FEBFE86178B99F1820B
+07B3D7C80F5CCCAE591BD8920814B4398A502756D3C945D07C6CD9FC2414086434151E87
+30C14D38764C532BDD5830E24C16BFF8CC19181621DD26E67259711E6CC43ED8AAE343B4
+B728BFD242C6C314B3D453DD3B3BC3986E736B4085C8D7498C9778538AC0F2DE17B9F89A
+60082B571BE433119A9522F93A4C1222A26F94A199D71F50FA5BA94CDA733E26A43A3002
+564A841FCCC267EF8F1556CF85C8AF4A649F0AC533E0E859E3E2723525FCEC1B6E6A3CE9
+0B66D585B1E7C4B953ECF941B12D3003FE14852B7978126BE4B58DF8924651697B79F333
+F2D5BC34458DFD36826F8DFD374D0D59DD01FFC2C455B1A12AC80380F48A742013D0C3D9
+C7E040364633F0476D1ECE1870386871CE95099A30F881EBE00F6E140FE58F8C1D5F2B37
+35D12A9FF60157F8691DD64E60EF9B957C586D4E2E9D5474634F7AA44D50B11B001C66CC
+F283185C6E65E32D2F2B8127B986CF62455067A5E621738C8A381D2B6A033F6C389BE878
+3179A54AD38D69223AD779A159B2D7D0AD1670A03171EB4C27930E1878037813CBC46214
+7486F3B8E9F7016C9E2E4C60B03A4C976D48EE3A20131AA00F4B79707FD801B3F7A7759A
+3AFF3F6CEE749F2B32B01A582DC408384B8749307794914EAF7A0300E1C9AEF42DFFD828
+C5EE7D9730CE489F0A98C81E166B2B1EED3BCFACC370709947CFD29DEAD86C58FCF6AEA4
+8D670583BCA7018853B781340D7F4D1F2FA5703EDA8F1815F74407B4617016AD9BDF1F49
+340E7D89AF7CB5818B996201512968AA2B3D71C468C69DB46E514EC3CCBA360B3E80972D
+86145148DC0BDD4ADDDFDC7D835DAAC0AA9B96DDD91973288B3A2A28BD6BB415C2A79818
+7F58F3402DA53B0600FA53A01AEEBCE5081BCC0645348BD1772C54A608E88499CE0103EA
+C4ABC7FD74256C4F16A977BDF7F13843BFC6CCF16092740D9C1E7561EFD4EC6A3A30460E
+A434D1921727FA26D9F56627DCD6AF95951E602936C4AC6C7A6F6DFEF2C0CE0571458B27
+BB31DA11C9E09DD3917F61140EFC4F059AC2FAC839BDDC0695B293C42BD17B1895A6B2B2
+F955821C5CE356B1AA33C5F361BB0F43828A20B9F193E71E057F45B6CC8ABE53EEFF801F
+2B6CFB31B6DEB5D84EB8525B938AC424B3486DEA14982E5CF7F2D2C92F2D9B28033DE0C3
+4B610505771E0B1BE6AF03552EB8B44EC1190DAEB15DAAF21E7F2D437780484F0535D8ED
+941A8FA13D379B911FC7AC99E4657DABD37891C467E8854DEAD2E34E05962F0EEC30B5D4
+B8FA6EBA42C102564A2FCDF679AFB7FC145C98EDCC81BF33DCFEB593CF8E7C2F6E9E22B7
+8B1DEE3B75C0E87AB95C6341A1D09948BF338B682F515D89230F8CDBFC72D56A00003EAD
+F5BC0A6CC1A802A80480D6CEBA34631C7892909E049473E8328295069C0845571ECC9980
+CD8BCEB4C930C06601BFBE690FA0BB34631C7FF64D91A31BDF9035EC6E44EA12A79DF384
+FD82092DEAFB2D2E1B0C8ED903BCA55382F98FA5346ACC20900D86E64FF528C604D6815E
+3DEFC5F71EBBBAC2B5787B2F25AE820AFDD4038CD58B0F1710C1EEC7DA521071DCCFB9BF
+24C9EA1049EF59E61D20BFD50BCB5D8CBD0DC266B8836F34EB94858A54CE0C9E6088188A
+EDE0BE39FAFE697AA6C8805CAD63DEE8A0CA226C91405DE5FE7FE8820124D6D79EA5F956
+8C5CBFEA24C4F3D601428329453F226C4C3E3E429E429C2E96DF25EE1DD7B5B12B2C1DA7
+CB0EE6EB0D018C2DD437A6883D2C2E57B9CB264CD3369C20AB831CDDAC5F57E550727C0B
+CC9715B2C87C26C0A9A6A2F173C7B03F12F993B217466E7896E4764C6AF20CDF0634205F
+3E38E6C8C6DE3A4269C5C6CF03E49D60F0E2F3D7B3ED302C3BDA4EC6332867A19C9CE8FD
+6E2D0F2C597E11896A3E6EDC4B616F76B3355DFBF26DB2199963252C93AE423F1AE6683F
+115E9B68672BFF4C9134EED4C51AE587CC859F742A283F3C9B6088B0B9E65A1EA521578A
+E67D7396907129B83C1C9E2302D5FF46FCBF408E0FA69AA8F6E7193AE9E9DD5254201317
+B3D304BDCA689B683568BCAD9539C4D6BDA50814D8F251A70E76E7A5EECF719DD1655DA0
+605D9EFC940A8CF0FDEBC7146DE12F108959280903C34C69DC92F8205F2EE1D52F483AA7
+7E02F277A1186849056036CB24AB238AF08C903C4CEB4851991C24A8158EAE8D8F3BE56C
+355FC26D7BBD2849B7ED9E1A25DFE98BC62A6797615BCE59DEAAFD5B6D08298E2DDAA611
+3DE60AB83FF7687B7ADD6706822270ECA925B559F2F9EC59C9AB0F365868DEC3122EE67F
+BAFE7EBFACEC14D4D40C55F94ABBE8CE82CEA67FC1415D127786071CC06DCB653CCDED0B
+40A9D49994865CF45BA494AC11543A0546DC37417BD01DB100273EE3F0E7D12093E50FD0
+E71B9A0326E8F35FCD86B3285781008ED03FCA1850D685CA5B62518C9194A0C7E8CFD5A9
+FF6A0EF508ADBCEDAB7C7144272F8C7DB274CE7AA09CFABCCA3E6967EF259A72C3B8F4FD
+4605CBB99CE88B679F3EC9486C442B05D776B9D7FA8C04203DBDF33C0CF45B15E68C9376
+168229CC5176BC1E9707853192BD0C394E2D8880050594675F5B83488026791AEB1E6D79
+A424B8F90149F4855EF1BDF6CF0137D459D2A22DA3FF00743B52B2F9C316262EE53AE760
+43E2F267C2598CE66CFEAEF1459C307CA9B3FD8E897C93426545B80834EA16764633B2C5
+5B31557E6B5398F17D0BE5CC1348FE71014EF3BA2F917589AE4A4C9D8EF22A6D0A288557
+C4B2F2ABF2C30E778A5F21AA16BDD04CD8433514FBC7F81583F5D9CE3DE38542DCA55FFC
+9142EB3B797946A7A121C134C82DAED820D3FF0E7053B40134353012A44B15506385533D
+0702662BC8545130B7717B5E99BDC18E8473D2920C80CAD8F61D352C2B3718567B0BDFDF
+F063D2E1A568D6B17412149E4C9AFE3FD3F8186A8274FC01CA07504BE6751A7BDE74719E
+970A9F1744917E3521C4988E547EC1B63D33AD86390DB6CDBA9436884CEAA6064E383B61
+68BD405523A23D32B571E534354E1BD4EA3EDB7D1BBF2D0F6D6B36993DB0DF94C18BEBE2
+6F4B6475306784C091E139A759F627843CED43666D95AE257E650DDA0F6C0458CF27885F
+25D59FE5601777ADCCB42ABC20F960B17A2669B4277AEE51A3D33BB1914FC5985236A6E0
+0C32956A1CAB55DD020DAFA2BAE36638E5F5866AEAB8E3439EFEA9266CB28B9DBA4B1746
+046A71E3BF05F37FF84CEFD66479640C3BB43D915BFA3AF6F3916F2AAAE39DD4317563C2
+26E361EE278E9FE076EE6B4733720C53918CA5CC9C5F4C6C7A36D8E49A591074AEFF0363
+09E5834A3978ACEB9016F116D20B6854BC59484F344D069768C6DFC503EB95C9FEA0521B
+FD6E1C99FCD1268D18C1DD428C66DE9145071190FB17464C8C4FE87D9C0F3DA5FC3E933D
+7375E88DC3BA96858D671A6616F52E70EC6B5795114C3F03F8C78CC388AC01866B347196
+40705C2EA04CC1369A88B3A242FFCB32B48024742A03C94A6E715EF09F06CC999CA1E593
+AB6013B7E25685C4FA93429EE0613E3DA07C94D82B9A739B954BD6EA1E2A9DE55461211B
+4FBCCFF6BD480C845DC4B075B33551C760FE3D8F5EDB1201269AF48C8F8E96AFB5C7F767
+20AD3F9BDB225AF317770F1C2644589EDB5639376E30DB053930511FEE7C9FF81F6B76ED
+57E4C6CF157AF5EE0D8E05F0B9F1276385B3C4EF779593B0120AAE0073880C0DE6F76906
+8B96E92133050EF7BA0A6585AB37880501F42477E0AB8A5D314F7A5A1B760142A42A40F2
+2A12F0F79C747F8C57C688C5937BCCF9B217647EA1D7C16936055814F9260C647045F3C8
+997D40B7BB690B654B9F243D2FC9343C7BAEC4F79AC5CA9C8A43E414B4BC6A6B02828CC2
+1432BBC6E49EAB7DAE35926C6B0BFBC6AC3831834CF54A732E8531AC7D0A3AF62A5FF8F2
+4B59EF71698824E2AC5E4DC2D5C58B9FFA80817C4DA7638CE5B6F0F33164FCCDA6F82933
+AE42A26BA9AA939A7DBD55F35C29BB9D192251E945D9890F48F63D7BB58269031899F7D5
+A52C1747CBEE945D55154AD30301FCC6345DF34A177E9CAB110D7A52B63B131A1F7D7165
+BB5AC4B1842B9A1F3D86F521E4107B40963BB34CC61B10F79D936736DEAC7F25BBDEC228
+E7838F1032154ADF35F333077483AFCDD50410C07707A47F9306BF794A15B5452EEB34FA
+48A8C1BAA627EBB16BEBE9369AE7D100CF8D14E5B70613C8C8A53CA82495E8BAE8990ABE
+0ACC0B2E9CC44191A50417657662385821B1C897C88AB2A0B149090CE11B940AC6DDB64D
+0BF745858A1A56F811F1DE81458F50A704EA30F5F1918D9B5481E6E4681B389C447A65E3
+56A12C8592C8709C09135B06994590DD0B87D2952C871EF0B7365D04928A7B19AB3A10EF
+40B0BA1DAB4D3DC5789EBDB23E98698963FBD74DAAB6C8885A88634E9857CBCB163B1D0E
+32DF259DFEF7217D6744CC6F34E0D96C7BC93CC0A19F4EFBDAB6338CB56B46E538EE92B4
+353AA6663AC42A2EF78E4A228886577678FF36E5ED221A807E009D33A737F89F80461FA5
+5741EEF636D19FAD5870AF6F436DFCEA130C102156F134F77DFE4933628DBE64B477555D
+81CE6131866AA5712347043CF70634F92D5B984445D32A545607B62BA1C12D37FB6B17F3
+84838E274818032AD7A07CDF1F504B3CB5C5C9D8D16342CAB18697A5821B2E219D14F15C
+AAFB33A44E4E6D18C4DC64F79DDCBF2BFF7B3FE05709420DBBC24B8C23822755062B9784
+69AF6B01CDC9C45E55A71BC5BE1EDFDC23C430D61FF776BB4B2AB69BD391758462A9700E
+21B81CE478207D443C5A868946969DA1E63AA939D3563605C83C2AB2C5E7551169F466D7
+41FDCEE57EEE7897C41F0409AB61E86C947C83850C23DE579ED1A7EF7F941522F41337A7
+F2FF06D4D5CC4A9436A2CEB91B1D9218F46BCC3A1A5C57539BD6A56C6755A8ADD89884F1
+2FF46C13248D02EACB04008BCE1CCC3DA9CB7D4EF0AF02A97734C95D8C45CC360AAA467E
+97858E0B66978BB46353E9C0A653E49CC1E63C119FA50441846E5AE38D551BDF3A7CBD2B
+8E51C2C088A617B68E21DD2F44EF5033CD252A75C80F16F6C45EBC84E17FA58F8DA6800B
+8F61B060F54124F1B1F12AE75059159AF036C25DD06F4EEF5D8048079AC6CCB1BD5DA270
+005EC1428BC3F7A6369EC13EC8F99F77892D163FE605B8609940E1B27D784C57B7842BD7
+10C78480BF7EE7CF9BC29064CBCBE8B3B584C453C29851C39438E10BB9CAD4B2776B0899
+EDFF8CC4D35C8DF827743DC5D85681F4A7B9EAB43E133384B072F0D7A86EC6BFD5989503
+A95AA4DFF2FCB6BCEC468DFF75D20F9FD35015D4F98D65160E9EF8E1AE723433114B5458
+7B0A7314D320A942440D3D37F3BE4164C5D796C5D3597222EC88C7A14503EF964643B095
+E2F113FA22EA7999905633109628F97982451A9810D6A1DD84EB108D7A26E04C1C00488D
+322774F47B555B28D24732E6C0D4D701933C9506D379B3E5BC10609B167C1064F34A4327
+A50D0D2FB470994714FB881EE3B88B054633BFF034650C0C4E4AE5720C35C7F3E4CD30E3
+6B26D8CD1813A7703867952488E01B23FDF799AE3AB35E4880E41B4DDBCF8CB4FA68423E
+2D5E122264F8378BB8EA414C83D95A4A6D85995CE64A50B39C8E5F94955CDDBD88804D42
+279515FC1129FD2F50A170B214BED20695CCE59EAE0ACE91FCE6DD217B3A737A9DCAE11E
+A0C746306AA9447F469BE68D8488E392D00583BAF1E63782C73D5201359CE7A768F24489
+0FA50098398CB006F74E9877E9E4373228269506F44931115C0E44654AFD6B48E3E2F6DD
+47E738DE4CDC5344E1C26FAE5B73B9844F5CB2292D675CE88C2078DBDA11C2A9A58F4B10
+42850802766C9387734F22288F12E1F0D211FE150294FDD1744D8001AB95D9D63FD5C916
+B7886A1D6A076D14AD0B6D65E63D49CBC825E85CCFE3E6119DD05D6450980900600A0A07
+4BE3EE6801DAA9670D1BD6F7FE3332BF9B16C9D7DF782547006BF79DD5286A899E1153F1
+077B7AD8CDAC2724E1689A95B958D24566EA5759AF2276E2558AC8A110EA5CAB9C1BE598
+4031BBCA618B7EA15E87379927AF1D58AF01217B45B9CC67F79D96977624A9A01B1AA7A3
+1D0E4B61F6FC96A620867BAB29A7331DE35BC73E29DD89DEC1B5CA163679017FD5D52D6E
+F359C8ACD7D149B509EB1E9EA1EBDDD572720F11A390AC61F898295FCCA27F466787CE24
+3C889A45EB97AE0AD87B5DB995DECB80D8A73592C9E17F02ED6BEFD6CFC5E56275366022
+E3EE687762FDB605B7221C7004DA9E8B594D6CA0B0AA5AD97D0231C228E38D21F2652470
+2524A76555EA690062A1C811C7708F33A432E4B93683D416BC6BFD9A3A9CD114ECEAD652
+98376657CFC1B1826B77B533314A3962ABA6137CF6502713BDA51FFC763CF78C7A0AFC99
+CD496DFE069FACD2669351BED17106952A3E55A13210C5024885CAF002343A31D1E64745
+E973853B94DE520B204922CE2063140C7403D7E038EA2D21D86A72E417DEF576BC60ED61
+B74A8237ABEBD176625ADC0B1475EF4D985D05148D0233041FB5F02920F4F4C769E2DF96
+8463AB7054465464844A2A1F1C427B9369BBF6221B0D557C1F1AFF62F710BA060FAA89D7
+3C6E7F5B09B2D1E192F47743BE288AB84682254C54ECDB6FB52E1013CFD075D0430D321D
+C0A9B30AA8D1BF0676816E3FB7BB53E19B9C782E3B15732AF9A233408CD12FCBB1D3A963
+3910D9E4F84F1D89B0A26AFC1DF439654005CEDFD46A9B5FC815C91E72631D255475710A
+CADB424EC5D2A86681422B36B8A6BE4DCA28EA5A919D9EE1B4F722518925484A59C6A972
+F68A0BC736BEBEF281DFA37F4F51BE2746644CAAC585DE766DCDF6443263C9A403E4E110
+32721D8C79C005B982D7B1A3E19AEAF0C89A2AB06841D677F79C3152E4B130B122BFC8ED
+D6EFFAC69BA8C66C47F3D5321FB8A9C7156CFA2F0F577DF1CA2D8E9C6D854B401FF8DCF3
+BFBA7C98B11B3F128EA81DD1BB7B4FC24943B43772A6E731876CF46608CB88EB143AE9B1
+7D72DE503210705410B26CF1D70D7D4B98A2C4AC6F7AEBCE59BAB09F1C4D4E97EC3A9D91
+15554C98E2FC7DF130D4548875C0ECF16614BFDAC96E9230FAAB82C6EBDAA0EBCCD1ABC9
+F9DB0B987DF58240B927A6AF8BF1CA62C39DA2DFDF36DA884F67553F058CE4718777EDED
+34E30501AC3DD9B8F9008463A33AA8612595E855D009CF9F7C1BDAC1DBD1483BCFF8A7DD
+346DC22F31646C0CF07C753596AFC285F6136BF7E3C83B0FB75D9BDFA9979C0930A245D2
+7899ECA0F64F12C390EA7293E5EFA7A1D0721AAF72B313E6A14FD20B1B5AD9F3BE0F071E
+33E89D4F5CC7111B4C06F18782A5A8F840CF27EE20B8BDC0B16E295D4AC30C2E079F75CB
+23A338BB99D059095BE8E7D2FEE1BC421BEAFC536D2E2C40E05B6EF3CF483A34CE506816
+2CE04C4F2D9F17748F9FAFB67F046A168F4545D80ECF05266556DA6E75B018F790D5B821
+B5F9D115BA8E3A7B273B92E6E111CD257A6B12F4F25956AF908C8CEC671DBB796FA93893
+18D5B8473A04B63E0F751744D8050A1D266A15656A016697A9CA765660B5728E9BAC77CE
+F7EFA339B522C2C52E6C678C550388136C678B2CD1027214D0D086028A29DD4785EEB512
+BD60CF2132746757559BE4C6B802792700B911D098F4A95A758B6E30285F906B6EE7B60D
+991F86B1961FDC2BD5A9FA8F68E488AD57494765D9822A469FCAC1BDCE3F3685B09550D4
+49CE97D9FA83F187923C4DE772464EFE98A9789B93E5691C621E9B79F227041D22CB05A0
+22282BAA61BFC04863CEB7BA282CE68AE91CCDC2717747B3BCD808136F779DADFDBEECFF
+E610CEE002874E4B33EF0ED4602073C56693BA2479D885F53FE4F5C68DF9C6B09D021342
+C117F488BFC7F2A7BADC2E059F0BF05AED5F6B8467CBE018D7AC442BC3526F8566A71B4A
+69E93874F74F3B751B8C6811992D47DC4D080461269C6EB18AE76ECC66479B6A53E1984F
+A17E13F546FD4AC12024A1ACE29C9BDCD47274E480017759381B2081349FF3AC5BAA1902
+2D9EB3DDC8471B0D2D58E3717973F7B7CD8E8AEAA301A676579AD57D112CF6D8F659B8CC
+E055A155AB0F6C6B8A3254ADBD5E6BBAA336327F3AE20C109CA8C46EF35814473457E3F2
+EC80EE99547B84377DF391B0A9B2F60B818A0A3D49D5E36A2D7A05F4F77F964F81CC51D2
+272CD30B52AFB7AEE06129977A0AF98BFF236EADF92CD7508A2F3FE853EE26530922A59B
+639571AA10FA5FC0E1315B7215B76045E18141403E4B0B2A9EB724E69BB40AC1AB479216
+1686D2B0DF545D0FA08CFACB8C8145AA9FB982222EE247B7DF2D5F2B33A9B6AE29CC6166
+3F642883EB6757DB8F1845E1727B7AADAE2FD8E560922467E79EF1803A03C9D51F649DD4
+16C75835F9EEB1FA6FAE978B1B7B7792FB24EDFD9EF55E67CB02D5C23C9628F126BD3A12
+31869DAE5FBBCE60133DEB7D33F1E0ADFD9927A3E9E42B6AB0E5D703BD7271A179985FC3
+D91C2D161B76F70987073647B26542C83A34172663F6793DE8B8D9BCD72CCD48DF5563C0
+FBFA6CC45D99AB78CD6ED8B861948E54DFE9C99E169E35A88D03C1C9A7C84720A3956B00
+0842CF8C515E3A722DDD0B6627926110B335744866564CC638901758FE0EFA98F4E3F4CF
+DF911E5E395EC3D17807D7483008A95BA603AB80FB6A359BA3F0A8ADFE60F9CBADF67441
+1D0BE41B802B3EC9075DC1EB375EDCD27E113B4B1EA3C8ED0B1BBB2A3DB934CDC5CDA9B6
+0F85B33DD71FCA5B25B0AAA6B528229D84E1E7B97CB72C0F20248509A2B6CC53E5B7B694
+24FD8BFAE39C66E86DCEE0B602C9102A0575F15693B3C0A268C1C3F897F57E1CC5A58ADA
+4222A57B2A53B234BA19ADA37208C16B1B757E106D5D8AF0AFFD6BBA6E753805BBC2E9A4
+450A78025400D18B8FDCA54A18440331E48E52E3C4CA80FC171B02293CED081E887215EA
+D34DCF1D6FC2FE86502262006977878E4960326634F1A1EC8D2D96CF51EECDDD6D7CB410
+6D2B37136A13B4D2B67A2DCC74365A27E72B263FCF506B34116BB93BF76DA0C813CE6F63
+639BA86D000BEEED941AC2096A7F1C714615CE20F920BC4427BBB157105FC8FCC3D5FA6C
+9C0D797AB7ECA5DA2B5DF210C4523E406821B704383C63055EB87E8C82E68ABB062487C8
+834EB35BA973902999E27D9A7D143536CB253195A3801FAF741C1588C808A1
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+{restore}if
+%%EndResource
+/RE{
+findfont
+dup maxlength 1 index/FontName known not{1 add}if dict begin
+{
+1 index/FID ne{def}{pop pop}ifelse
+}forall
+/Encoding exch def
+dup/FontName exch def
+currentdict end definefont pop
+}bind def
+%!PS-Adobe-3.0 Resource-Encoding
+%
+% @psencodingfile{
+% author = "Werner Lemberg, Michail Vidiassov",
+% version = "1.0",
+% date = "2006-Feb-03",
+% filename = "groff.enc",
+% license = "public domain",
+% email = "groff@gnu.org",
+% docstring = "Groff default text encoding. Used with MetaPost."
+% }
+
+%%BeginResource: encoding groffEncoding
+/groffEncoding [
+% 0x00 | 0
+ /asciicircum /asciitilde /Scaron /Zcaron
+ /scaron /zcaron /Ydieresis /trademark
+ /quotesingle /Euro /.notdef /.notdef
+ /.notdef /.notdef /.notdef /.notdef
+% 0x10 | 16
+ /.notdef /.notdef /.notdef /.notdef
+ /.notdef /.notdef /.notdef /.notdef
+ /.notdef /.notdef /.notdef /.notdef
+ /.notdef /.notdef /.notdef /.notdef
+% 0x20 | 32
+ /space /exclam /quotedbl /numbersign
+ /dollar /percent /ampersand /quoteright
+ /parenleft /parenright /asterisk /plus
+ /comma /hyphen /period /slash
+% 0x30 | 48
+ /zero /one /two /three
+ /four /five /six /seven
+ /eight /nine /colon /semicolon
+ /less /equal /greater /question
+% 0x40 | 64
+ /at /A /B /C
+ /D /E /F /G
+ /H /I /J /K
+ /L /M /N /O
+% 0x50 | 80
+ /P /Q /R /S
+ /T /U /V /W
+ /X /Y /Z /bracketleft
+ /backslash /bracketright /circumflex /underscore
+% 0x60 | 96
+ /quoteleft /a /b /c
+ /d /e /f /g
+ /h /i /j /k
+ /l /m /n /o
+% 0x70 | 112
+ /p /q /r /s
+ /t /u /v /w
+ /x /y /z /braceleft
+ /bar /braceright /tilde /.notdef
+% 0x80 | 128
+ /quotesinglbase /guillemotleft /guillemotright /bullet
+ /florin /fraction /perthousand /dagger
+ /daggerdbl /endash /emdash /ff
+ /fi /fl /ffi /ffl
+% 0x90 | 144
+ /dotlessi /dotlessj /grave /hungarumlaut
+ /dotaccent /breve /caron /ring
+ /ogonek /quotedblleft /quotedblright /oe
+ /lslash /quotedblbase /OE /Lslash
+% 0xA0 | 160
+ /.notdef /exclamdown /cent /sterling
+ /currency /yen /brokenbar /section
+ /dieresis /copyright /ordfeminine /guilsinglleft
+ /logicalnot /minus /registered /macron
+% 0xB0 | 176
+ /degree /plusminus /twosuperior /threesuperior
+ /acute /mu /paragraph /periodcentered
+ /cedilla /onesuperior /ordmasculine /guilsinglright
+ /onequarter /onehalf /threequarters /questiondown
+% 0xC0 | 192
+ /Agrave /Aacute /Acircumflex /Atilde
+ /Adieresis /Aring /AE /Ccedilla
+ /Egrave /Eacute /Ecircumflex /Edieresis
+ /Igrave /Iacute /Icircumflex /Idieresis
+% 0xD0 | 208
+ /Eth /Ntilde /Ograve /Oacute
+ /Ocircumflex /Otilde /Odieresis /multiply
+ /Oslash /Ugrave /Uacute /Ucircumflex
+ /Udieresis /Yacute /Thorn /germandbls
+% 0xE0 | 224
+ /agrave /aacute /acircumflex /atilde
+ /adieresis /aring /ae /ccedilla
+ /egrave /eacute /ecircumflex /edieresis
+ /igrave /iacute /icircumflex /idieresis
+% 0xF0 | 240
+ /eth /ntilde /ograve /oacute
+ /ocircumflex /otilde /odieresis /divide
+ /oslash /ugrave /uacute /ucircumflex
+ /udieresis /yacute /thorn /ydieresis
+] def
+%%EndResource
+
+% eof
+%%BeginProlog
+ /ptmr8g groffEncoding /Times-Roman RE
+ /ptmr8g /ptmr8g def
+ /zfzdrr /ZapfDingbats-Reverse def
+ /ptmri8g groffEncoding /Times-Italic RE
+ /ptmri8g /ptmri8g def
+ /fsyro /Symbol-Slanted def
+ /zfeu /FreeEuro def
+/fshow {exch findfont exch scalefont setfont show}bind def
+%%EndSetup
+%%Page: 1 1
+newpath -2 -4.125 moveto
+38.60602 -4.125 lineto
+38.60602 8.78003 lineto
+-2 8.78003 lineto
+ closepath fill
+ 1 setgray
+newpath -3 -3.125 moveto
+37.60602 -3.125 lineto
+37.60602 9.78003 lineto
+-3 9.78003 lineto
+ closepath fill
+ 0 setgray
+0 0 moveto
+(\275) ptmr8g 10.00005 fshow
+10 0 moveto
+(A) ptmr8g 8.00009 fshow
+18.276 0 moveto
+(+) zfzdrr 10.00005 fshow
+30.166 0 moveto
+(a) ptmr8g 10.00005 fshow
+ 0 0.5 dtransform truncate idtransform setlinewidth pop [] 0 setdash
+ 1 setlinejoin 10 setmiterlimit
+newpath -3 -3.125 moveto
+37.60602 -3.125 lineto
+37.60602 9.78003 lineto
+-3 9.78003 lineto
+ closepath stroke
+newpath 70.491 2.32751 moveto
+70.491 8.37088 65.59187 13.27 59.54851 13.27 curveto
+53.50514 13.27 48.60602 8.37088 48.60602 2.32751 curveto
+48.60602 -3.71585 53.50514 -8.61497 59.54851 -8.61497 curveto
+65.59187 -8.61497 70.491 -3.71585 70.491 2.32751 curveto closepath fill
+ 1 setgray
+newpath 69.491 3.32751 moveto
+69.491 9.37088 64.59187 14.27 58.54851 14.27 curveto
+52.50514 14.27 47.60602 9.37088 47.60602 3.32751 curveto
+47.60602 -2.71585 52.50514 -7.61497 58.54851 -7.61497 curveto
+64.59187 -7.61497 69.491 -2.71585 69.491 3.32751 curveto closepath fill
+ 0 setgray
+gsave [0.9397 0.34203 -0.34203 0.9397 53.5435 -2.70255 ] concat 0 0 moveto
+(e) ptmri8g 10.00005 fshow grestore
+gsave [0.9397 0.34203 -0.34203 0.9397 56.45497 2.82672 ] concat 0 0 moveto
+(i) ptmri8g 6.99997 fshow grestore
+gsave [0.9397 0.34203 -0.34203 0.9397 58.2902 3.4947 ] concat 0 0 moveto
+(w) fsyro 6.99997 fshow grestore
+gsave [0.9397 0.34203 -0.34203 0.9397 63.22362 5.29033 ] concat 0 0 moveto
+(t) ptmri8g 6.99997 fshow grestore
+newpath 69.491 3.32751 moveto
+69.491 9.37088 64.59187 14.27 58.54851 14.27 curveto
+52.50514 14.27 47.60602 9.37088 47.60602 3.32751 curveto
+47.60602 -2.71585 52.50514 -7.61497 58.54851 -7.61497 curveto
+64.59187 -7.61497 69.491 -2.71585 69.491 3.32751 curveto closepath stroke
+ 1 setlinecap
+newpath 37.60602 3.32751 moveto
+47.60602 3.32751 lineto stroke
+6.09799 12.92004 moveto
+(\244) ptmr8g 10.00005 fshow
+13.59799 12.92004 moveto
+(\243) ptmr8g 10.00005 fshow
+21.09799 12.92004 moveto
+(\004) zfeu 10.00005 fshow
+10.203 -12.00502 moveto
+(\204) ptmr8g 10.00005 fshow
+ [3 3 ] 0 setdash
+newpath -5.25 -15.89502 moveto
+72.491 -15.89502 lineto
+72.491 21.70007 lineto
+-5.25 21.70007 lineto
+ closepath stroke
+showpage
+%%EOF
diff --git a/Master/texmf-dist/doc/metapost/base/source/grdemo.mp b/Master/texmf-dist/doc/metapost/base/source/grdemo.mp
new file mode 100644
index 00000000000..14fb7609259
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/base/source/grdemo.mp
@@ -0,0 +1,37 @@
+verbatimtex
+.EQ
+delim $$
+.EN
+\# etex
+
+prologues := 2;
+
+input boxes
+
+beginfig(1);
+ pair shadowshift;
+ shadowshift = (1, -1) * bp;
+
+ def drawshadowed(text t) =
+ forsuffixes $ = t:
+ fill bpath$ shifted shadowshift;
+ unfill bpath$;
+ drawboxed($);
+ endfor
+ enddef;
+
+ boxit.a(btex \[12] \s8A\s+2 \[lh] a etex);
+ circleit.b(btex $e sup {i omega t}$ etex rotated 20);
+
+ b.w - a.e = (10bp, 0);
+
+ drawshadowed(a, b);
+ draw a.e .. b.w;
+
+ label.top(btex \[Cs] \[Po] \[Eu] etex, a.n);
+ label.llft(btex \[Fn] etex, a.s);
+
+ draw bbox currentpicture dashed evenly;
+endfig;
+
+end
diff --git a/Master/texmf-dist/doc/metapost/base/source/manfig.mp b/Master/texmf-dist/doc/metapost/base/source/manfig.mp
index e024f62ffb5..bd490432c87 100644
--- a/Master/texmf-dist/doc/metapost/base/source/manfig.mp
+++ b/Master/texmf-dist/doc/metapost/base/source/manfig.mp
@@ -1,10 +1,7 @@
-%% This is for the MathTime version that uses PostScript outline fonts
-%% ----------------------------------------------------------------
-%verbatimtex \documentstyle[times]{article}
-% \begin{document}
-%etex
-%defaultfont := "rptmr";
-%% ----------------------------------------------------------------
+% $Id: manfig.mp,v 1.4 2005/03/27 17:29:22 karl Exp $
+% Figures for MetaPost manual, by John Hobby. Public domain.
+
+filenametemplate "%j-%c.mps";
beginfig(0);
draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0);
@@ -264,7 +261,7 @@ endfig;
beginfig(20);
picture p;
-p = "testing" infont "rptmr" scaled 7;
+p = "testing" infont "ptmr8r" scaled 7;
draw p;
draw llcorner p--lrcorner p--urcorner p--ulcorner p--cycle;
dotlabel.lft(btex \tt llcorner etex, llcorner p);
@@ -856,4 +853,4 @@ label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c);
endfig;
-end \ No newline at end of file
+end
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpgraph.bib b/Master/texmf-dist/doc/metapost/base/source/mpgraph.bib
index b95ad5af223..a896103b0d1 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpgraph.bib
+++ b/Master/texmf-dist/doc/metapost/base/source/mpgraph.bib
@@ -1,3 +1,6 @@
+% $Id: mpgraph.bib,v 1.2 2004/09/19 19:10:08 karl Exp $
+% BibTeX entries for MetaPost doc, by John Hobby. Public domain.
+
@string{jcompstatg = {Journal of Computational and Statistical Graphics}}
@incollection{BenKer90,
@@ -16,14 +19,14 @@
title = "The Elements of Graphing Data",
publisher = "Hobart Press",
address = "Summit, New Jersey",
- year = 1985
+ year = "1985, revised 1994"
}
@book{Cleve93,
author = "Cleveland, William S.",
title = "Visualizing Data",
publisher = "Hobart Press",
address = "Summit, New Jersey",
- year= "to appear",
+ year= 1993,
}
@book{Tufte83,
author = "Edward R. Tufte",
@@ -93,4 +96,4 @@
publisher = "Addison Wesley",
address = "Reading, Massachusetts",
year = 1986
-} \ No newline at end of file
+}
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpgraph.mp b/Master/texmf-dist/doc/metapost/base/source/mpgraph.mp
index 1621f3a8605..71548107f48 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpgraph.mp
+++ b/Master/texmf-dist/doc/metapost/base/source/mpgraph.mp
@@ -1,5 +1,12 @@
+% $Id: mpgraph.mp,v 1.2 2004/09/19 19:10:08 karl Exp $
+% Figures for MetaPost doc, by John Hobby. Public domain.
+
input graph
+filenametemplate "%j-%c.mps";
+
+%if false: %% Begin skipping already debugged figures
+%fi input sarith %% End skipping of already debugged figures
beginfig(1);
draw begingraph(3in,2in);
@@ -74,11 +81,12 @@ draw begingraph(3in,2in);
glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
path p;
gdata("timepop.d", $, augment.p($1, newy(Scvnum $2)); );
- gdraw p;
+ gdraw p withpen nullpen;
for y=5,10,20,50,100,150,200,250:
grid.lft(format("%g",y), newy(y)) withcolor .85white;
endfor
autogrid(grid.bot,) withcolor .85white;
+ gdraw p;
frame.llft;
endgraph;
endfig;
@@ -126,4 +134,4 @@ draw format("%3g","6.022e23");
endfig;
-end \ No newline at end of file
+end
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex b/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex
index 104b70bf917..e19b1024ce9 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex
+++ b/Master/texmf-dist/doc/metapost/base/source/mpgraph.tex
@@ -1,9 +1,11 @@
+% $Id: mpgraph.tex,v 1.3 2005/03/22 00:16:53 karl Exp $
+% MetaPost graph doc, by John Hobby. License at end.
\documentclass{article} % article is NOT the original style
\usepackage{makeidx}
\usepackage{fancyvrb}
\usepackage{ctabbing}
\RecustomVerbatimEnvironment{verbatim}{BVerbatim}{baseline=c}
-\usepackage{epsf}
+\usepackage{graphics}
\usepackage[textwidth=6in,textheight=8.75in]{geometry}
\newcommand\descr[1]{{\langle\hbox{\rm#1}\rangle}}
@@ -11,7 +13,7 @@
\newcommand\tdescr[1]{$\langle$\invisgap{\rm#1}\invisgap$\rangle$}
\newcommand\Ignore[1]{} % For fooling delatex so spell will work
-\newfont\psyvii{rpsyr at 7pt}
+\newfont\psyvii{psyr at 7pt}
\newcommand\regmark{$^{\hbox{\psyvii\char'322}}$} % Registered trademark
\newcommand\logofn{\global\font\logofn=logo8 \logofn}
\newcommand\logo{\global\font\logo=logo10 \logo}
@@ -119,7 +121,7 @@ $$
Americans of that age in 1991 \cite{Census92}.)
\begin{figure}[htp]
-$$ \epsfbox{mpgraph.1} $$
+$$ \includegraphics{mpgraph-1.mps} $$
\caption{A graph of the 1991 age distribution in the United States}
\label{fig1}
\end{figure}
@@ -165,11 +167,28 @@ generates only bullets as shown in Figure~\ref{fig2}.
cause the line to reappear superimposed on the plotting symbols.)
\begin{figure}[htp]
-$$ \epsfbox{mpgraph.2} $$
+$$ \includegraphics{mpgraph-2.mps} $$
\caption{The 1991 age distribution plotted with bullets}
\label{fig2}
\end{figure}
+Watch out for the following: the \tdescr{picture expression} is placed
+with the lower-left corner at the path knot, not its center. If you
+want it to be dead-center, you have to correct the placement
+yourself. For the example above, you need something like this instead:
+
+\medskip
+\begin{verbatim}
+def MPbullet =
+ btex \lower\fontdimen22\cmsy \hbox to 0pt{\hss\cmsy\char15\hss} etex
+enddef;
+\end{verbatim}
+
+\medskip\noindent
+followed by:
+$$ \hbox{\verb|gdraw "agepop91.d" plot MPbullet|} $$
+
+
% glabel, gdotlabel, OUT
The {\tt glabel} and {\tt gdotlabel} commands add labels to a graph. The
@@ -211,7 +230,7 @@ large numbers. We shall see later that simple transformations such as this can
be achieved without generating new data files.
\begin{figure}[htp]
-$$ \epsfbox{mpgraph.3} $$
+$$ \includegraphics{mpgraph-3.mps} $$
\caption{An improved version of the 1991 age distribution graph}
\label{fig3}
\end{figure}
@@ -270,7 +289,7 @@ draw begingraph(3in,2in);
endgraph;
\end{verbatim}
\atop
-\epsfbox{mpgraph.4}
+\includegraphics{mpgraph-4.mps}
$$
\caption{The 1991 age distribution graph and the input that creates it.}
\label{fig4}
@@ -306,8 +325,8 @@ Figure~\ref{fig5} graphs execution times for two matrix multiplication algorithm
using
$$ \hbox{\tt setcoords(log,log)} $$
to specify logarithmic spacing on both axes. The data file {\tt matmul.d} gives
-timings for both algorithms:\\
-\hbox to\hsize{\footnotesize\hfil$
+timings for both algorithms:
+$$ \hbox to\hsize{\footnotesize\hfil$
\begin{verbatim}
20 .007861 standard MM: size, seconds
30 .022051
@@ -332,13 +351,14 @@ timings for both algorithms:\\
480 72.60
\end{verbatim}
\hfil$}
+$$
A blank line in a data file ends a data set. Subsequent {\tt gdraw} commands
access additional data sets by just naming the same data file again.
Since each line gives one $x$~coordinate and one $y$~coordinate, commentary
material after the second data field on a line is ignored.
\begin{figure}[htp]
-$$ \mathcenter{\epsfbox{mpgraph.5}}
+$$ \mathcenter{\includegraphics{mpgraph-5.mps}}
\quad
\begin{BVerbatim}[baseline=c]
draw begingraph(2.3in,2in);
@@ -386,7 +406,7 @@ draw begingraph(6.5cm,4.5cm);
endgraph;
\end{verbatim}
\atop
-\mathcenter{\epsfbox{mpgraph.6}}
+\mathcenter{\includegraphics{mpgraph-6.mps}}
$$
\caption{Annual lead emissions and average level at atmospheric monitoring
stations in the United States. The MetaPost input is shown above
@@ -465,16 +485,19 @@ $$ \begin{verbatim}
vardef newy(expr y) = (256/75)*y + mlog y enddef;
draw begingraph(3in,2in);
glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
- gdraw "ttimepop.d";
+ path p;
+ gdata("timepop.d", $, augment.p($1, newy(Scvnum $2)); );
+ gdraw p withpen nullpen;
for y=5,10,20,50,100,150,200,250:
grid.lft(format("%g",y), newy(y)) withcolor .85white;
endfor
autogrid(grid.bot,) withcolor .85white;
+ gdraw p;
frame.llft;
endgraph;
\end{verbatim}
\atop
- \epsfbox{mpgraph.7}
+ \includegraphics{mpgraph-7.mps}
$$
\caption{Population of the United States in millions versus time with the
population re-expressed as $p/75+\ln p$. The MetaPost input shown
@@ -564,7 +587,7 @@ draw begingraph(3in,2in);
endgraph;
\end{verbatim}
\atop
- \epsfbox{mpgraph.8}
+ \includegraphics{mpgraph-8.mps}
$$
\caption{A scatter plot and the commands that generated it}
\label{fig8}
@@ -638,7 +661,7 @@ draw begingraph(3in,2in);
endgraph;
\end{verbatim}
\atop
- \epsfbox{mpgraph.9}
+ \includegraphics{mpgraph-9.mps}
$$
\caption{A graph of U.S. annual energy production
and the commands that generated it}
@@ -726,10 +749,10 @@ $$ \hbox{\tt format($\descr{string expression}$,\,%
does this. You must first {\tt input graph} or {\tt input format} to load the
macro file. The macro takes a format string and a number to typeset and returns
a picture containing the typeset result. Thus
-$$ \hbox{\verb|format("%g",2+2)|}\quad {\rm yields}\quad \epsfbox{mpgraph.10} $$
+$$ \hbox{\verb|format("%g",2+2)|}\quad {\rm yields}\quad \includegraphics{mpgraph-10.mps} $$
and
$$ \hbox{\verb|format("%3g","6.022e23")|}
- \quad {\rm yields}\quad \epsfbox{mpgraph.11}
+ \quad {\rm yields}\quad \includegraphics{mpgraph-11.mps}
$$
A format string consists of
@@ -1061,7 +1084,7 @@ For completeness, we also mention one other new feature of MetaPost
Version 0.60. When \TeX\ material is included in a picture via the
{\tt btex}\ldots{\tt etex} feature, the thickness of horizontal and
vertical rules gets rounded to exactly the right number of pixels; i.e.,
-interpreting MetaPost output according to the PostScript\regmark\ scan
+interpreting MetaPost output according to the PostScript scan
conversion rules~\cite{ad:red} makes the pixel width equal to the ceiling
of the unrounded width. In fact, a similar relationship holds for all line
widths. The generated PostScript sets line widths by first transforming
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpintro.bib b/Master/texmf-dist/doc/metapost/base/source/mpintro.bib
index dc90248f30b..0df815eac66 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpintro.bib
+++ b/Master/texmf-dist/doc/metapost/base/source/mpintro.bib
@@ -1,3 +1,6 @@
+% $Id: mpintro.bib,v 1.2 2004/09/19 19:10:08 karl Exp $
+% BibTeX entries for MetaPost doc, by John Hobby. Public domain.
+
@techreport{CSTR116,
author = "Kernighan, Brian W.",
title = "{PIC}---A Graphics Language for Typesetting",
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpintro.tex b/Master/texmf-dist/doc/metapost/base/source/mpintro.tex
index 99e487c46dd..539a107c0b5 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpintro.tex
+++ b/Master/texmf-dist/doc/metapost/base/source/mpintro.tex
@@ -1,3 +1,5 @@
+% $Id: mpintro.tex,v 1.2 2004/09/19 19:10:08 karl Exp $
+% MetaPost doc, by John Hobby.
\documentstyle{article}
\input epsf
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpman.bib b/Master/texmf-dist/doc/metapost/base/source/mpman.bib
index ef846d5a79b..c9e8838fe60 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpman.bib
+++ b/Master/texmf-dist/doc/metapost/base/source/mpman.bib
@@ -1,3 +1,6 @@
+% $Id: mpman.bib,v 1.2 2004/09/19 19:10:08 karl Exp $
+% BibTeX entries for MetaPost doc, by John Hobby. Public domain.
+
@string{dcg = "Discrete and Computational Geometry"}
@techreport{CSTR116,
@@ -77,4 +80,4 @@
number = 2,
pagest = "123--140",
year = 1986
-} \ No newline at end of file
+}
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpman.ist b/Master/texmf-dist/doc/metapost/base/source/mpman.ist
index c808a5544bf..946af2429cb 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpman.ist
+++ b/Master/texmf-dist/doc/metapost/base/source/mpman.ist
@@ -1,4 +1,5 @@
-% MakeIndex style file mpman.ist
+% $Id: mpman.ist,v 1.2 2004/09/19 19:10:08 karl Exp $
+% MakeIndex style file for MetaPost doc, by John Hobby. Public domain.
% @ is a valid character in some entries
actual '?' % ? instead of @
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpman.tex b/Master/texmf-dist/doc/metapost/base/source/mpman.tex
index 4c75733f3ba..ed965965baf 100644
--- a/Master/texmf-dist/doc/metapost/base/source/mpman.tex
+++ b/Master/texmf-dist/doc/metapost/base/source/mpman.tex
@@ -1,13 +1,17 @@
+% $Id: mpman.tex,v 1.26 2005/04/13 12:57:28 karl Exp $
+% MetaPost manual, by John Hobby. License at end.
\documentclass{article} % article is NOT the original style
+%
\usepackage{makeidx}
\usepackage{fancyvrb}
\usepackage{ctabbing}
\RecustomVerbatimEnvironment
{verbatim}{BVerbatim}{baseline=c}
-\usepackage{epsf}
-\usepackage[textwidth=6in,textheight=8.75in]{geometry}
+\usepackage{graphicx}
+\usepackage[textwidth=6in,textheight=8.65in]{geometry}
\usepackage{tocloft}
-\setlength\cftbeforesecskip{1.5ex plus 0.2ex minus 0.1ex}
+ \setlength\cftbeforesecskip{1.3ex plus 0.3ex minus 0.3ex}
+\usepackage{url}
\makeatletter
\def\logo{\global\font\logo=logo10 at1\@ptsize\p@ \logo}
@@ -16,10 +20,14 @@
{\logo META}\-{\logo FONT}}}
\makeatother
+\def\ttindex#1{{\tt #1}\index{#1?\texttt{#1}}}
+\def\ttt{\texttt} % I get tired of typing this out
+
+\def\ConTeXt{Con\TeX t}
% \def\MF{{META\-FONT}} % Replacement for the above when using times.sty
-\newfont\psyvii{rpsyr at 7pt}
+\newfont\psyvii{psyr at 7pt}
\newcommand\reg{$^{\hbox{\psyvii\char'322}}$} % Registered trademark
\newcommand\descr[1]{{\langle\hbox{#1}\rangle}}
@@ -27,7 +35,7 @@
\newcommand\tdescr[1]{$\langle$\invisgap#1\invisgap$\rangle$}
\newcommand\pl{\dag}
-\newcommand\bx{\ddag}
+\newcommand\bx{$*$}
\newcommand\mathcenter[1]{\vcenter{\hbox{#1}}}
@@ -35,7 +43,7 @@
\renewcommand{\topfraction}{.85}
\renewcommand{\bottomfraction}{.7}
\renewcommand{\textfraction}{.15}
-\renewcommand{\floatpagefraction}{.66}
+\renewcommand{\floatpagefraction}{.5}
\renewcommand{\dbltopfraction}{.66}
\renewcommand{\dblfloatpagefraction}{.66}
\setcounter{topnumber}{9}
@@ -49,20 +57,21 @@
\VerbatimFootnotes
\author{John D. Hobby}
\title{A User's Manual for MetaPost}
-\date{}
+\date{documented version: 0.99}
\maketitle
\begin{abstract}
-The MetaPost system implements a picture-drawing language very much like Knuth's
-\MF\ except that it outputs PostScript commands instead of run-length-encoded
-bitmaps. MetaPost is a powerful language for producing figures for documents
-to be printed on PostScript printers. It provides easy access to all the
-features of PostScript and it includes facilities for integrating text and
-graphics.
+The MetaPost system implements a picture-drawing language very much like
+Knuth's \MF\ except that it outputs PostScript commands instead of
+run-length-encoded bitmaps. MetaPost is a powerful language for
+producing figures for documents to be printed on PostScript printers.
+It provides easy access to all the features of PostScript and it
+includes facilities for integrating text and graphics.
This document serves as an introductory user's manual. It does not require
-knowledge of \MF\ or access to {\it The \MF book}, but both are beneficial.
+knowledge of \MF\ or access to {\sl The \MF book}, but both are beneficial.
An appendix explains the differences between MetaPost and \MF.
+
\end{abstract}
\thispagestyle{empty}
\newpage
@@ -74,40 +83,41 @@ An appendix explains the differences between MetaPost and \MF.
\setcounter{page}{1}
\pagestyle{headings}
\pagenumbering{arabic}
-\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
+\setlength{\parskip}{.75ex plus 0.5ex minus 0.2ex}
\section{Introduction}
\label{intro}
-MetaPost is a programming language much like Knuth's \MF\footnote{\MF\ is a
-trademark of Addison Wesley Publishing company.}\index{metafont?\MF}~\cite{kn:c}
-except that it outputs PostScript programs instead of bitmaps. Borrowed from \MF\
-are the basic tools for creating and manipulating pictures. These include numbers,
-coordinate pairs, cubic splines, affine transformations, text strings, and boolean
-quantities. Additional features facilitate integrating text and graphics and
-accessing special features of PostScript\footnote{PostScript is a
-trademark of Adobe Systems Inc.}\index{PostScript} such as clipping, shading, and
-dashed lines.
-Another feature borrowed from \MF\ is the ability to solve linear equations
-that are given implicitly, thus allowing many programs to be written in a
-largely declarative style. By building complex operations
+MetaPost is a programming language much like Knuth's \MF\footnote{\MF\
+is a trademark of Addison Wesley Publishing
+company.}\index{metafont?\MF}~\cite{kn:c} except that it outputs
+PostScript programs instead of bitmaps. Borrowed from \MF\ are the
+basic tools for creating and manipulating pictures. These include
+numbers, coordinate pairs, cubic splines, affine transformations, text
+strings, and boolean quantities. Additional features facilitate
+integrating text and graphics and accessing special features of
+PostScript\footnote{PostScript is a trademark of Adobe Systems
+Inc.}\index{PostScript} such as clipping, shading, and dashed lines.
+Another feature borrowed from \MF\ is the ability to solve linear
+equations that are given implicitly, thus allowing many programs to be
+written in a largely declarative style. By building complex operations
from simpler ones, MetaPost achieves both power and flexibility.
-MetaPost is particularly
-well-suited to generating figures for technical documents where some aspects of a
-picture may be controlled by mathematical or geometrical constraints that are
-best expressed symbolically. In other words, MetaPost is not meant to take the
-place of a freehand drawing tool or even an interactive graphics editor.
-It is really a programming language for generating graphics, especially figures
-for \TeX\footnote{\TeX\ is a trademark of the American Mathematical
-Society.}\index{TeX?\TeX} and troff\index{troff} documents.
-The figures can be integrated into a \TeX\ document via a freely available
-program called {\tt dvips}\index{dvips} as shown in
-Figure~\ref{fig0}.\footnote{The C
-source for {\tt dvips} comes with the web2c \TeX\ distribution. Similar programs
-are available from other sources.} A similar procedure works with troff: the
-{\tt dpost} output processor includes PostScript figures when they are
-requested via troff's {\tt \char`\\X} command.
+MetaPost is particularly well-suited to generating figures for technical
+documents where some aspects of a picture may be controlled by
+mathematical or geometrical constraints that are best expressed
+symbolically. In other words, MetaPost is not meant to take the place
+of a freehand drawing tool or even an interactive graphics editor. It
+is really a programming language for generating graphics, especially
+figures for \TeX\footnote{\TeX\ is a trademark of the American
+Mathematical Society.}\index{TeX?\TeX} and troff\index{troff} documents.
+The figures can be integrated into a \TeX\ document via a freely
+available program called {\tt dvips}\index{dvips} as shown in
+Figure~\ref{fig0}.\footnote{The C source for {\tt dvips} comes with the
+web2c \TeX\ distribution. Similar programs are available from other
+sources.} A similar procedure works with troff: the {\tt dpost} output
+processor includes PostScript figures when they are requested via
+troff's {\tt \char`\\X} command.
\begin{figure}[htp]
$$ \def\fbox#1{\hbox{\vrule
@@ -148,36 +158,70 @@ $$
\label{fig0}
\end{figure}
-To use MetaPost, you prepare an input file containing MetaPost code and then
-invoke MetaPost, usually by giving a command of the form\index{mp?\texttt{mp}}
-$$ {\tt mp}\, \descr{file name} $$
-(This syntax could be system dependent).
-MetaPost input files\index{files!input} normally have names ending ``{\tt .mp}''
-but this part of the name can be omitted when invoking MetaPost. For an input
-file {\tt foo.mp}
-$$ \hbox{\tt mp foo} $$
-invokes MetaPost and produces output files with names like {\tt foo.1} and
-{\tt foo.2}. Any terminal I/O is summarized in a
-transcript\index{files!transcript}\index{transcript file}
-file called {\tt foo.log}. This includes
-error messages and any MetaPost commands entered interactively.%
-\footnote{A {\tt *}\index{*?\texttt{*}} prompt is used for interactive input and a
-{\tt **}\index{**?\texttt{**}} prompt
-indicates that an input file name is expected. This can be avoided by invoking
-MetaPost on a file that ends with an {\tt end}\index{end?\texttt{end}} command.}
-The transcript file starts with a banner line that tells what version of MetaPost
-you are using.
-
-This document introduces the MetaPost language, beginning with the features that
-are easiest to use and most important for simple applications. The first few
-sections describe the language as it appears to the novice user with key parameters
-at their default values. Some features described in these sections are part of a
-predefined macro package called Plain. Later sections summarize the
-complete language and distinguish between primitives and preloaded macros
-from the Plain macro package\index{Plain macros}.
-Since much of the language is identical to Knuth's \MF, the appendix gives a
-detailed comparison so that advanced users can learn more about MetaPost by
-reading {\sl The \MF book\/}.~\cite{kn:c}
+To use MetaPost, you prepare an input file containing MetaPost code and
+then invoke MetaPost, usually by giving a command of the
+form\index{mpost?\texttt{mpost}}
+$$ {\tt mpost}\, \descr{filename} $$
+The syntax and program name itself are system-dependent; sometimes it is
+named \texttt{mp}. MetaPost input
+files\index{files!input} normally have names ending ``{\tt .mp}'' but
+this part of the name can be omitted when invoking MetaPost. For an
+input file {\tt foo.mp}
+$$ \hbox{\tt mpost foo} $$
+invokes MetaPost and produces output files with names like {\tt foo.1}
+and {\tt foo.2}. Any terminal I/O is summarized in a
+transcript\index{files!transcript}\index{transcript file} file called
+{\tt foo.log}. This includes error messages and any MetaPost commands
+entered interactively.\footnote{A {\tt *}\index{*?\texttt{*}} prompt is
+used for interactive input and a {\tt **}\index{**?\texttt{**}} prompt
+indicates that an input file name is expected. This can be avoided by
+invoking MetaPost on a file that ends with an {\tt
+end}\index{end?\texttt{end}} command.}
+
+\label{Dmpversion}The transcript file starts with a banner line that
+identifies the version of MetaPost you are using. You can also determine
+the current version from within a MetaPost program via the
+\texttt{mpversion} predefined constant string (this was introduced in
+version 0.9). For instance:
+$$\begin{verbatim}
+if known mpversion:
+ message "mp = " \& mpversion;
+ if mpversion > "1.0": message "time has flown by" fi
+fi;
+\end{verbatim}
+$$
+prints `{\tt mp = 0.9}'. (Incidentally, \texttt{>} does a simple ASCII
+comparison of strings; that works here, because of our particular
+version numbering---until and unless MetaPost reaches version 10!)
+\index{Creator comment in PostScript output}
+The version number is also included in the \texttt{Creator} comment in
+the PostScript output.
+
+This document introduces the MetaPost language, beginning with the
+features that are easiest to use and most important for simple
+applications. The first few sections describe the language as it
+appears to the novice user with key parameters at their default values.
+Some features described in these sections are part of a predefined macro
+package called Plain. Later sections summarize the complete language
+and distinguish between primitives and preloaded macros from the Plain
+macro package\index{Plain macros}. Since much of the language is
+identical to Knuth's \MF, the appendix gives a detailed comparison so
+that advanced users can learn more about MetaPost by reading {\sl The
+\MF book\/} \cite{kn:c}.
+
+The MetaPost home page is \url{http://tug.org/metapost}. It has links
+to much additional information, including many articles that have been
+written about MetaPost. For general help, try the
+\url{metapost@tug.org} mailing list; you can subscribe to this list at
+\url{http://tug.org/mailman/listinfo/metapost}.
+
+The development is currently hosted at Sarovar; visit
+\url{http://www.sarovar.org/projects/metapost} for the current
+development team members, sources, and much else.
+
+Please report bugs and request enhancements either on the
+\url{metapost@tug.org} list, or through Sarovar. (Please do not send
+reports directly to Dr.\ Hobby any more.)
\section{Basic Drawing Statements}
@@ -189,41 +233,46 @@ $$ \hbox{\verb|draw (20,20)--(0,0)|} $$
draws\index{draw?\texttt{draw}} a diagonal line and
$$ \hbox{\verb|draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0)|} $$
draws a polygonal line like this:
-$$ \epsfbox{manfig.0} $$
+$$ \includegraphics{manfig-0} $$
-What is meant by coordinates like \verb|(30,0)|? MetaPost uses the same default
-coordinate system that PostScript\index{PostScript} does. This means that
-\verb|(30,0)| is 30 units
-to the right of the origin, where a unit is $1\over72$ of an inch. We shall refer
-to this default unit as a
+\label{Ddrawdot}MetaPost also has a \ttt{drawdot} command to print a
+single point, as in \ttt{drawdot(30,0)}.
+
+What is meant by coordinates like \verb|(30,0)|? MetaPost uses the same
+default coordinate system that PostScript\index{PostScript!coordinate
+system} does. This
+means that \verb|(30,0)| is 30 units to the right of the origin, where a
+unit is $1\over72$ of an inch. We shall refer to this default unit as a
{\sl PostScript point\/}\index{PostScript!point}\index{point!PostScript}
-to distinguish it from the standard printer's point\index{point!printer's}
-which is $1\over72.27$ inches.
-
-MetaPost uses the same names for units of measure that \TeX\ and \MF\ do. Thus
-\verb|bp|\index{bp?\texttt{bp}}\label{Dbp} refers to PostScript points (``big points'')
-and \verb|pt|\index{pt?\texttt{pt}}\label{Dpt} refers to printer's points.
-Other units of measure
-include \verb|in|\index{in?\texttt{in}}\label{Din} for inches,
-\verb|cm|\index{cm?\texttt{cm}}\label{Dcm} for centimeters,
-and \verb|mm|\index{mm?\texttt{mm}}\label{Dmm} for
-millimeters. For example,
+to distinguish it from the standard printer's
+point\index{point!printer's} which is $1\over72.27$ inches.
+
+MetaPost uses the same names for units of measure that \TeX\ and \MF\
+do. Thus \verb|bp|\index{bp?\texttt{bp}}\label{Dbp} refers to
+PostScript points (``big points'') and
+\verb|pt|\index{pt?\texttt{pt}}\label{Dpt} refers to printer's points.
+Other units of measure include
+\verb|in|\index{in?\texttt{in}}\label{Din} for inches,
+\verb|cm|\index{cm?\texttt{cm}}\label{Dcm} for centimeters, and
+\verb|mm|\index{mm?\texttt{mm}}\label{Dmm} for millimeters. For
+example,
$$ \hbox{\verb|(2cm,2cm)--(0,0)--(0,3cm)--(3cm,0)--(0,0)|} $$
-generates a larger version of the above diagram. It is OK to say \verb|0| instead
-\verb|0cm| because {\tt cm} is really just a conversion factor and {\tt 0cm} just
-multiplies the conversion factor by zero. (MetaPost understands constructions
-like {\tt 2cm}\index{multiplication!implicit} as shorthand for \verb|2*cm|).
-
-It is often convenient to introduce your own scale factor, say $u$.
-Then you can define coordinates in terms of $u$ and decide later whether you want
-to begin with \verb|u=1cm| or \verb|u=0.5cm|. This gives you control over what
-gets scaled and what does not so that changing $u$ will not affect features such
-as line widths.
-
-There are many ways to affect the appearance of a line besides just changing its
-width, so the width-control mechanisms allow a lot of generality that we do not need
-yet.
-This leads to the strange looking statement\index{pickup?\texttt{pickup}}\index{pencircle?\texttt{pencircle}}%
+generates a larger version of the above diagram. It is OK to say
+\verb|0| instead \verb|0cm| because {\tt cm} is really just a conversion
+factor and {\tt 0cm} just multiplies the conversion factor by zero.
+(MetaPost understands constructions like {\tt
+2cm}\index{multiplication!implicit} as shorthand for \verb|2*cm|).
+
+It is convenient to introduce your own scale factor, say $u$. Then you
+can define coordinates in terms of $u$ and decide later whether you want
+to begin with \verb|u=1cm| or \verb|u=0.5cm|. This gives you control
+over what gets scaled and what does not so that changing $u$ will not
+affect features such as line widths.
+
+There are many ways to affect the appearance of a line besides just
+changing its width, so the width-control mechanisms allow a lot of
+generality that we do not need yet. This leads to the strange looking
+statement\index{pickup?\texttt{pickup}}\index{pencircle?\texttt{pencircle}}%
\index{scaled?\texttt{scaled}}
$$ \hbox{\verb|pickup pencircle scaled 4pt|} $$
for setting the line width for subsequent \verb|draw| statements to 4 points.
@@ -257,32 +306,32 @@ for i=0 upto 2:
endfor
endfig;
\end{verbatim}
-\quad \mathcenter{\epsfbox{manfig.2}}
+\quad \mathcenter{\includegraphics{manfig-2}}
$$
\caption{MetaPost commands and the resulting output}
\label{fig1}
\end{figure}
Note that the program in Figure~\ref{fig1} starts with
-\verb|beginfig(2)|\index{beginfig?\texttt{beginfig}} and
-ends with \verb|endfig|\index{endfig?\texttt{endfig}}.
-These are macros that perform various administrative
-functions and ensure that the results of all the \verb|draw| statements get
-packaged up and translated into PostScript. A MetaPost input file normally
-contains a sequence of \verb|beginfig|, \verb|endfig| pairs with an
-{\tt end}\index{end?\texttt{end}}
-statement after the last one. If this file is named {\tt fig.mp}, the output
-from \verb|draw| statements between \verb|beginfig(1)| and the next \verb|endfig|
-is written in a file {\tt fig.1}\index{files!output}.
-In other words, the numeric argument to the \verb|beginfig| macro determines the
-name of the corresponding output file.
-
-What does one do with all the PostScript files? They can be included as figures
-in a \TeX\index{TeX?\TeX} or troff\index{troff} document if you have an
-output driver that can handle
-encapsulated PostScript figures. If your standard \TeX\ macro directory contains
-a file {\tt epsf.tex}\index{epsf.tex?\texttt{epsf.tex}}, you can probably include {\tt fig.1}
-in a \TeX\ document as follows:
+\verb|beginfig(2)|\index{beginfig?\texttt{beginfig}} and ends with
+\verb|endfig|\index{endfig?\texttt{endfig}}. These are macros that
+perform various administrative functions and ensure that the results of
+all the \verb|draw| statements get packaged up and translated into
+PostScript. A MetaPost input file normally contains a sequence of
+\verb|beginfig|, \verb|endfig| pairs with an {\tt
+end}\index{end?\texttt{end}} statement after the last one. If this file
+is named {\tt fig.mp}, the output from \verb|draw| statements between
+\verb|beginfig(1)| and the next \verb|endfig| is written in a file {\tt
+fig.1}\index{files!output}. In other words, the numeric argument to the
+\verb|beginfig| macro determines the name of the corresponding output
+file.
+
+What does one do with all the PostScript files? They can be included as
+figures in a \TeX\index{TeX?\TeX} or troff\index{troff} document if you
+have an output driver that can handle encapsulated PostScript figures.
+If your standard \TeX\ macro directory contains a file {\tt
+epsf.tex}\index{epsf.tex?\texttt{epsf.tex}}, you can probably include
+{\tt fig.1} in a \TeX\ document as follows:
$$ \begin{array}{c}
\hbox{\verb|\input epsf |}\\
\vdots\\
@@ -299,6 +348,47 @@ $$ \hbox{\verb|.BP fig.1 3c 3c|} $$
includes {\tt fig.1} and specifies that its height and width are both three
centimeters.
+\subsection{Filename templates}
+
+Metapost has support for output file-name templates. These templates
+use \ttt{printf}-style escape sequences and are re-evaluated before
+each figure is written to disk.
+
+The command to use is \ttt{filenametemplate}, and it accepts a string
+as argument. The syntax is as simple as:
+
+\begin{center}\begin{tabular}{l}
+\verb|filenametemplate "%j-%3c.mps";|\\
+\verb|beginfig(1);|\\
+\verb| draw p;|\\
+\verb|endfig;|
+\end{tabular}\end{center}
+
+If the file is saved as \ttt{fig.mp}, then this will create the output
+file \ttt{fig-001.mps} instead of \ttt{fig.1}. A small set of escape
+sequences are possible, see table~\ref{tab:fntmpl} for details.
+
+\def\d{$\langle$0-9$\rangle$}
+
+\begin{table}
+\begin{center}\begin{tabular}{ll}
+\%\% & A percent sign \\
+\%\,j & The current jobname\\
+\%\d c & The charcode value\\
+\%\d y & The current year\\
+\%\d m & The numeric month\\
+\%\d d & The day of the month\\
+\%\d H & The hour\\
+\%\d M & The minute\\
+\end{tabular}\end{center}
+\caption{Allowed escape sequences for \ttt{filenametemplate}}
+\label{tab:fntmpl}
+\end{table}
+
+To ensure compatibility with older files, the default value of
+\ttt{filenametemplate} is \verb|%j.%c|.
+If you assign an empty string, it will revert to that default.
+
\section{Curves}
\label{curves}
@@ -318,20 +408,20 @@ Figure~\ref{fig2} shows the curve with points \verb|z0| through \verb|z4|
labeled.
\begin{figure}[htp]
-$$ \epsfbox{manfig.3}
+$$ \includegraphics{manfig-3}
$$
\caption[A curve through points 0, 1, 2, 3, and 4]
{The result of {\tt draw z0..z1..z2..z3..z4}}
\label{fig2}
\end{figure}
-There are many other ways to draw a curved path through the same five points.
-To make a smooth closed curve, connect \verb|z4| back to the beginning by
-appending \verb|..cycle|\index{cycle?\texttt{cycle}} to the \verb|draw| statement as shown
-in Figure~\ref{fig3}a. It is also possible in a single \verb|draw| statement
-to mix curves and straight lines as shown in Figure~\ref{fig3}b. Just use
-\verb|--| where you want straight lines and \verb|..| where you want curves.
-Thus
+There are many other ways to draw a curved path through the same five
+points. To make a smooth closed curve, connect \verb|z4| back to the
+beginning by appending \verb|..cycle|\index{cycle?\texttt{cycle}} to the
+\verb|draw| statement as shown in Figure~\ref{fig3}a. It is also
+possible in a single \verb|draw| statement to mix curves and straight
+lines as shown in Figure~\ref{fig3}b. Just use \verb|--| where you want
+straight lines and \verb|..| where you want curves. Thus
$$ \hbox{\verb|draw z0..z1..z2..z3--z4--cycle|} $$
produces a curve through points 0,~1, 2, and~3, then a polygonal line from
point~3 to point~4 and back to point~0. The result is essentially the same
@@ -343,8 +433,8 @@ as having two draw statements
\end{eqnarray*}
\begin{figure}[htp]
-$$ {\epsfbox{manfig.104} \atop (a)}
- \qquad {\epsfbox{manfig.204} \atop (b)}
+$$ {\includegraphics{manfig-104} \atop (a)}
+ \qquad {\includegraphics{manfig-204} \atop (b)}
$$
\caption[Closed curves through five points]
{(a)~The result of {\tt draw z0..\linebreak[0]z1..\linebreak[0]%
@@ -356,10 +446,10 @@ $$
\subsection{B\'ezier Cubic Curves}
-When MetaPost is asked to draw a smooth curve through a sequence of points,
-it constructs a piecewise cubic curve with continuous slope and approximately
-continuous curvature\index{curvature}. This means that a path specification such
-as
+When MetaPost is asked to draw a smooth curve through a sequence of
+points, it constructs a piecewise cubic curve with continuous slope and
+approximately continuous curvature\index{curvature}. This means that a
+path specification such as
$$ \hbox{\verb|z0..z1..z2..z3..z4..z5|} $$
results in a curve that can be defined parametrically\index{parameterization}
as $(X(t),Y(t))$ for
@@ -397,7 +487,7 @@ draw (0,0)..controls (26.8,-1.8) and (51.4,14.6)
$$
\begin{figure}[htp]
-$$ \epsfbox{manfig.5}
+$$ \includegraphics{manfig-5}
$$
\caption[A curve and the control polygon]
{The result of {\tt draw z0..z1..z2..z3..z4} with the
@@ -409,22 +499,23 @@ $$
\subsection{Specifying Direction, Tension, and Curl}
\label{tenscurl}
-MetaPost provides many ways of controlling the behavior of a curved path without
-actually specifying the control points. For instance, some points on the path
-may be selected as vertical or horizontal extrema. If \verb|z1| is to be a
-horizontal extreme and \verb|z2| is to be a vertical extreme, you can specify
-that $(X(t),Y(t))$ should go upward at \verb|z1| and to the left at \verb|z2|:
+MetaPost provides many ways of controlling the behavior of a curved path
+without actually specifying the control points. For instance, some
+points on the path may be selected as vertical or horizontal extrema.
+If \verb|z1| is to be a horizontal extreme and \verb|z2| is to be a
+vertical extreme, you can specify that $(X(t),Y(t))$ should go upward at
+\verb|z1| and to the left at \verb|z2|:
$$ \hbox{\verb|draw z0..z1{up}..z2{left}..z3..z4;|} $$
-The resulting shown in Figure~\ref{fig5} has the desired vertical and horizontal
-directions at \verb|z1| and \verb|z2|, but it does not look as smooth as the
-curve in Figure~\ref{fig2}. The reason is the large discontinuity in
-curvature\index{curvature}
-at \verb|z1|. If it were not for the specified direction at \verb|z1|, the
-MetaPost interpreter would have chosen a direction designed to make the curvature
-above \verb|z1| almost the same as the curvature below that point.
+The resulting shown in Figure~\ref{fig5} has the desired vertical and
+horizontal directions at \verb|z1| and \verb|z2|, but it does not look
+as smooth as the curve in Figure~\ref{fig2}. The reason is the large
+discontinuity in curvature\index{curvature} at \verb|z1|. If it were
+not for the specified direction at \verb|z1|, the MetaPost interpreter
+would have chosen a direction designed to make the curvature above
+\verb|z1| almost the same as the curvature below that point.
\begin{figure}[htp]
-$$ \epsfbox{manfig.6}
+$$ \includegraphics{manfig-6}
$$
\caption[A curve and the control polygon]
{The result of {\tt draw z0..z1\char`\{up\char`\}..z2\char`\{left\char`\}%
@@ -439,7 +530,7 @@ directions there. Figures \ref{fig6} and~\ref{fig7} give a good idea of what
this family of curves is like.
\begin{figure}[htp]
-$$ \mathcenter{\epsfbox{manfig.7}} \quad
+$$ \mathcenter{\includegraphics{manfig-7}} \quad
\begin{verbatim}
beginfig(7)
for a=0 upto 9:
@@ -453,7 +544,7 @@ $$
\end{figure}
\begin{figure}[htp]
-$$ \mathcenter{\epsfbox{manfig.8}} \quad
+$$ \mathcenter{\includegraphics{manfig-8}} \quad
\begin{verbatim}
beginfig(8)
for a=0 upto 7:
@@ -466,15 +557,17 @@ $$
\label{fig7}
\end{figure}
-Figures \ref{fig6} and~\ref{fig7} illustrate a few new MetaPost features.
-The first is the {\tt dir}\index{dir?\texttt{dir}}\label{Ddirop} operator that takes an
-angle in degrees
-and generates a unit vector in that direction. Thus \verb|dir 0| is equivalent
-to {\tt right}\index{right?\texttt{right}}\label{Dright} and \verb|dir 90| is equivalent to
-{\tt up}\index{up?\texttt{up}}\label{Dup}. There are also predefined direction vectors
-{\tt left}\index{left?\texttt{left}}\label{Dleft}
-and {\tt down}\index{down?\texttt{down}}\label{Ddown} for {\tt dir 180}
-and {\tt dir 270}.
+Figures \ref{fig6} and~\ref{fig7} illustrate a few new MetaPost
+features. The first is the {\tt
+dir}\index{dir?\texttt{dir}}\label{Ddirop} operator that takes an angle
+in degrees and generates a unit vector in that direction. Thus
+\verb|dir 0| is equivalent to {\tt
+right}\index{right?\texttt{right}}\label{Dright} and \verb|dir 90| is
+equivalent to {\tt up}\index{up?\texttt{up}}\label{Dup}. There are also
+predefined direction vectors {\tt
+left}\index{left?\texttt{left}}\label{Dleft} and {\tt
+down}\index{down?\texttt{down}}\label{Ddown} for {\tt dir 180} and {\tt
+dir 270}.
The direction
vectors given in \verb|{}| can be of any length, and they can come before a
@@ -485,22 +578,22 @@ $$ \hbox{\verb|..{dir 60}(10,0){up}..|} $$
produces a curve with a corner at $(10,0)$.
Note that some of the curves in Figure~\ref{fig6} have points of
-inflection\index{inflections}.
-This is necessary in order to produce smooth curves in situations like
-Figure~\ref{fig3}a, but it is probably not desirable when dealing with vertical
-and horizontal extreme points as in Figure~\ref{fig8}a. If \verb|z1| is supposed
-to be the topmost point on the curve, this can be achieved by using
-\verb|...|\index{...?\texttt{...}}
-instead of \verb|..| in the path specification as shown in Figure~\ref{fig8}b.
-The meaning of \verb|...| is ``choose an inflection-free path between these
-points unless the endpoint directions make this impossible.'' (It would be
-possible to avoid inflections in Figure~\ref{fig6}, but not in Figure~\ref{fig7}).
+inflection\index{inflections}. This is necessary in order to produce
+smooth curves in situations like Figure~\ref{fig3}a, but it is probably
+not desirable when dealing with vertical and horizontal extreme points
+as in Figure~\ref{fig8}a. If \verb|z1| is supposed to be the topmost
+point on the curve, this can be achieved by using
+\verb|...|\index{...?\texttt{...}} instead of \verb|..| in the path
+specification as shown in Figure~\ref{fig8}b. The meaning of \verb|...|
+is ``choose an inflection-free path between these points unless the
+endpoint directions make this impossible.'' (It would be possible to
+avoid inflections in Figure~\ref{fig6}, but not in Figure~\ref{fig7}).
\begin{figure}[htp]
-$$ {\mathcenter{\epsfbox{manfig.109}} \atop
+$$ {\mathcenter{\includegraphics{manfig-109}} \atop
\hbox{\verb|draw z0{up}..z1{right}..z2{down}|}}
\quad
- {\mathcenter{\epsfbox{manfig.209}} \atop
+ {\mathcenter{\includegraphics{manfig-209}} \atop
\hbox{\verb|draw z0{up}...z1{right}...z2{down}|}}
$$
\caption{Two {\tt draw} statements and the resulting curves.}
@@ -508,12 +601,12 @@ $$
\end{figure}
Another way to control a misbehaving path is to increase the
-``tension''\index{tension} parameter.
-Using \verb|..| in a path specification sets the tension parameter to the default
-value~1. If this makes some part of a path a little too wild, we can selectively
-increase the tension. If Figure~\ref{fig9}a is considered ``too wild,'' a
-{\tt draw} statement of the following form increases the tension between
-{\tt z1} and {\tt z2}:
+``tension''\index{tension} parameter. Using \verb|..| in a path
+specification sets the tension parameter to the default value~1. If
+this makes some part of a path a little too wild, we can selectively
+increase the tension. If Figure~\ref{fig9}a is considered ``too wild,''
+a {\tt draw} statement of the following form increases the tension
+between {\tt z1} and {\tt z2}:
$$ \hbox{\verb|draw z0..z1..tension 1.3..z2..z3|} $$
This produces Figure~\ref{fig9}b. For an asymmetrical effect like
Figure~\ref{fig9}c, the \verb|draw| statement becomes
@@ -521,11 +614,11 @@ $$ \hbox{\verb|draw z0..z1..tension 1.6 and 1..z2..z3|} $$
The tension parameter can be less than one, but it must be at least $3\over4$.
\begin{figure}[htp]
-$$ {\mathcenter{\epsfbox{manfig.110}} \atop (a)}
+$$ {\mathcenter{\includegraphics{manfig-110}} \atop (a)}
\quad
- {\mathcenter{\epsfbox{manfig.210}} \atop (b)}
+ {\mathcenter{\includegraphics{manfig-210}} \atop (b)}
\quad
- {\mathcenter{\epsfbox{manfig.310}} \atop (c)}
+ {\mathcenter{\includegraphics{manfig-310}} \atop (c)}
$$
\caption[Effects of changing the tension parameter]
{Results of {\tt draw z0..z1..tension} $\alpha$ {\tt and} $\beta$
@@ -535,27 +628,27 @@ $$
\label{fig9}
\end{figure}
-MetaPost paths also have a parameter called ``curl''\index{curl?\texttt{curl}} that affects
-the ends of a
-path. In the absence of any direction specifications, the first and last segments
-of a non-cyclic path are approximately circular arcs as in the $c=1$ case of
-Figure~\ref{fig10}. To use a different value for the curl parameter, specify
-\verb|{curl c}| for some other value of $c$. Thus
+MetaPost paths also have a parameter called
+``curl''\index{curl?\texttt{curl}} that affects the ends of a path. In
+the absence of any direction specifications, the first and last segments
+of a non-cyclic path are approximately circular arcs as in the $c=1$
+case of Figure~\ref{fig10}. To use a different value for the curl
+parameter, specify \verb|{curl c}| for some other value of $c$. Thus
$$ \hbox{\verb|draw z0{curl c}..z1..{curl c}z2|} $$
-sets the curl parameter for \verb|z0| and \verb|z2|. Small values of the curl
-parameter reduce the curvature\index{curvature} at the indicated path endpoints,
-while large values
-increase the curvature as shown in Figure~\ref{fig10}. In particular, a curl value
-of zero makes the curvature approach zero.
+sets the curl parameter for \verb|z0| and \verb|z2|. Small values of
+the curl parameter reduce the curvature\index{curvature} at the
+indicated path endpoints, while large values increase the curvature as
+shown in Figure~\ref{fig10}. In particular, a curl value of zero makes
+the curvature approach zero.
\begin{figure}[htp]
-$$ {\mathcenter{\epsfbox{manfig.111}} \atop c=0}
+$$ {\mathcenter{\includegraphics{manfig-111}} \atop c=0}
\qquad
- {\mathcenter{\epsfbox{manfig.211}} \atop c=1}
+ {\mathcenter{\includegraphics{manfig-211}} \atop c=1}
\qquad
- {\mathcenter{\epsfbox{manfig.311}} \atop c=2}
+ {\mathcenter{\includegraphics{manfig-311}} \atop c=2}
\qquad
- {\mathcenter{\epsfbox{manfig.411}} \atop c=\infty}
+ {\mathcenter{\includegraphics{manfig-411}} \atop c=\infty}
$$
\caption[Effects of changing the curl parameter]
{Results of {\tt draw z0\char`\{curl c\char`\}..z1..%
@@ -566,17 +659,18 @@ $$
\subsection{Summary of Path Syntax}
-There are a few other features of MetaPost path syntax, but they are relatively
-unimportant. Since \MF\ uses the same path syntax, interested readers can refer
-to \cite[chapter 14]{kn:c}. The summary of path syntax in Figure~\ref{sypath}
-includes everything discussed so far including the \verb|--| and \verb|...|
-constructions which \cite{kn:c} shows to be macros rather than primitives.
-A few comments on the semantics are in order here: If there is a non-empty
-$\descr{direction specifier}$ before a $\descr{path knot}$ but not after it,
-or vice versa, the specified direction (or curl amount) applies to both the
-incoming and outgoing path segments. A similar arrangement applies when a
-$\descr{controls}$ specification gives only one $\descr{pair primary}$.
-Thus
+There are a few other features of MetaPost path syntax, but they are
+relatively unimportant. Since \MF\ uses the same path syntax,
+interested readers can refer to \cite[chapter 14]{kn:c}. The summary of
+path syntax in Figure~\ref{sypath} includes everything discussed so far
+including the \verb|--| and \verb|...| constructions which \cite{kn:c}
+shows to be macros rather than primitives. A few comments on the
+semantics are in order here: If there is a non-empty $\descr{direction
+specifier}$ before a $\descr{path knot}$ but not after it, or vice
+versa, the specified direction (or curl amount) applies to both the
+incoming and outgoing path segments. A similar arrangement applies when
+a $\descr{controls}$ specification gives only one $\descr{pair
+primary}$. Thus
$$ \hbox{\verb|..controls (30,20)..|} $$
is equivalent to
$$ \hbox{\verb|...controls (30,20) and (30,20)..|} $$
@@ -618,11 +712,12 @@ $\descr{controls} \rightarrow
\label{sypath}
\end{figure}
-A pair of coordinates like \verb|(30,20)| or a \verb|z| variable that represents a
-coordinate pair is what Figure~\ref{sypath} calls a $\descr{pair primary}$.
-A $\descr{path knot}$ is similar except that it can take on other forms such as
-a path expression in parentheses. Primaries and expressions of various types will
-be discussed in full generality in Section~\ref{exprs}.
+A pair of coordinates like \verb|(30,20)| or a \verb|z| variable that
+represents a coordinate pair is what Figure~\ref{sypath} calls a
+$\descr{pair primary}$. A $\descr{path knot}$ is similar except that it
+can take on other forms such as a path expression in parentheses.
+Primaries and expressions of various types will be discussed in full
+generality in Section~\ref{exprs}.
\section{Linear Equations}
@@ -631,11 +726,13 @@ be discussed in full generality in Section~\ref{exprs}.
An important feature taken from \MF\ is the ability to solve linear
equations so that programs can be written in a partially declarative fashion.
For example, the MetaPost interpreter can read
-$$ \hbox{\verb|a+b=3; 2*a=b+3;|} $$
-and deduce that $a=2$ and $b=1$. The same equations can be written slightly more
-compactly by stringing them together with multiple equal signs:
-$$ \hbox{\verb|a+b = 2*a-b = 3;|} $$
-Whichever way you give the equations, you can then give the command\index{show?\texttt{show}}
+$$ \hbox{\verb|a+b=3; 2a=b+3;|} $$
+and deduce that $a=2$ and $b=1$. The same equations can be written
+slightly more compactly by stringing them together with multiple equal
+signs:
+$$ \hbox{\verb|a+b = 2a-b = 3;|} $$
+Whichever way you give the equations, you can then give the
+command\index{show?\texttt{show}}
$$ \hbox{\tt show a,b;} $$
to see the values of {\tt a} and {\tt b}. MetaPost responds by typing
$$\begin{verbatim}
@@ -644,40 +741,42 @@ $$\begin{verbatim}
\end{verbatim}
$$
-Note that {\tt =}\index{=?\texttt{=}} is not an assignment operator; it simply declares
-that the left-hand side equals the right-hand side. Thus {\tt a=a+1} produces an
-error message complaining about an
-``inconsistent equation\index{Inconsistent equation?\texttt{Inconsistent equation}}.'' The way to increase
-the value of {\tt a} is to use the assignment\index{assignment} operator
-{\tt :=}\index{:=?\texttt{:=}} as follows:
+Note that {\tt =}\index{=?\texttt{=}} is not an assignment operator; it
+simply declares that the left-hand side equals the right-hand side.
+Thus {\tt a=a+1} produces an error message complaining about an
+``inconsistent equation\index{Inconsistent equation?\texttt{Inconsistent
+equation}}.'' The way to increase the value of {\tt a} is to use the
+assignment\index{assignment} operator {\tt :=}\index{:=?\texttt{:=}} as
+follows:
$$ \hbox{\tt a:=a+1;} $$
In other words, {\tt :=} is for changing existing values while {\tt =} is for
giving linear equations to solve.
-There is no restriction against mixing equations and assignment operations as in
-the following example:
+There is no restriction against mixing equations and assignment
+operations as in the following example:
$$ \hbox{\tt a = 2; b = a; a := 3; c = a;} $$
-After the first two equations set {\tt a} and~{\tt b} equal to 2, the assignment
-operation changes {\tt a} to~3 without affecting {\tt b}. The final value of
-{\tt c} is 3 since it is equated to the new value of {\tt a}. In general, an
-assignment operation is interpreted by first computing the new value, then
-eliminating the old value from all existing equations before actually assigning
-the new value.
+After the first two equations set {\tt a} and~{\tt b} equal to 2, the
+assignment operation changes {\tt a} to~3 without affecting {\tt b}.
+The final value of {\tt c} is 3 since it is equated to the new value of
+{\tt a}. In general, an assignment operation is interpreted by first
+computing the new value, then eliminating the old value from all
+existing equations before actually assigning the new value.
\subsection{Equations and Coordinate Pairs}
MetaPost can also solve linear equations involving coordinate pairs. We have
already seen many trivial examples of this in the form of equations like
$$ \hbox{\verb|z1=(0,.2in)|} $$
-Each side of the equation must be formed by adding or subtracting coordinate pairs
-and multiplying or dividing them by known numeric quantities. Other ways of
-naming pair-valued variables will be discussed later, but the
-${\tt z}\descr{number}$\index{z convention?{\tt z} convention} is convenient because it is
-an abbreviation for
+Each side of the equation must be formed by adding or subtracting
+coordinate pairs and multiplying or dividing them by known numeric
+quantities. Other ways of naming pair-valued variables will be
+discussed later, but the ${\tt z}\descr{number}$\index{z convention?{\tt
+z} convention} is convenient because it is an abbreviation for
$$ \hbox{\tt (x}\descr{number} \hbox{\tt, y}\descr{number}\hbox{\tt)} $$
-This makes it possible to give values to \verb|z| variables by giving equations
-involving their coordinates. For instance, points {\tt z1}, {\tt z2}, {\tt z3},
-and~{\tt z6} in Figure~\ref{fig12} were initialized via the following equations:
+This makes it possible to give values to \verb|z| variables by giving
+equations involving their coordinates. For instance, points {\tt z1},
+{\tt z2}, {\tt z3}, and~{\tt z6} in Figure~\ref{fig12} were initialized
+via the following equations:
\begin{eqnarray*}
&&\hbox{\verb|z1=-z2=(.2in,0);|} \\
&&\hbox{\verb|x3=-x6=.3in;|} \\
@@ -690,12 +789,12 @@ z3=(.3in,.6in); z6=(-.3in,1.2in);
\end{verbatim}
$$
-After reading the equations, the MetaPost interpreter knows the values of
-{\tt z1}, {\tt z2},
-{\tt z3}, and~{\tt z6}. The next step in the construction of Figure~\ref{fig12}
-is to define points {\tt z4} and {\tt z5} equally spaced along the line from
-{\tt z3} to {\tt z6}. Since this operation comes up often, MetaPost has a special
-syntax for it. This mediation construction\index{mediation}
+After reading the equations, the MetaPost interpreter knows the values
+of {\tt z1}, {\tt z2}, {\tt z3}, and~{\tt z6}. The next step in the
+construction of Figure~\ref{fig12} is to define points {\tt z4} and {\tt
+z5} equally spaced along the line from {\tt z3} to {\tt z6}. Since this
+operation comes up often, MetaPost has a special syntax for it. This
+mediation construction\index{mediation}
$$ \hbox{\verb|z4=1/3[z3,z6]|} $$
means that {\tt z4} is $1\over3$ of the way from $z3$ to $z6$; i.e.,
$$ {\tt z4}={\tt z3}+{1\over3}({\tt z6}-{\tt z3}). $$
@@ -720,7 +819,7 @@ draw z1--z2;
draw z3--z6;
endfig;
\end{verbatim}
-\quad \mathcenter{\epsfbox{manfig.13}}
+\quad \mathcenter{\includegraphics{manfig-13}}
$$
\caption[MetaPost code and figure using linear equations]
{MetaPost commands and the resulting figure. Point labels have been
@@ -728,23 +827,24 @@ $$
\label{fig12}
\end{figure}
-Mediation can also be used to say that some point is at an unknown position along
-the line between two known points. For instance, we could a introduce new
-variable {\tt aa} and write something like
+Mediation can also be used to say that some point is at an unknown
+position along the line between two known points. For instance, we
+could a introduce new variable {\tt aa} and write something like
$$ \hbox{\verb|z20=aa[z1,z3];|} $$
-This says that {\tt z20} is some unknown fraction {\tt aa} of the way along the
-line between {\tt z1} and {\tt z3}. Another such equation involving a different
-line is sufficient to fix the value of {\tt z20}. To say that {\tt z20} is at
-the intersection of the {\tt z1}-{\tt z3} line and the {\tt z2}-{\tt z4} line,
-introduce another variable {\tt ab} and set
+This says that {\tt z20} is some unknown fraction {\tt aa} of the way
+along the line between {\tt z1} and {\tt z3}. Another such equation
+involving a different line is sufficient to fix the value of {\tt z20}.
+To say that {\tt z20} is at the intersection of the {\tt z1}-{\tt z3}
+line and the {\tt z2}-{\tt z4} line, introduce another variable {\tt ab}
+and set
$$ \hbox{\verb|z20=ab[z2,z4];|} $$
This allows MetaPost to solve for {\tt x20}, {\tt y20}, {\tt aa}, and {\tt ab}.
-It is a little painful to keep
-thinking up new names like {\tt aa} and {\tt ab}. This can be avoided by using
-a special feature called {\tt whatever}\index{whatever?\texttt{whatever}}\label{Dwhatev}.
-This macro generates a new anonymous
-variable each time it appears. Thus the statement
+It is a little painful to keep thinking up new names like {\tt aa} and
+{\tt ab}. This can be avoided by using a special feature called {\tt
+whatever}\index{whatever?\texttt{whatever}}\label{Dwhatev}. This macro
+generates a new anonymous variable each time it appears. Thus the
+statement
$$ \hbox{\verb|z20=whatever[z1,z3]=whatever[z2,z4]|} $$
sets {\tt z20} as before, except it uses {\tt whatever} to generate two
{\em different\/} anonymous variables instead of {\tt aa} and {\tt ab}.
@@ -763,19 +863,20 @@ be determined before they are needed. This means that the equations
&& \hbox{\verb|z4=1/3[z3,z6];|}\\
&& \hbox{\verb|z5=2/3[z3,z6];|}
\end{eqnarray*}
-suffice to determine {\tt z1} through {\tt z6}, no matter what order the equations
-are given in. On the other hand
+suffice to determine {\tt z1} through {\tt z6}, no matter what order the
+equations are given in. On the other hand
$$ \hbox{\verb|z20=whatever[z1,z3]|} $$
is legal only when a known value has previously been specified for the difference
${\tt z3}-{\tt z1}$, because the equation is equivalent
to\index{mediation}
$$ \hbox{\verb|z20 = z1 + whatever*(z3-z1)|} $$
-and the linearity requirement disallows multiplying unknown components of
-${\tt z3}-{\tt z1}$ by the anonymous unknown result of {\tt whatever}. The general
-rule is that you cannot multiply two unknown quantities or divide by an unknown
-quantity, nor can an unknown quantity be used in a {\tt draw} statement.
-Since only linear equations are allowed, the MetaPost interpreter can easily solve
-the equations and keep track of what values are known.
+and the linearity requirement disallows multiplying unknown components
+of ${\tt z3}-{\tt z1}$ by the anonymous unknown result of {\tt
+whatever}. The general rule is that you cannot multiply two unknown
+quantities or divide by an unknown quantity, nor can an unknown quantity
+be used in a {\tt draw} statement. Since only linear equations are
+allowed, the MetaPost interpreter can easily solve the equations and
+keep track of what values are known.
The most natural way to ensure that MetaPost can handle an expression like
$$ \hbox{\verb|whatever[z1,z3]|} $$
@@ -784,18 +885,20 @@ actually required since MetaPost may be able to deduce a known value for
${\tt z3}-{\tt z1}$ before either of {\tt z1} and {\tt z3} are known.
For instance, MetaPost will accept the equations
$$ \hbox{\verb|z3=z1+(.1in,.6in); z20=whatever[z1,z3];|} $$
-but it will not be able to determine any of the components of {\tt z1}, {\tt z3},
-or {\tt z20}.
+but it will not be able to determine any of the components of {\tt z1},
+{\tt z3}, or {\tt z20}.
These equations do give partial information about {\tt z1}, {\tt z3},
and {\tt z20}. A good way to see this is to give another equation such as
$$ \hbox{\verb|x20-x1=(y20-y1)/6;|} $$
-This produces the error message
-``{\tt ! Redundant equation}\index{Redundant equation?\texttt{Redundant equation}}.''
-MetaPost assumes that you are trying to tell it something new, so it will usually
-warn you when you give a redundant equation. If the new equation had been
+This produces the error message ``{\tt ! Redundant
+equation}\index{Redundant equation?\texttt{Redundant equation}}.''
+MetaPost assumes that you are trying to tell it something new, so it
+will usually warn you when you give a redundant equation. If the new
+equation had been
$$ \hbox{\verb|(x20-x1)-(y20-y1)/6=1in;|} $$
-the error message would have been\index{Inconsistent equation?\texttt{Inconsistent equation}}
+the error message would have been\index{Inconsistent
+equation?\texttt{Inconsistent equation}}
$$ \hbox{\verb|! Inconsistent equation (off by 71.99979).|} $$
This error message illustrates
roundoff\index{roundoff error} error in MetaPost's linear equation solving
@@ -808,32 +911,34 @@ parallel.
\section{Expressions}
\label{exprs}
-It is now time for a more systematic view of the MetaPost language. We have seen
-that there are numeric quantities and coordinate pairs, and that these can be
-combined to specify paths for {\tt draw} statements.
-We have also seen how variables can be used in linear equations, but we have not
-discussed all the operations and data types that can be used in equations.
+It is now time for a more systematic view of the MetaPost language. We
+have seen that there are numeric quantities and coordinate pairs, and
+that these can be combined to specify paths for {\tt draw} statements.
+We have also seen how variables can be used in linear equations, but we
+have not discussed all the operations and data types that can be used in
+equations.
It is possible to experiment with expressions involving any of the data types
mentioned below by using the statement\index{show?\texttt{show}}\label{Dshow}
$$ {\tt show}\, \descr{expression} $$
-to ask MetaPost to print a symbolic representation of the value of each expression.
-For known numeric values, each is printed on a new line preceded by ``{\tt >>} ''.
-Other types of results are printed similarly, except that complicated values are
-sometimes not printed on standard output. This produces a reference to the
-transcript file\index{files!transcript} that looks like this:
+to ask MetaPost to print a symbolic representation of the value of each
+expression. For known numeric values, each is printed on a new line
+preceded by ``{\tt >>} ''. Other types of result are printed similarly,
+except that complicated values are sometimes not printed on standard
+output. This produces a reference to the transcript
+file\index{files!transcript} that looks like this:
$$ \hbox{\tt >> picture (see the transcript file)} $$
-If you want to the full results of {\tt show} statements to be printed on your
-terminal, assign a positive value to the
-internal\index{internal variables} variable\index{variables!internal}
-{\tt tracingonline}\index{tracingonline?\texttt{tracingonline}}\label{Dtonline}.
+If you want to the full results of {\tt show} statements to be printed
+on your terminal, assign a positive value to the internal\index{internal
+variables} variable\index{variables!internal} {\tt
+tracingonline}\index{tracingonline?\texttt{tracingonline}}\label{Dtonline}.
\subsection{Data Types}
-MetaPost actually has nine basic data types\index{types}: numeric,
-pair, path, transform,
-color, string, boolean, picture, and pen. Let us consider these one at a time
-beginning with the numeric type.
+MetaPost actually has ten basic data types\index{types}: numeric,
+pair, path, transform, (rgb)color, cmykcolor, string, boolean, picture, and
+pen. Let us consider these one at a time beginning with the numeric
+type.
Numeric\index{numeric type} quantities in MetaPost are represented in fixed
point arithmetic\index{arithmetic} as
@@ -845,10 +950,10 @@ of magnitude 4096 or more, setting the internal variable
{\tt warningcheck}\index{warningcheck}\label{Dwarncheck} to zero
suppresses the warning messages about large numeric quantities.
-The pair\index{pair type} type is represented as a pair of numeric quantities.
-We have seen that pairs
-are used to give coordinates in {\tt draw} statements. Pairs can be added,
-subtracted, used in mediation expressions, or multiplied or divided by numerics.
+The pair\index{pair type} type is represented as a pair of numeric
+quantities. We have seen that pairs are used to give coordinates in
+{\tt draw} statements. Pairs can be added, subtracted, used in
+mediation expressions, or multiplied or divided by numerics.
Paths\index{path type} have already been discussed in the context of {\tt draw}
statements, but
@@ -857,9 +962,9 @@ stored and manipulated. A path represents a straight or curved line that is
defined parametrically.
Another data type represents an arbitrary affine
-transformation\index{transform type}. A {\em transform\/} can be any combination
-of rotating, scaling, slanting,
-and shifting. If ${\tt p}=(p_x,p_y)$ is a pair and {\tt T} is a
+transformation\index{transform type}. A {\em transform\/} can be any
+combination of rotating, scaling, slanting, and shifting. If ${\tt
+p}=(p_x,p_y)$ is a pair and {\tt T} is a
transform,\index{transformed?\texttt{transformed}}
$$ \hbox{\tt p transformed T} $$
is a pair of the form
@@ -868,21 +973,28 @@ where the six numeric quantities $(t_x,t_y,t_{xx},t_{xy},t_{yx},t_{yy})$
determine {\tt T}. Transforms can also be applied to paths, pictures, pens,
and transforms.
-The color\index{color type} type is a lot like the pair type, except that it
-has three components
-instead of two. Like pairs, colors can be added, subtracted, used in mediation
-expressions, or multiplied or divided by numerics. Colors can be specified
-in terms of the predefined constants {\tt black}\index{black?\texttt{black}}\label{Dblack},
-{\tt white}\index{white?\texttt{white}}\label{Dwhite}, {\tt red}\index{red?\texttt{red}}\label{Dred},
+The color\index{color type} type is like the pair type, except
+that it has three components instead of two and each component is normally between 0 and 1. Like pairs, colors can be added, subtracted, used in mediation expressions, or multiplied or divided by numerics. Colors can be specified in terms of the predefined constants {\tt black}\index{black?\texttt{black}}\label{Dblack}, {\tt
+white}\index{white?\texttt{white}}\label{Dwhite},
+{\tt red}\index{red?\texttt{red}}\label{Dred},
{\tt green}\index{green?\texttt{green}}\label{Dgreen},
-{\tt blue}\index{blue?\texttt{blue}}\label{Dblue}, or the red, green,
-and blue components can be given explicitly. Black is {\tt (0,0,0)} and white
-is {\tt (1,1,1)}. A level of gray such as {\tt (.4,.4,.4)} can be specified
-as {\tt 0.4white}. There is no restriction against colors ``blacker
-than black'' or ``whiter than white'' except all components are snapped
-back to the $[0,1]$ range when a color is given in a PostScript\index{PostScript}
-output file. MetaPost solves linear equations involving colors the same way it
-does for pairs.
+{\tt blue}\index{blue?\texttt{blue}}\label{Dblue}, or the red, green, and
+blue components can be given explicitly. Black is {\tt (0,0,0)} and
+white is {\tt (1,1,1)}. A level of gray such as {\tt (.4,.4,.4)} can also be
+specified as {\tt 0.4white}. Although color typed variables may be
+any ordered triplet, when adding an object to a picture, MetaPost will
+convert its color by clipping each component between 0 and 1. For
+example, MetaPost will output the color (1,2,3) as (1,1,1).
+MetaPost solves linear equations involving
+colors the same way it does for pairs. The type `rgbcolor' is an alias of
+type `color'.
+
+The cmykcolor\index{cmykcolor type} type is similar to the color
+type except that it has four components instead of three. This type is used to
+specify colors by their cyan, magenta, yellow, and black components explicitly.
+Because cmykcolors deal with pigments instead of light rays, the color
+black would be expressed as {\tt (1,1,1,1)} and white as {\tt (0,0,0,0)}.
+
A string\index{string type} represents a sequence of characters.
String constants\index{string constants} are given
@@ -890,31 +1002,39 @@ in double quotes \hbox{\verb|"like this"|}. String constants cannot contain
double quotes or newlines, but there is a way to construct a string containing
any sequence of eight-bit characters.
-The boolean\index{boolean type} type has the constants
-{\tt true}\index{true?\texttt{true}}\label{Dtrue} and
-{\tt false}\index{false}\label{Dfalse} and the
-operators {\tt and}\index{and?\texttt{and}}\label{Dand}, {\tt or}\index{or?\texttt{or}}\label{Dor},
-{\tt not}\index{not?\texttt{not}}\label{Dnot}. The relations \verb|=| and
-\verb|<>|\index{<>?\texttt{<>}}\label{Dcmpar}
-test objects of any type for equality and inequality\index{inequality}.
+\label{Dscantokens}
+Conversion from strings to other types, notably numeric, can be accomplished by
+the \ttindex{scantokens} primitive:
+\begin{center}\texttt{n := scantokens(}\textit{str}\texttt{);}\end{center}
+More generally, \texttt{scantokens} parses a string into a token
+sequence, as if MetaPost had read it as input.
+
+The boolean\index{boolean type} type has the constants {\tt
+true}\index{true?\texttt{true}}\label{Dtrue} and {\tt
+false}\index{false}\label{Dfalse} and the operators {\tt
+and}\index{and?\texttt{and}}\label{Dand}, {\tt
+or}\index{or?\texttt{or}}\label{Dor}, {\tt
+not}\index{not?\texttt{not}}\label{Dnot}. The relations \verb|=| and
+\verb|<>|\index{<>?\texttt{<>}}\label{Dcmpar} test objects of any type
+for equality and inequality\index{inequality}.
Comparison\index{comparison} relations \verb|<|\index{<?\texttt{<}},
-\verb|<=|\index{<=?\texttt{<=}}, \verb|>|\index{>?\texttt{>}}, and \verb|>=|\index{>=?\texttt{>=}}
-are defined lexicographically for
-strings and in the obvious way for numerics. Ordering relations are also
-defined for booleans, pairs, colors, and transforms, but the comparison rules
-are not worth discussing here.
+\verb|<=|\index{<=?\texttt{<=}}, \verb|>|\index{>?\texttt{>}}, and
+\verb|>=|\index{>=?\texttt{>=}} are defined lexicographically for
+strings and in the obvious way for numerics. Ordering relations are
+also defined for booleans, pairs, colors, and transforms, but the
+comparison rules are not worth discussing here.
The picture\index{picture type} data type is just what the name implies.
-Anything that can be drawn in MetaPost can be stored in a picture variable.
-In fact, the {\tt draw}\index{draw?\texttt{draw}}
-statement actually stores its results in a special picture variable called
-{\tt currentpicture}\index{currentpicture?\texttt{currentpicture}}. Pictures can be added to other
-pictures and operated on by transforms.
-
-Finally, there is a data type called a pen\index{pen type}. The main function
-of pens in
-MetaPost is to determine line thickness, but they can also be used to achieve
-calligraphic effects. The statement\index{pickup?\texttt{pickup}}\label{Dpickup}
+Anything that can be drawn in MetaPost can be stored in a picture
+variable. In fact, the {\tt draw}\index{draw?\texttt{draw}} statement
+actually stores its results in a special picture variable called {\tt
+currentpicture}\index{currentpicture?\texttt{currentpicture}}. Pictures
+can be added to other pictures and operated on by transforms.
+
+Finally, there is a data type called a pen\index{pen type}. The main
+function of pens in MetaPost is to determine line thickness, but they
+can also be used to achieve calligraphic effects. The
+statement\index{pickup?\texttt{pickup}}\label{Dpickup}
$$ {\tt pickup\ }\descr{pen expression} $$
causes the given pen to be used in subsequent {\tt draw} statements.
Normally, the pen expression is of the form
@@ -925,20 +1045,22 @@ an elliptical pen or a polygonal pen.
\subsection{Operators}
-There are many different ways to make expressions of the nine basic types, but
-most of the operations fit into a fairly simple syntax with four levels of
-precedence as shown in Figure~\ref{syexpr}. There are
-primaries\index{primary?\tdescr{primary}}, secondaries\index{secondary?\tdescr{secondary}},
-tertiaries\index{tertiary?\tdescr{tertiary}}, and expressions\index{expression?\tdescr{expression}}
-of each of the basic types, so the syntax rules could
-be specialized to deal with items such as \tdescr{numeric primary},
-\tdescr{boolean tertiary}, etc. This allows the result type for an operation
-to depend on the choice of operator and the types of its operands. For example,
-the {\tt <} relation is a \tdescr{tertiary binary} that can be applied
-to a \tdescr{numeric expression} and a \tdescr{numeric tertiary} to give a
-\tdescr{boolean expression}. The same operator can accept other operand types
-such as \tdescr{string expression} and \tdescr{string tertiary}, but an error
-message results if the operand types do not match.
+There are many different ways to make expressions of the nine basic
+types, but most of the operations fit into a fairly simple syntax with
+four levels of precedence as shown in Figure~\ref{syexpr}. There are
+primaries\index{primary?\tdescr{primary}},
+secondaries\index{secondary?\tdescr{secondary}},
+tertiaries\index{tertiary?\tdescr{tertiary}}, and
+expressions\index{expression?\tdescr{expression}} of each of the basic
+types, so the syntax rules could be specialized to deal with items such
+as \tdescr{numeric primary}, \tdescr{boolean tertiary}, etc. This
+allows the result type for an operation to depend on the choice of
+operator and the types of its operands. For example, the {\tt <}
+relation is a \tdescr{tertiary binary} that can be applied to a
+\tdescr{numeric expression} and a \tdescr{numeric tertiary} to give a
+\tdescr{boolean expression}. The same operator can accept other operand
+types such as \tdescr{string expression} and \tdescr{string tertiary},
+but an error message results if the operand types do not match.
\begin{figure}[htp]
\begin{ctabbing}
@@ -959,72 +1081,74 @@ $\tt \qquad \;|\; \descr{expression} \descr{tertiary binop}
\end{ctabbing}
\caption{The overall syntax rules for expressions}
\index{unary op?\tdescr{unary op}} \index{nullary op?\tdescr{nullary op}}
-\index{primary binop?\tdescr{primary binop}} \index{secondary binop?\tdescr{secondary binop}}
+\index{primary binop?\tdescr{primary binop}}
+\index{secondary binop?\tdescr{secondary binop}}
\index{tertiary binop?\tdescr{tertiary binop}}
\label{syexpr}
\end{figure}
-The multiplication and division operators {\tt *}\label{Dmldiv}
-and~{\tt /} are examples of what
-Figure~\ref{syexpr} calls a \tdescr{primary binop}. Each can accept two numeric
-operands or one numeric operand and one operand of type pair or color.
-The exponentiation operator \verb|**|\index{**?\texttt{**}}\index{exponentiation}\label{Dpow}
-is a \tdescr{primary binop} that requires two numeric operands.
-Placing this at the
-same level of precedence as multiplication
-and division has the unfortunate consequence that \verb|3*a**2| means $(3a)^2$,
-not $3(a^2)$\index{parsing irregularities}. Since unary negation\label{Dneg}
-applies at the primary level, it also turns
-out that \verb|-a**2| means $(-a)^2$. Fortunately, subtraction has lower
-precedence so that \verb|a-b**2| does mean $a-(b^2)$ instead of $(a-b)^2$.
-
-Another \tdescr{primary binop} is the
-{\tt dotprod}\index{dotprod?\texttt{dotprod}}\label{Ddprod} operator that computes the
-vector dot product of two pairs. For example, {\tt z1 dotprod z2} is equivalent
-to {\tt x1*y1 + x2*y2}.
+The multiplication and division operators {\tt *}\label{Dmldiv} and~{\tt
+/} are examples of what Figure~\ref{syexpr} calls a \tdescr{primary
+binop}. Each can accept two numeric operands or one numeric operand and
+one operand of type pair or color. The exponentiation operator
+\verb|**|\index{**?\texttt{**}}\index{exponentiation}\label{Dpow} is a
+\tdescr{primary binop} that requires two numeric operands. Placing this
+at the same level of precedence as multiplication and division has the
+unfortunate consequence that \verb|3*a**2| means $(3a)^2$, not
+$3(a^2)$\index{parsing irregularities}. Since unary
+negation\label{Dneg} applies at the primary level, it also turns out
+that \verb|-a**2| means $(-a)^2$. Fortunately, subtraction has lower
+precedence so that \verb|a-b**2| does mean $a-(b^2)$ instead of
+$(a-b)^2$.
+
+Another \tdescr{primary binop} is the {\tt
+dotprod}\index{dotprod?\texttt{dotprod}}\label{Ddprod} operator that
+computes the vector dot product of two pairs. For example, {\tt z1
+dotprod z2} is equivalent to {\tt x1*y1 + x2*y2}.
The additive operators {\tt +} and {\tt -}\label{Dadd} are
-\tdescr{secondary binops} that
-operate on numerics, pairs, or colors and produce results of the same type.
-Other operators that fall in this category are ``Pythagorean addition''
-\verb|++|\index{++?\texttt{++}}\label{Dpyadd} and
-``Pythagorean subtraction'' \verb|+-+|\index{+-+?\texttt{+-+}}\label{Dpysub}:
-\verb|a++b| means $\sqrt{a^2+b^2}$ and \verb|a+-+b| means $\sqrt{a^2-b^2}$.
-There are too many other operators to list here, but some of the most important
-are the boolean operators {\tt and}\index{and?\texttt{and}} and {\tt or}\index{or?\texttt{or}}.
-The {\tt and} operator is a
-\tdescr{primary binop} and the {\tt or} operator is a \tdescr{secondary binop}.
+\tdescr{secondary binops} that operate on numerics, pairs, or colors and
+produce results of the same type. Other operators that fall in this
+category are ``Pythagorean addition''
+\verb|++|\index{++?\texttt{++}}\label{Dpyadd} and ``Pythagorean
+subtraction'' \verb|+-+|\index{+-+?\texttt{+-+}}\label{Dpysub}:
+\verb|a++b| means $\sqrt{a^2+b^2}$ and \verb|a+-+b| means
+$\sqrt{a^2-b^2}$. There are too many other operators to list here, but
+some of the most important are the boolean operators {\tt
+and}\index{and?\texttt{and}} and {\tt or}\index{or?\texttt{or}}. The
+{\tt and} operator is a \tdescr{primary binop} and the {\tt or} operator
+is a \tdescr{secondary binop}.
The basic operations on strings are concatenation\index{concatenation} and
substring construction.
The \tdescr{tertiary binop} \verb|&|\index{&?\texttt{\&}}\label{Damp}
implements concatenation; e.g.,
$$ \hbox{\verb|"abc" & "de"|} $$
-produces the string \verb|"abcde"|.
-For substring construction, the
-\tdescr{of operator} {\tt substring}\index{substring of?\texttt{substring of}}\label{Dsubstr}
-is used like this:
+produces the string \verb|"abcde"|. For substring construction, the
+\tdescr{of operator} {\tt substring}\index{substring
+of?\texttt{substring of}}\label{Dsubstr} is used like this:
$$ {\tt substring}\, \descr{pair expression} \,{\tt of}\, \descr{string primary} $$
-The \tdescr{pair expression} determines what part of the string to select. For
-this purpose, the string is indexed\index{indexing} so that integer positions
-fall {\em between\/} characters. Pretend the string is written on a piece of
-graph paper
-so that the first character occupies $x$~coordinates between zero and one and the
-next character covers the range $1\le x\le2$, etc. Thus the string \verb|"abcde"|
+The \tdescr{pair expression} determines what part of the string to
+select. For this purpose, the string is indexed\index{indexing} so that
+integer positions fall {\em between\/} characters. Pretend the string
+is written on a piece of graph paper so that the first character
+occupies $x$~coordinates between zero and one and the next character
+covers the range $1\le x\le2$, etc. Thus the string \verb|"abcde"|
should be thought of like this
-$$ \epsfbox{manfig.14} $$
-and {\tt substring (2,4) of "abcde"} is {\tt "cd"}. This takes a little getting
-used to but it tends to avoid annoying ``off by one'' errors.
+$$ \includegraphics{manfig-14} $$
+and {\tt substring (2,4) of "abcde"} is {\tt "cd"}. This takes a little
+getting used to but it tends to avoid annoying ``off by one'' errors.
-Some operators take no arguments at all. An example of what Figure~\ref{syexpr}
-calls a \tdescr{nullary op} is
-{\tt nullpicture}\index{nullpicture?\texttt{nullpicture}}\label{Dnlpic} which
+Some operators take no arguments at all. An example of what
+Figure~\ref{syexpr} calls a \tdescr{nullary op} is {\tt
+nullpicture}\index{nullpicture?\texttt{nullpicture}}\label{Dnlpic} which
returns a completely blank picture.
-The basic syntax in Figure~\ref{syexpr} only covers aspects of the expression
-syntax that are relatively type-independent. For instance, the complicated path
-syntax given in Figure~\ref{sypath} gives alternative rules for constructing a
-\tdescr{path expression}. An additional rule\index{path knot?\tdescr{path knot}}
+The basic syntax in Figure~\ref{syexpr} only covers aspects of the
+expression syntax that are relatively type-independent. For instance,
+the complicated path syntax given in Figure~\ref{sypath} gives
+alternative rules for constructing a \tdescr{path expression}. An
+additional rule\index{path knot?\tdescr{path knot}}
$$ \descr{path knot} \rightarrow \descr{pair tertiary} \;|\; \descr{path tertiary}
$$
explains the meaning of \tdescr{path knot} in Figure~\ref{sypath}. This means
@@ -1042,12 +1166,12 @@ $$ \descr{primary} \rightarrow
\hbox{\tt ,} \descr{expression} \hbox{\tt ]}
$$
where each \tdescr{expression} can be of type numeric, pair, or color.
-The \tdescr{numeric atom}\index{numeric atom?\tdescr{numeric atom}} in a mediation
-expression is an extra simple type of \tdescr{numeric primary} as
-shown in Figure~\ref{synprim}. The meaning of all this is that the initial
-parameter in a mediation expression needs to be parenthesized when it is not
-just a variable, a positive number, or a positive fraction.
-For example,\index{parsing irregularities}
+The \tdescr{numeric atom}\index{numeric atom?\tdescr{numeric atom}} in a
+mediation expression is an extra simple type of \tdescr{numeric primary}
+as shown in Figure~\ref{synprim}. The meaning of all this is that the
+initial parameter in a mediation expression needs to be parenthesized
+when it is not just a variable, a positive number, or a positive
+fraction. For example,\index{parsing irregularities}
$$ \hbox{\tt -1[a,b]} \quad {\rm and}\quad \hbox{\tt (-1)[a,b]} $$
are very different: the former is $-b$ since it is equivalent to
{\tt -(1[a,b])}; the latter is $a-(b-a)$ or $2a-b$.
@@ -1066,88 +1190,99 @@ $\tt \qquad \;|\; \descr{numeric nullary op}$\\
$\tt \descr{number or fraction} \rightarrow \descr{number}
\hbox{\tt /}\descr{number}$\\
$\tt \qquad \;|\; \descr{number not followed by
- `$\hbox{\tt /}\descr{number}$'}$\\
+ `$\hbox{\tt /}\descr{number}$'}$
\end{ctabbing}
\caption{Syntax rules for numeric primaries}
\label{synprim}
\end{figure}
-A noteworthy feature of the syntax rules in Figure~\ref{synprim} is that the
-{\tt /}\index{fractions} operator binds most tightly when its operands are
-numbers. Thus {\tt 2/3} is a
-\tdescr{numeric atom}\index{numeric atom?\tdescr{numeric atom}}\index{parsing irregularities}
-while {\tt (1+1)/3} is only a \tdescr{numeric secondary}. Applying a
-\tdescr{primary binop} such as {\tt sqrt}\index{sqrt?\texttt{sqrt}}\label{Dsqrt}
-makes the difference clear:
+A noteworthy feature of the syntax rules in Figure~\ref{synprim} is that
+the {\tt /}\index{fractions} operator binds most tightly when its
+operands are numbers. Thus {\tt 2/3} is a \tdescr{numeric
+atom}\index{numeric atom?\tdescr{numeric atom}}\index{parsing
+irregularities} while {\tt (1+1)/3} is only a \tdescr{numeric
+secondary}. Applying a \tdescr{primary binop} such as {\tt
+sqrt}\index{sqrt?\texttt{sqrt}}\label{Dsqrt} makes the difference clear:
$$ \hbox{\tt sqrt 2/3} $$
means $\sqrt{2\over3}$ while
$$ \hbox{\tt sqrt(1+1)/3} $$
-means $\sqrt 2/3$.
-Operators such as {\tt sqrt} can be written in standard functional notation,
-but it is often unnecessary to parenthesize the argument. This applies to any
-function that is parsed as a \tdescr{primary binop}. For instance
-{\tt abs(x)}\index{abs?\texttt{abs}}\label{Dabs} and {\tt abs x} both compute the
-absolute value of {\tt x}. The same holds for the
-{\tt round}\index{round?\texttt{round}}\label{Dround},
-{\tt floor}\index{floor?\texttt{floor}}\label{Dfloor},
-{\tt ceiling}\index{ceiling?\texttt{ceiling}}\label{Dceil},
-{\tt sind}\index{sind?\texttt{sind}}\label{Dsind},
-and {\tt cosd}\index{cosd?\texttt{cosd}}\label{Dcosd}
-functions. The last two of these compute trigonometric functions of angles in
-degrees.
-
-Not all unary operators take numeric arguments and return numeric results.
-For instance, the {\tt abs}\index{abs?\texttt{abs}} operator can be applied to a pair
-to compute the Euclidean length of a vector. Applying the
-{\tt unitvector}\index{unitvector?\texttt{unitvector}}\label{Duvec} operator to a pair produces
-the same pair rescaled so that its Euclidean length is~1.
-The {\tt decimal}\index{decimal?\texttt{decimal}}\label{Ddecop}
-operator takes a number and returns the string representation.
-The {\tt angle}\index{angle?\texttt{angle}}\label{Dangle}
-operator takes a pair and computes the two-argument arctangent; i.e., {\tt angle}
-is the inverse of the {\tt dir} operator that was discussed in
-Section~\ref{tenscurl}. There is also an operator
-{\tt cycle}\index{cycle?\texttt{cycle}}\label{Dcycop}
-that takes a \tdescr{path primary} and returns a boolean result indicating whether
+means $\sqrt 2/3$. Operators such as {\tt sqrt} can be written in
+standard functional notation, but it is often unnecessary to
+parenthesize the argument. This applies to any function that is parsed
+as a \tdescr{primary binop}. For instance {\tt
+abs(x)}\index{abs?\texttt{abs}}\label{Dabs} and {\tt abs x} both compute
+the absolute value of {\tt x}. The same holds for the {\tt
+round}\index{round?\texttt{round}}\label{Dround}, {\tt
+floor}\index{floor?\texttt{floor}}\label{Dfloor}, {\tt
+ceiling}\index{ceiling?\texttt{ceiling}}\label{Dceil}, {\tt
+sind}\index{sind?\texttt{sind}}\label{Dsind}, and {\tt
+cosd}\index{cosd?\texttt{cosd}}\label{Dcosd} functions. The last two of
+these compute trigonometric functions of angles in degrees.
+
+Not all unary operators take numeric arguments and return numeric
+results. For instance, the {\tt abs}\index{abs?\texttt{abs}} operator
+can be applied to a pair to compute the Euclidean length of a vector.
+Applying the {\tt
+unitvector}\index{unitvector?\texttt{unitvector}}\label{Duvec} operator
+to a pair produces the same pair rescaled so that its Euclidean length
+is~1. The {\tt decimal}\index{decimal?\texttt{decimal}}\label{Ddecop}
+operator takes a number and returns the string representation. The {\tt
+angle}\index{angle?\texttt{angle}}\label{Dangle} operator takes a pair
+and computes the two-argument arctangent; i.e., {\tt angle} is the
+inverse of the {\tt dir} operator that was discussed in
+Section~\ref{tenscurl}. There is also an operator {\tt
+cycle}\index{cycle?\texttt{cycle}}\label{Dcycop} that takes a
+\tdescr{path primary} and returns a boolean result indicating whether
the path is a closed curve.
-There is a whole class of other operators that classify expressions and return
-boolean results. A type name such as {\tt pair}\index{pair?\texttt{pair}} can operate on
-any type of \tdescr{primary} and return a boolean result indicating whether the
-argument is a {\tt pair}\label{Dpairop}. Similarly, each of the following can
-be used as a unary operator:
-{\tt numeric}\index{numeric?\texttt{numeric}}\label{Dnumop},
-{\tt boolean}\index{boolean?\texttt{boolean}}\label{Dboolop},
-{\tt color}\index{color?\texttt{color}}\label{Dcolrop},
-{\tt string}\index{string?\texttt{string}}\label{Dstrgop},
-{\tt transform}\index{transform?\texttt{transform}}\label{Dtrnfop},
-{\tt path}\index{path?\texttt{path}}\label{Dpathop},
-{\tt pen}\index{pen?\texttt{pen}}\label{Dpenop},
-and {\tt picture}\index{picture?\texttt{picture}}\label{Dpictop}.
-Besides just testing the type of a \tdescr{primary}, you can use the
-{\tt known}\index{known?\texttt{known}}\label{Dknown} and
-{\tt unknown}\index{unknown?\texttt{unknown}}\label{Dunknwn} operators to
+There is a whole class of other operators that classify expressions and
+return boolean results. A type name such as {\tt
+pair}\index{pair?\texttt{pair}} can operate on any type of
+\tdescr{primary} and return a boolean result indicating whether the
+argument is a {\tt pair}\label{Dpairop}. Similarly, each of the
+following can be used as a unary operator:
+{\tt numeric}\index{numeric?\texttt{numeric}}\label{Dnumop},
+{\tt boolean}\index{boolean?\texttt{boolean}}\label{Dboolop},
+{\tt cmykcolor}\index{cmykcolor?\texttt{cmykcolor}}\label{Dccolrop},
+{\tt color}\index{color?\texttt{color}}\label{Dcolrop},
+{\tt string}\index{string?\texttt{string}}\label{Dstrgop},
+{\tt transform}\index{transform?\texttt{transform}}\label{Dtrnfop},
+{\tt path}\index{path?\texttt{path}}\label{Dpathop},
+{\tt pen}\index{pen?\texttt{pen}}\label{Dpenop},
+{\tt picture}\index{picture?\texttt{picture}}\label{Dpictop}, and
+{\tt rgbcolor}\index{rgbcolor?\texttt{rgbcolor}}\label{Drcolrop}.
+Besides just
+testing the type of a \tdescr{primary}, you can use the {\tt
+known}\index{known?\texttt{known}}\label{Dknown} and {\tt
+unknown}\index{unknown?\texttt{unknown}}\label{Dunknwn} operators to
test if it has a completely known value.
-Even a number can behave like an operator in some contexts.
-This refers to the trick that allows {\tt 3x}\index{multiplication, implicit} and
-{\tt 3cm} as alternatives to {\tt 3*x} and {\tt 3*cm}. The rule is that a
-\tdescr{number or fraction} that is not followed by {\tt +}, {\tt -}, or another
-\tdescr{number or fraction} can serve as a \tdescr{primary binop}.
-Thus {\tt 2/3x}\index{parsing irregularities}
-is two thirds of {\tt x} but {\tt (2)/3x} is $2\over3x$ and {\tt 3 3} is illegal.
-
-There are also operators for extracting numeric subfields from pairs, colors,
-and even transforms. If {\tt p} is a \tdescr{pair primary},
-{\tt xpart p}\index{xpart?\texttt{xpart}}\label{Dxprt} and
-{\tt ypart p}\index{ypart}\label{Dyprt} extract its
-components so that
-$$ \hbox{\tt (xpart p, ypart p)} $$
-is equivalent to~{\tt p} even if {\tt p} is an unknown pair that is being used
-in a linear equation. Similarly, a color {\tt c} is equivalent
-to\index{redpart?\texttt{redpart}}\index{greenpart?\texttt{greenpart}}\index{bluepart?\texttt{bluepart}}\label{Drgbprt}
-$$ \hbox{\tt (redpart c, greenpart c, bluepart c)} $$
-The part specifiers for transforms will be discussed later.
+Even a number can behave like an operator in some contexts. This refers
+to the trick that allows {\tt 3x}\index{multiplication, implicit} and
+{\tt 3cm} as alternatives to {\tt 3*x} and {\tt 3*cm}. The rule is that
+a \tdescr{number or fraction} that is not followed by {\tt +}, {\tt -},
+or another \tdescr{number or fraction} can serve as a \tdescr{primary
+binop}. Thus {\tt 2/3x}\index{parsing irregularities} is two thirds of
+{\tt x} but {\tt (2)/3x} is $2\over3x$ and {\tt 3 3} is illegal.
+
+There are also operators for extracting numeric subfields from pairs,
+colors, cmykcolors, and even transforms. If {\tt p} is a \tdescr{pair
+primary}, {\tt xpart p}\index{xpart?\texttt{xpart}}\label{Dxprt} and
+{\tt ypart p}\index{ypart}\label{Dyprt} extract its components so that
+$$ \hbox{\tt (xpart p, ypart p)} $$ is equivalent to~{\tt p} even if
+{\tt p} is an unknown pair that is being used in a linear equation.
+Similarly, a color {\tt c} is equivalent
+to\index{redpart?\texttt{redpart}}%
+\index{greenpart?\texttt{greenpart}}%
+\index{bluepart?\texttt{bluepart}}\label{Drgbprt}
+$$ \hbox{\tt (redpart c, greenpart c, bluepart c)} $$.
+For a cmykcolor {\tt c}, the parts are:\index{cyanpart?\texttt{cyanpart}}%
+\index{magentapart?\texttt{magentapart}}%
+\index{yellowpart?\texttt{yellowpart}}%
+\index{blackpart?\texttt{blackpart}}\label{Dcmykprt}
+$$ \hbox{\tt (cyanpart c, magentapart c, yellowpart c, blackpart c)} $$
+The part
+specifiers for transforms will be discussed later.
\section{Variables}
@@ -1163,14 +1298,15 @@ comments about tokens.
\subsection{Tokens}
-A MetaPost input file is treated as a sequence of numbers, string constants, and
-symbolic tokens\index{tokens}\index{tokens!symbolic}. A number consists of a
-sequence of digits possibly containing
-a decimal point. Technically, the minus sign in front of a negative number is
-a separate token. Since MetaPost uses fixed point arithmetic\index{arithmetic},
-it does not understand exponential notation such as {\tt 6.02E23}. MetaPost
-would interpret this as the number 6.02, followed by the symbolic token {\tt E},
-followed by the number~23.
+A MetaPost input file is treated as a sequence of numbers, string
+constants, and symbolic tokens\index{tokens}\index{tokens!symbolic}. A
+number consists of a sequence of digits possibly containing a decimal
+point. Technically, the minus sign in front of a negative number is a
+separate token. Since MetaPost uses fixed point
+arithmetic\index{arithmetic}, it does not understand exponential
+notation such as {\tt 6.02E23}. MetaPost would interpret this as the
+number 6.02, followed by the symbolic token {\tt E}, followed by the
+number~23.
Anything between a pair of double quotes {\tt "} is a
string constant\index{string constants}. It is
@@ -1202,18 +1338,19 @@ $$
\label{classes}
\end{table}
-Thus \verb|A_alpha| and {\tt +-+} are symbolic tokens but {\tt !=} is interpreted
-as two tokens and {\tt x34} is a symbolic token followed by a number. Since the
-brackets {\tt [} and {\tt ]} are listed on lines by themselves, the only symbolic
-tokens involving them are {\tt [}, {\tt [[}, {\tt [[[}, etc.\ and
-{\tt ]}, {\tt ]]}, etc.
+Thus \verb|A_alpha| and {\tt +-+} are symbolic tokens but {\tt !=} is
+interpreted as two tokens and {\tt x34} is a symbolic token followed by
+a number. Since the brackets {\tt [} and {\tt ]} are listed on lines by
+themselves, the only symbolic tokens involving them are {\tt [}, {\tt
+[[}, {\tt [[[}, etc.\ and {\tt ]}, {\tt ]]}, etc.
-Some characters are not listed in Table~\ref{classes} because they need special
-treatment. The four characters {\tt ,;()} are ``loners'': each comma, semicolon,
-or parenthesis is a separate token even when they occur consecutively. Thus
-{\tt (())} is four tokens, not one or two. The percent sign is very special
-because it introduces comments\index{comments}. The percent sign and everything
-after it up to the end of the line are ignored.
+Some characters are not listed in Table~\ref{classes} because they need
+special treatment. The four characters {\tt ,;()} are ``loners'': each
+comma, semicolon, or parenthesis is a separate token
+even when they occur consecutively. Thus {\tt (())} is four tokens, not
+one or two. The percent sign is very special because it introduces
+comments\index{comments}. The percent sign and everything after it up
+to the end of the line are ignored.
Another special character is the period. Two or more periods
together form a symbolic token, but a single period is ignored, and a period
@@ -1226,23 +1363,24 @@ when naming a variable that is more than one token long.
\label{vardecl}
A variable name is a symbolic token or a sequence of symbolic tokens.
-Most symbolic
-tokens are legitimate variable names, but anything with a predefined meaning like
-{\tt draw}, {\tt +}, or {\tt ..} is disallowed; i.e., variable names cannot be
-macros or MetaPost primitives. This minor restriction allows an amazingly broad
-class of variable names: {\tt alpha}, \verb|==>|, \verb|@&#$&|, and \verb|~~| are
-all legitimate variable names. Such symbolic tokens without special meanings
-are called {\em tags}\index{tags}.
-
-A variable name can be a sequence of tags like {\tt f.bot} or {\tt f.top}.
-The idea is to provide some of the functionality of Pascal records or C structures.
-It is also possible to simulate arrays by using variable names that contain
-numbers as well as symbolic tokens. For example, the variable name {\tt x2r}
-consists of the tag {\tt x}, the number 2, and the tag~{\tt r}. There can also
-be variables named {\tt x3r} and even {\tt x3.14r}. These variables can be
-treated as an array\index{arrays} via constructions like {\tt x[i]r},
-where {\tt i} has an appropriate numeric value. The overall syntax for
-variable names is shown in Figure~\ref{syvar}.
+Most symbolic tokens are legitimate variable names, but anything with a
+predefined meaning like {\tt draw}, {\tt +}, or {\tt ..} is disallowed;
+i.e., variable names cannot be macros or MetaPost primitives. This
+minor restriction allows an amazingly broad class of variable names:
+{\tt alpha}, \verb|==>|, \verb|@&#$&|, and \verb|~~| are all legitimate
+variable names. Such symbolic tokens without special meanings are
+called {\em tags}\index{tags}.
+
+A variable name can be a sequence of tags like {\tt f.bot} or {\tt
+f.top}. The idea is to provide some of the functionality of Pascal
+records or C structures. It is also possible to simulate arrays by
+using variable names that contain numbers as well as symbolic tokens.
+For example, the variable name {\tt x2r} consists of the tag {\tt x},
+the number 2, and the tag~{\tt r}. There can also be variables named
+{\tt x3r} and even {\tt x3.14r}. These variables can be treated as an
+array\index{arrays} via constructions like {\tt x[i]r}, where {\tt i}
+has an appropriate numeric value. The overall syntax for variable names
+is shown in Figure~\ref{syvar}.
\begin{figure}[htp]
\begin{ctabbing}
@@ -1261,29 +1399,30 @@ Variables like {\tt x2} and {\tt y2} take on numeric values by default, so we
can use the fact that {\tt z}\tdescr{suffix} is an abbreviation for\index{z convention?{\tt z} convention}\label{Dzconv}
$$ (x\descr{suffix},\, y\descr{suffix}) $$
to generate pair-valued variables when needed. It turns out that the
-{\tt beginfig}\index{beginfig?\texttt{beginfig}} macro wipes out pre-existing values variables
-that begin with the tags {\tt x} or {\tt y} so that
-{\tt beginfig} \ldots\ {\tt endfig}
-blocks do not interfere with each other when this naming scheme is used.
-In other words, variables that start with {\tt x}, {\tt y}, {\tt z} are
-local\index{variables!local}\index{locality}
-to the figure they are used in. General mechanisms for making variables local
-will be discussed in Section~\ref{grsec}.
+{\tt beginfig}\index{beginfig?\texttt{beginfig}} macro wipes out
+pre-existing values variables that begin with the tags {\tt x} or {\tt
+y} so that {\tt beginfig} \ldots\ {\tt endfig} blocks do not interfere
+with each other when this naming scheme is used. In other words,
+variables that start with {\tt x}, {\tt y}, {\tt z} are
+local\index{variables!local}\index{locality} to the figure they are used
+in. General mechanisms for making variables local will be discussed in
+Section~\ref{grsec}.
Type declarations\index{declarations}\index{type declarations}
make it possible to use almost any naming scheme while still
wiping out any previous value that might cause interference. For example, the
declaration
$$ \hbox{\tt pair pp, a.b;} $$
-makes {\tt pp} and {\tt a.b} unknown pairs. Such a declaration is not strictly
-local since {\tt pp} and {\tt a.b} are not automatically restored to their
-previous values at the end of the current figure. Of course, they are restored
-to unknown pairs if the declaration is repeated.
-
-Declarations work the same way for any of
-the other eight types: numeric, path, transform, color, string, boolean, picture,
-and pen. The only restriction is that you cannot give explicit numeric subscripts
-in a variable declaration. Do not give the illegal declaration
+makes {\tt pp} and {\tt a.b} unknown pairs. Such a declaration is not
+strictly local since {\tt pp} and {\tt a.b} are not automatically
+restored to their previous values at the end of the current figure. Of
+course, they are restored to unknown pairs if the declaration is
+repeated.
+
+Declarations work the same way for any of the other eight types:
+numeric, path, transform, color, string, boolean, picture, and pen. The
+only restriction is that you cannot give explicit numeric subscripts in
+a variable declaration. Do not give the illegal declaration
$$ \hbox{\tt numeric q1, q2, q3;} $$
use the generic subscript\index{subscript!generic} symbol {\tt []}\index{[]?\texttt{[]}}
instead, to declare the whole array:
@@ -1293,56 +1432,60 @@ After the declaration
$$ \hbox{\tt path p[]q[], pq[][];} $$
{\tt p2q3} and {\tt pq1.4 5} are both paths.
-Internal\index{internal variables}\index{variables!internal}
-variables like {\tt tracingonline} cannot be declared in
-the normal fashion. All the internal variables discussed in this manual are
-predefined and do not have to be declared at all, but there is a way to declare
-that a variable should behave like a newly-created internal variable.
-The declaration is {\tt newinternal}\index{newinternal?\texttt{newinternal}}\label{Dnewint}
+Internal\index{internal variables}\index{variables!internal} variables
+like {\tt tracingonline} cannot be declared in the normal fashion. All
+the internal variables discussed in this manual are predefined and do
+not have to be declared at all, but there is a way to declare that a
+variable should behave like a newly-created internal variable. The
+declaration is {\tt
+newinternal}\index{newinternal?\texttt{newinternal}}\label{Dnewint}
followed by a list of symbolic tokens. For example,
$$ \hbox{\tt newinternal a, b, c;} $$
-causes {\tt a}, {\tt b}, and {\tt c} to behave like internal variables. Such
-variables always have known numeric values, and these values can only be changed
-by using the assignment\index{assignment} operator {\tt:=}\index{:=?\texttt{:=}}.
-Internal variables are initially zero
-except that the Plain\index{Plain macros} macro package gives some of them nonzero
-initial values. (The Plain macros are normally preloaded automatically as
-explained in Section~\ref{intro}.)
+causes {\tt a}, {\tt b}, and {\tt c} to behave like internal variables.
+Such variables always have known numeric values, and these values can
+only be changed by using the assignment\index{assignment} operator
+{\tt:=}\index{:=?\texttt{:=}}. Internal variables are initially zero
+except that the Plain\index{Plain macros} macro package gives some of
+them nonzero initial values. (The Plain macros are normally preloaded
+automatically as explained in Section~\ref{intro}.)
\section{Integrating Text and Graphics}
\label{text}
MetaPost has a number of features for including labels and other
-text\index{text and graphics}
-in the figures it generates. The simplest way to do this is to use the
-{\tt label}\index{label?\texttt{label}}\label{Dlabel} statement\index{label suffix?\tdescr{label suffix}}
+text\index{text and graphics} in the figures it generates. The simplest
+way to do this is to use the {\tt
+label}\index{label?\texttt{label}}\label{Dlabel} statement\index{label
+suffix?\tdescr{label suffix}}
$$ {\tt label}\descr{label suffix} \hbox{\tt (}
\descr{string or picture expression} \hbox{\tt,}\, \descr{pair expression}
\hbox{\tt );}
$$
The \tdescr{string or picture expression} gives the label and the
-\tdescr{pair expression} says where to put it. The \tdescr{label suffix} can be
-\tdescr{empty} in which case the label is just centered on the given coordinates.
-If you are labeling some feature of a diagram you probably want to offset the
-label slightly to avoid overlapping. This is illustrated in Figure~\ref{fig16}
-where the {\tt "a"} label is placed above the midpoint of the line it refers to
-and the {\tt "b"} label is to the left of the midpoint of its line. This is
-achieved by using {\tt label.top}\index{top?\texttt{top}} for the {\tt "a"} label and
-{\tt label.lft}\index{lft?\texttt{lft}}
-for the {\tt "b"} label as shown in the figure. The \tdescr{label suffix}
-specifies the position of the label relative to the specified coordinates.
-The complete set of possibilities is\index{rt?\texttt{rt}}\index{bot?\texttt{bot}}%
+\tdescr{pair expression} says where to put it. The \tdescr{label
+suffix} can be \tdescr{empty} in which case the label is just centered
+on the given coordinates. If you are labeling some feature of a diagram
+you probably want to offset the label slightly to avoid overlapping.
+This is illustrated in Figure~\ref{fig16} where the {\tt "a"} label is
+placed above the midpoint of the line it refers to and the {\tt "b"}
+label is to the left of the midpoint of its line. This is achieved by
+using {\tt label.top}\index{top?\texttt{top}} for the {\tt "a"} label
+and {\tt label.lft}\index{lft?\texttt{lft}} for the {\tt "b"} label as
+shown in the figure. The \tdescr{label suffix} specifies the position
+of the label relative to the specified coordinates. The complete set of
+possibilities is\index{rt?\texttt{rt}}\index{bot?\texttt{bot}}%
\index{ulft?\texttt{ulft}}\index{urt?\texttt{urt}}\index{llft?\texttt{llft}}\index{lrt?\texttt{lrt}}
$$ \tt \descr{label suffix} \rightarrow
\descr{empty} \;|\; lft \;|\; rt \;|\; top \;|\; bot \;|\;
ulft \;|\;urt \;|\; llft \;|\; lrt
$$
-where {\tt lft} and {\tt rt} mean left and right and {\tt llft}, {\tt ulft}, etc.\
-mean lower left, upper left, etc. The actual amount by which the label is offset
-in whatever direction is determined by the
+where {\tt lft} and {\tt rt} mean left and right and {\tt llft}, {\tt
+ulft}, etc.\ mean lower left, upper left, etc. The actual amount by
+which the label is offset in whatever direction is determined by the
internal variable\index{internal variables}\index{variables!internal}
-{\tt labeloffset}\index{labeloffset?\texttt{labeloffset}}\label{Dlaboff}.
+{\tt
+labeloffset}\index{labeloffset?\texttt{labeloffset}}\label{Dlaboff}.
\begin{figure}[htp]
$$
@@ -1359,7 +1502,7 @@ label.lft("b", .5[z0,z2]);
dotlabel.bot("(0,0)", z0);
endfig;
\end{verbatim}
-\qquad \mathcenter{\epsfbox{manfig.17}}
+\qquad \mathcenter{\includegraphics{manfig-17}}
$$
\caption{MetaPost code and the resulting output}
\label{fig16}
@@ -1367,11 +1510,12 @@ $$
Figure~\ref{fig16} also illustrates the
{\tt dotlabel}\index{dotlabel?\texttt{dotlabel}}\label{Ddotlab}
-statement. This is exactly
-like the {\tt label} statement except that it adds a dot at the indicated
-coordinates. For example
+statement. This is effectively
+like a {\tt label} statement followed by a statement drawing a dot at
+the indicated coordinates. For example
$$ \hbox{\tt dotlabel.bot("(0,0)", z0)} $$
places a dot at {\tt z0} and then puts the label ``(0,0)'' just below the dot.
+
Another alternative is the macro
{\tt thelabel}\index{thelabel?\texttt{thelabel}}\label{Dthelab}. This has
the same syntax as the {\tt label} and {\tt dotlabel} statements except that it
@@ -1381,12 +1525,12 @@ $$ \hbox{\tt label.bot("(0,0)", z0)} $$
is equivalent to
$$ \hbox{\tt draw thelabel.bot("(0,0)", z0)} $$
-For simple applications of labeled figures, you can normally get by with just
-{\tt label} and {\tt dotlabel}. In fact, you may be able to use a short form of
-the {\tt dotlabel} statement that saves a lot of typing
-when you have many points {\tt z0}, {\tt z1}, {\tt z.a}, {\tt z.b}, etc.\
-and you want to use the {\tt z} suffixes as labels.
-The statement\index{dotlabels?\texttt{dotlabels}}\label{Ddotlbs}
+For simple applications of labeled figures, you can normally get by with
+just {\tt label} and {\tt dotlabel}. In fact, you may be able to use a
+short form of the {\tt dotlabel} statement that saves a lot of typing
+when you have many points {\tt z0}, {\tt z1}, {\tt z.a}, {\tt z.b},
+etc.\ and you want to use the {\tt z} suffixes as labels. The
+statement\index{dotlabels?\texttt{dotlabels}}\label{Ddotlbs}
$$ \hbox{\tt dotlabels.rt(0, 1, a);} $$
is equivalent to
$$ \hbox{\tt dotlabel.rt("0",z0); dotlabel.rt("1",z1); dotlabel.rt("a",z.a);} $$
@@ -1394,48 +1538,61 @@ Thus the argument to {\tt dotlabels} is a list of suffixes for which {\tt z}
variables are known, and the \tdescr{label suffix} given with {\tt dotlabels}
is used to position all the labels.
-There is also a {\tt labels}\index{labels?\texttt{labels}}\label{Dlabels} statement that is
-analogous to
-{\tt dotlabels} but its use is discouraged because it presents compatibility
-problems with \MF\index{metafont?\MF}. Some versions of the preloaded
-Plain\index{Plain macros} macro package define {\tt labels} to be synonymous
-with {\tt dotlabels}.
-
-For labeling statements such as {\tt label} and {\tt dotlabel} that use a
-string expression for the label text,
-the string gets typeset in a default font as determined by
-the string variable {\tt defaultfont}\index{defaultfont?\texttt{defaultfont}}\label{Ddffont}.
-The initial value of {\tt defaultfont}
-is likely to be {\tt "cmr10"}, but it can be changed to a different font name
-by giving an assignment such as
-$$ \hbox{\tt defaultfont:="Times-Roman"} $$
+There is also a {\tt
+labels}\index{labels?\texttt{labels}}\label{Dlabels} statement that is
+analogous to {\tt dotlabels} but its use is discouraged because it
+presents compatibility problems with \MF\index{metafont?\MF}. Some
+versions of the preloaded Plain\index{Plain macros} macro package define
+{\tt labels} to be synonymous with {\tt dotlabels}.
+
+For labeling statements such as {\tt label} and {\tt dotlabel} that use
+a string expression for the label text, the string gets typeset in a
+default font as determined by the string variable {\tt
+defaultfont}\index{defaultfont?\texttt{defaultfont}}\label{Ddffont}.
+The initial value of {\tt defaultfont} is likely to be {\tt "cmr10"},
+but it can be changed to a different font name by giving an assignment
+such as
+$$ \hbox{\tt defaultfont:="ptmr8r"} $$
+\ttt{ptmr8r} is a typical way to refer to the Times-Roman font in \TeX.
+The discussion of font names on p.\ \pageref{fontname} explains further.
+
There is also a numeric quantity called
{\tt defaultscale}\index{defaultscale?\texttt{defaultscale}}\label{Ddfscale}
that determines the type size.
When {\tt default\-scale} is 1, you get the ``normal size'' which is
usually 10 point, but this can also be changed. For instance
$$ \hbox{\tt defaultscale := 1.2} $$
-makes labels come out twenty percent larger. If you do not know the normal size
-and you want to be sure the text comes out at some specific size, say 12 points,
-you can use the {\tt fontsize}\index{fontsize?\texttt{fontsize}}\label{Dfntsiz}
-operator to determine the normal size: e.g.,
+makes labels come out twenty percent larger. If you do not know the
+normal size and you want to be sure the text comes out at some specific
+size, say 12 points, you can use the {\tt
+fontsize}\index{fontsize?\texttt{fontsize}}\label{Dfntsiz} operator to
+determine the normal size: e.g.,
$$ \hbox{\tt defaultscale := 12pt/fontsize defaultfont;} $$
-When you change {\tt defaultfont}, the new font name should be something that
-\TeX\ would understand since MetaPost gets height and width information by reading
-the {\tt tfm}\index{tfm file?{\tt tfm} file}\index{files!tfm?{\tt tfm}} file.
-(This is explained in {\it The \TeX book\/}.~\cite{kn:a})
-It should be possible to use built-in PostScript fonts, but the names for them
-are system-dependent. Some systems may use {\tt rptmr} or {\tt ps-times-roman}
-instead of {\tt Times-Roman}.
-A \TeX\index{TeX?\TeX} font such as {\tt cmr10} is a little dangerous because it does
-not have a space character or certain ASCII symbols. In addition, MetaPost does
-not use the ligatures\index{ligatures} and kerning\index{kerning} information
-that comes with a \TeX\ font.
+\label{fontname}
+When you change {\tt defaultfont}, the new font name should be something
+that \TeX\ would understand since MetaPost gets height and width
+information by reading a {\tt tfm}\index{tfm file?{\tt tfm}
+file}\index{files!tfm?{\tt tfm}} file. (This is explained in {\sl The
+\TeX book\/} \cite{kn:a}.) It should be possible to use built-in
+PostScript fonts, but the names for them are system-dependent. Some
+typical ones are {\tt ptmr8r} for Times-Roman, \ttt{pplr8r} for
+Palatino, and \ttt{phvr} for Helvetica. The Fontname document,
+available at \url{http://tug.org/fontname}, has much more information
+about font names and TeX. A \TeX\index{TeX fonts?\TeX\ fonts} font such
+as {\tt cmr10} is a little dangerous because it does not have a space
+character or certain ASCII symbols.
+
+MetaPost does not use the ligatures\index{ligatures} and
+kerning\index{kerning} information that comes with a \TeX\ font.
+Further, MetaPost does not interpret virtual fonts.
\subsection{Typesetting Your Labels}
+\label{Dbtex}
+\index{labels, typesetting}
+
\TeX\index{TeX?\TeX} may be used to format complex labels.
If you say\index{btex?\texttt{btex}}\index{etex?\texttt{etex}}
$$ {\tt btex}\, \descr{typesetting commands}\, {\tt etex} $$
@@ -1463,9 +1620,9 @@ label.bot(btex $x$ etex, (2u,0));
label.lft(btex $y$ etex, (0,u));
endfig;
\end{verbatim}
-\qquad \mathcenter{\epsfbox{manfig.18}}
+\qquad \mathcenter{\includegraphics{manfig-18}}
$$
-\caption{MetaPost code and the resulting output}
+\caption{Arbitrary \TeX\ as labels}
\label{fig17}
\end{figure}
@@ -1499,9 +1656,9 @@ label.lft(
(120ux, 4uy));
endfig;
\end{verbatim}
-\qquad \mathcenter{\epsfbox{manfig.19}}
+\qquad \mathcenter{\includegraphics{manfig-19}}
$$
-\caption{MetaPost code and the resulting output}
+\caption{\TeX\ labels with display math, and rotated by MetaPost}
\label{fig18}
\end{figure}
@@ -1512,72 +1669,176 @@ $$ \hbox{\verb|$$y={2\over 1+\cos x}$$|} $$
but this would not work because
\TeX\ typesets the labels in ``horizontal mode.''
-Here is how \TeX\ material gets translated into a form MetaPost understands:
-The MetaPost processor skips over
-{\tt btex}\index{btex?\texttt{btex}} \ldots\ {\tt etex}\index{etex?\texttt{etex}} blocks
-and depends on a preprocessor to translate them into low level MetaPost
-commands. If the main file is {\tt fig.mp}, the translated \TeX\
-material is placed in a file named {\tt fig.mpx}\index{files!mpx?{\tt mpx}}.
-This is normally
-done silently without any user intervention but it could fail if one of
-the {\tt btex} $\ldots$ {\tt etex} blocks contains an erroneous
-\TeX\index{TeX?\TeX!errors} command. Then the erroneous \TeX\ input
-is saved in the file {\tt mpxerr.tex}\index{mpxerr.tex?\texttt{mpxerr.tex}} and the error
-messages appear in {\tt mpxerr.log}\index{mpxerr.log?\texttt{mpxerr.log}}.
-
-\TeX\ macro definitions or any other auxiliary
-\TeX\ commands can be enclosed in a
-{\tt verbatimtex}\index{verbatimtex?\texttt{verbatimtex}} \ldots\ {\tt etex}\index{etex?\texttt{etex}} block.
-The difference between
-{\tt btex} and {\tt verbatimtex} is that the former generates a picture
-expression while the latter only adds material for \TeX\ to process.
-For instance, if you want \TeX\ to typeset labels using macros defined in
-{\tt mymac.tex}, your MetaPost input file would look something like this:
+For a way to typeset \emph{variable} text as labels, see the
+\texttt{TEX} utility routine described on p.\ \pageref{dTEX}.
+
+Here is how \TeX\ material gets translated into a form MetaPost
+understands: The MetaPost processor skips over {\tt
+btex}\index{btex?\texttt{btex}} \ldots\ {\tt
+etex}\index{etex?\texttt{etex}} blocks and depends on a preprocessor to
+translate them into low level MetaPost commands. If the main file is
+{\tt fig.mp}, the translated \TeX\ material is placed in a file named
+{\tt fig.mpx}\index{files!mpx?{\tt mpx}}. This is normally done
+silently without any user intervention but it could fail if one of the
+{\tt btex} $\ldots$ {\tt etex} blocks contains an erroneous
+\TeX\index{TeX?\TeX!errors} command. Then the erroneous \TeX\ input is
+saved in the file {\tt mpxerr.tex}\index{mpxerr.tex?\texttt{mpxerr.tex}}
+and the error messages appear in {\tt
+mpxerr.log}\index{mpxerr.log?\texttt{mpxerr.log}}.
+
+The preprocessor for \TeX\ labels {\it does\/} understand virtual
+fonts, so you can use your normal \TeX\ font switching commands inside
+the label.
+
+\label{Dverbatimtex}
+\TeX\ macro definitions or any other auxiliary \TeX\ commands can be
+enclosed in a {\tt verbatimtex}\index{verbatimtex?\texttt{verbatimtex}}
+\ldots\ {\tt etex}\index{etex?\texttt{etex}} block. The difference
+between {\tt btex} and {\tt verbatimtex} is that the former generates a
+picture expression while the latter only adds material for \TeX\ to
+process. For instance, if you want \TeX\ to typeset labels using macros
+defined in {\tt mymac.tex}, your MetaPost input file would look
+something like this:
\begin{eqnarray*}
&& \verb|verbatimtex \input mymac etex|\\
&& \verb|beginfig(1);|\\
-&& \qquad \vdots\\
+&& \qquad \dots\\
&& \verb|label(btex|\, \descr{\TeX\ material using \hbox{\tt mymac.tex}}\,
\verb|etex, | \descr{some coordinates} \hbox{\tt );}\\
-&& \qquad \vdots
+&& \qquad \dots
\end{eqnarray*}
On Unix\footnote{Unix is a registered trademark of Unix Systems
-Laboratories.}\index{Unix\reg}
-systems, an environment variable can be used to specify that
-{\tt btex} $\ldots$ {\tt etex} and {\tt verbatimtex} $\ldots$ {\tt etex}
-blocks are in troff\index{troff} instead of \TeX. When using this option,
-it is a good idea to start your MetaPost input file with the assignment
-{\tt prologues:=1}\index{prologues?\texttt{prologues}}\label{Dprologs}. Giving this
-internal variable\index{internal variables}\index{variables!internal}
-a positive value causes causes output to be formatted as
-``structured PostScript''\index{PostScript!structured} generated on the
-assumption that text comes from built-in PostScript fonts. This makes MetaPost
-output much more portable, but it has an important drawback: It generally
-does not work when you use \TeX\ fonts, since programs that translate \TeX\
-output into PostScript\index{PostScript} need to make special provisions for
-\TeX\index{TeX?\TeX!fonts} fonts in
-included figures and the standard PostScript structuring rules do not allow
-for this. The details on how to include PostScript figures in a paper done
-in \TeX\ or troff are system-dependent. They can generally be found in
-manual pages and other on-line documentation. A file called {\tt dvips.tex}
-is distributed electronically along with the dvips\index{dvips} \TeX\ output
-processor.
+Laboratories.}\index{Unix\reg} and other Web2C-based systems, the
+option {\tt -troff} to MetaPost tells the preprocessor that {\tt btex}
+$\ldots$ {\tt etex} and {\tt verbatimtex} $\ldots$ {\tt etex} blocks
+are in troff\index{troff} instead of \TeX. When using this option,
+MetaPost sets the internal variable
+\ttindex{troffmode} to~1\index{prologues?\texttt{prologues}}.
+
+\label{Dprologues}
+Setting \ttt{prologues} can be useful with \TeX, too, not just troff.
+Here is some explanation:
+
+\begin{itemize}
+\item When \ttt{prologues} is 0, which is the default, the MetaPost
+output files do not have embedded fonts. Fonts in the resulting
+output will probably render as Courier\index{Courier} or Times-Roman\index{Times-Roman}.
+
+\item When \ttt{prologues} is 1, the MetaPost output claims to be
+``structured PostScript''\index{PostScript!structured} (EPSF\index{EPSF}),
+but it is not completely conformant. This variant is kept for backward
+compatibility with old (troff) documents, but its use is deprecated.
+For historical reasons, MetaPost sets \ttt{prologues} to~1 when the {\tt
+-troff} option is given on the command line.
+
+\item When \ttt{prologues} is 2, the MetaPost output is EPSF and assumes
+that the text comes from PostScript fonts
+provided by the ``environment'', such as the document viewer or
+embedded application using the output. MetaPost will attempt to
+set up the font encodings correctly, based on \ttt{fontmapfile} and
+\ttt{fontmapline} commands.
+
+\item When \ttt{prologues} is 3, the MetaPost output will be EPSF but
+will contain the PostScript font(s) (or a subset) used based on the
+\ttt{fontmapfile} and \ttt{fontmapline} commands. This value is useful
+for generating stand-alone PostScript graphics.
+\end{itemize}
+
+It is worth noting that the default value \ttt{prologues:=0} is sufficient
+for graphics included in \TeX-based documents. Also, the \ttt{prologues} variable is irrelevant
+when processing MetaPost files through the \ttindex{mptopdf} utility
+(part of the \ConTeXt\ distribution), because PDF files are, by nature,
+stand-alone. The details on how to include PostScript figures in a paper
+done in \TeX\ or troff are system-dependent. They can generally be found
+in manual pages and other on-line documentation. The manual for the
+widely-used Dvips processor is in a file \ttt{dvips.texi}, included in
+most distributions, and is available online at
+\url{http://tug.org/texinfohtml/dvips.html}, among many other places and
+formats.
+
+\label{Dmakempx}
+On Web2C-based systems, the preprocessor is named \ttindex{makempx},
+which calls another utility \ttindex{mpto}; the Web2C documentation
+describes them in more detail. We'll mention one feature here, though:
+if the environment variable \ttindex{MPTEXPRE} is set to the name of an
+existing file, {\tt makempx} will prepend it to the output. You can use
+this to include \LaTeX\ preambles, for instance. The \ttt{TEX}
+macro described on p.\ \pageref{dTEX} provides another way to handle this.
+
+
+\subsection{Font map files}
+\label{Sfontmapfile}\label{Sfontmapline}
+
+If \ttt{prologues} is set to~2, any used fonts in the output file are
+automatically re-encoded, and the encoding vector file specified in
+the fontmap entry will be embedded in the output file. If
+\ttt{prologues} is set to~3, MetaPost will also attempt to include
+(a subset of) the used PostScript fonts. For this to work, it needs to
+acquire font map information.
+
+The code is based on the font library used by pdf\TeX. Following in
+the footsteps of pdf\TeX, there are two new associated primitives:
+\ttindex{fontmapfile} and \ttindex{fontmapline}. Here is a simple
+example, specifying the map file for Latin Modern fonts in \LaTeX\
+(T1) encoding:
+\begin{center}\begin{tabular}{l}
+\verb|prologues:=2;|\\
+\verb|fontmapfile "ec-public-lm.map";|\\
+\verb|beginfig(1);|\\
+\verb| draw "Helló, világ" infont "ec-lmr10";|\\
+\verb|endfig;|
+\end{tabular}\end{center}
+
+Using \ttt{fontmapline}, you can specify font mapping information
+inside the figure:
+\begin{center}\begin{tabular}{l}
+\verb|prologues:=2;|\\
+\verb|fontmapline "pplbo8r URWPalladioL-Bold "&ditto&|\\
+\verb| ".167 SlantFont"&ditto&" <8r.enc <uplb8a.pfb";|\\
+\verb|beginfig(1);|\\
+\verb| draw "Hello, world" infont "pplbo8r";|\\
+\verb|endfig;|
+\end{tabular}\end{center}
+This will attempt to reencode the PostScript font URWPalladioL-Bold
+whose tfm file is pplbo8r.tfm. The encoding is found in the file
+8r.enc, and will be included into the output file.
+
+If the same example was run with \ttt{prologues:=3}, MetaPost would
+include a subset of the font that resides in uplb8a.pfb into the
+output. In this case, the subset of the font is reorganized so that it
+has the correct encoding internally, 8r.enc will not be embedded also.
+
+The argument to both commands has an optional flag character at the very
+beginning. This optional flag has the same meaning as in pdf\TeX:
+$$\begin{tabular}{|c|l|} \hline
+\multicolumn1{|c|}{option}& \multicolumn1{c|}{meaning}\\ \hline
+ + & extend the font list, but ignore duplicates \\
+ = & extend the font list, replacing duplicates \\
+ $-$ & remove all matching fonts from the font list \\
+\hline
+\end{tabular}
+$$
+Without any option, the current list will be completely replaced. If there are no \ttt{fontmapfile} statements, MetaPost will attempt
+to locate a default map file with a preference to read {\tt
+mpost.map} and then {\tt pdftex.map}. If \ttt{prologues} is set to~1,
+MetaPost attempts to read a file called {\tt psfonts.map}, regardless of any
+{\tt fontmapfile} statement. Again, this is for backward compatibility only.
\subsection{The {\tt infont} operator}
\label{Sinfont}
-Regardless of whether you use \TeX\ or troff, all the real work of adding
-text to pictures is done by a MetaPost primitive operator called
-{\tt infont}\index{infont?\texttt{infont}}. It is a
-\tdescr{primary binop}\index{primary binop?\tdescr{primary binop}} that takes a
-\tdescr{string secondary} as its
-left argument and a \tdescr{string primary} as its right argument. The left
-argument is text, and the right argument is a font name.
-The result of the operation is a \tdescr{picture secondary} that can then be
-transformed in various ways. One possibility is enlargement by a given factor
-via the syntax\index{scaled?\texttt{scaled}}
+Regardless of whether you use \TeX\ or troff, all the real work of
+adding text to pictures is done by a MetaPost primitive operator called
+{\tt infont}\index{infont?\texttt{infont}}. It is a \tdescr{primary
+binop}\index{primary binop?\tdescr{primary binop}} that takes a
+\tdescr{string secondary} as its left argument and a \tdescr{string
+primary} as its right argument. The left argument is text, and the
+right argument is a font name. The result of the operation is a
+\tdescr{picture secondary} that can then be transformed in various ways.
+One possibility is enlargement by a given factor via the
+syntax\index{scaled?\texttt{scaled}}
$$ \descr{picture secondary}\, \hbox{\tt scaled}\, \descr{numeric primary} $$
Thus {\tt label("text",z0)} is equivalent to
$$ \hbox{\tt label("text" infont defaultfont scaled defaultscale, z0)} $$
@@ -1587,61 +1848,69 @@ If it is not convenient to use a string constant for the left argument of
$$ {\tt char}\, \descr{numeric primary} $$
to select a character based on its numeric position in the font.
Thus
-$$ \hbox{\tt char(n+64) infont "Times-Roman"} $$
-is a picture containing character {\tt n+64} of the Times-Roman font.
+$$ \hbox{\tt char(n+64) infont "ptmr8r"} $$
+is a picture containing character {\tt n+64} of the font \ttt{ptmr8r},
+which is a typical \TeX\ way to refer to Times-Roman. See p.\
+\pageref{fontname} for further discussion.
\subsection{Measuring Text}
\label{meas}
-MetaPost makes readily available the physical dimensions\index{size}
-of pictures generated by the {\tt infont} operator. There are
-unary operators {\tt llcorner}\index{llcorner?\texttt{llcorner}}\label{Dcornop},
-{\tt lrcorner}\index{lrcorner?\texttt{lrcorner}}, {\tt urcorner}\index{urcorner?\texttt{urcorner}},
-{\tt ulcorner}\index{ulcorner?\texttt{ulcorner}}, and {\tt center}\index{center}\label{Dcenter}
-that take a \tdescr{picture primary} and return the corners of its ``bounding
-box'' as illustrated in Figure~\ref{bbox}. The {\tt center} operator also
-accepts \tdescr{path primary} and \tdescr{pen primary} operands.
-In MetaPost Version 0.30 and higher, {\tt llcorner}, {\tt lrcorner}, etc.
-accept all three argument types as well.
-
-The argument type restrictions on the corner operators are not very important
-because their main purpose is to allow {\tt label} and {\tt dotlabel} statements
-to center their text properly.
-The predefined macro\index{bbox?\texttt{bbox}}\label{Dbbox}
+MetaPost makes readily available the physical dimensions\index{size} of
+pictures generated by the {\tt infont} operator. There are unary
+operators {\tt
+llcorner}\index{llcorner?\texttt{llcorner}}\label{Dcornop}, {\tt
+lrcorner}\index{lrcorner?\texttt{lrcorner}}, {\tt
+urcorner}\index{urcorner?\texttt{urcorner}}, {\tt
+ulcorner}\index{ulcorner?\texttt{ulcorner}}, and {\tt
+center}\index{center}\label{Dcenter} that take a \tdescr{picture
+primary} and return the corners of its ``bounding box'' as illustrated
+in Figure~\ref{bbox}. The {\tt center} operator also accepts
+\tdescr{path primary} and \tdescr{pen primary} operands. In MetaPost
+Version 0.30 and higher, {\tt llcorner}, {\tt lrcorner}, etc. accept
+all three argument types as well.
+
+The argument type restrictions on the corner operators are not very
+important because their main purpose is to allow {\tt label} and {\tt
+dotlabel} statements to center their text properly. The predefined
+macro\index{bbox?\texttt{bbox}}\label{Dbbox}
$$ {\tt bbox}\, \descr{picture primary} $$
finds a rectangular path that represents the bounding box of a given picture.
If {\tt p} is a picture, {\tt bbox p} equivalent to
$$ \hbox{\tt (llcorner p--lrcorner p--urcorner p--ulcorner p--cycle)} $$
-except that it allows for a small amount of extra space around {\tt p} as specified
-by the internal variable\index{internal variables}\index{variables!internal}
-{\tt bboxmargin}\index{bboxmargin?\texttt{bboxmargin}}\label{Dbbmargin}.
+except that it allows for a small amount of extra space around {\tt p}
+as specified by the internal variable\index{internal
+variables}\index{variables!internal} {\tt
+bboxmargin}\index{bboxmargin?\texttt{bboxmargin}}\label{Dbbmargin}.
\begin{figure}[htp]
-$$ \epsfbox{manfig.20} $$
+$$ \includegraphics{manfig-20} $$
\caption{A bounding box and its corner points.}
\label{bbox}
\end{figure}
-Note that MetaPost computes the bounding box of a {\tt btex}\index{btex?\texttt{btex}}
-\ldots\ {\tt etex}\index{etex?\texttt{etex}} picture just the way \TeX\index{TeX?\TeX} does.
-This is quite natural, but it has certain implications in view of the fact that
-\TeX\ has features like {\tt\string\strut}\index{strut?{\tt\string\strut}} and
-{\tt\string\rlap}\index{rlap?{\tt\string\rlap}} that allow \TeX\ users to lie about the
-dimensions of a box.
-
-When \TeX\ commands that lie about the dimensions of a box are translated in to
-low-level MetaPost code, a {\tt setbounds}\index{setbounds?\texttt{setbounds}}\label{Dsetbnd}
-statement does the lying:\index{picture variable?\tdescr{picture variable}}
+Note that MetaPost computes the bounding box of a {\tt
+btex}\index{btex?\texttt{btex}} \ldots\ {\tt
+etex}\index{etex?\texttt{etex}} picture just the way
+\TeX\index{TeX?\TeX} does. This is quite natural, but it has certain
+implications in view of the fact that \TeX\ has features like
+{\tt\string\strut}\index{strut?{\tt\string\strut}} and
+{\tt\string\rlap}\index{rlap?{\tt\string\rlap}} that allow \TeX\ users
+to lie about the dimensions of a box.
+
+When \TeX\ commands that lie about the dimensions of a box are
+translated in to low-level MetaPost code, a {\tt
+setbounds}\index{setbounds?\texttt{setbounds}}\label{Dsetbnd} statement
+does the lying:\index{picture variable?\tdescr{picture variable}}
$$ {\tt setbounds}\, \descr{picture variable}\, {\tt to}\, \descr{path expression}
$$
-makes the \tdescr{picture variable} behave as if its bounding box were the same
-as the given path. To get the true bounding box of such a picture, assign a
-positive value to the
-internal variable\index{internal variables}\index{variables!internal}
-{\tt truecorners}\index{truecorners?\texttt{truecorners}}\label{Dtruecorn}:\footnote{The
-{\tt setbounds} and
-{\tt truecorners} features are only found in MetaPost version 0.30 and higher.}
-i.e.,
+makes the \tdescr{picture variable} behave as if its bounding box were
+the same as the given path. To get the true bounding box of such a
+picture, assign a positive value to the internal variable\index{internal
+variables}\index{variables!internal} {\tt
+truecorners}\index{truecorners?\texttt{truecorners}}\label{Dtruecorn}:\footnote{The
+{\tt setbounds} and {\tt truecorners} features are only found in
+MetaPost version 0.30 and higher.} i.e.,
$$ \hbox{\verb|show urcorner btex $\bullet$\rlap{ A} etex|} $$
produces ``\verb|>> (4.9813,6.8078)|'' while
$$ \hbox{\verb|truecorners:=1; show urcorner btex $\bullet$\rlap{ A} etex|} $$
@@ -1651,20 +1920,19 @@ produces ``\verb|>> (15.7742,6.8078)|.''
\section{Advanced Graphics}
\label{adv.gr}
-All the examples in the previous sections have been simple line drawings with
-labels added. This section describes shading and tools for generating
-not-so-simple line drawings.
-Shading is done with the {\tt fill}\index{fill?\texttt{fill}}\label{Dfill} statement.
-In its simplest
-form, the {\tt fill} statement requires a \tdescr{path expression} that gives
-the boundary of the region to be filled. In the syntax
+All the examples in the previous sections have been simple line drawings
+with labels added. This section describes shading and tools for
+generating not-so-simple line drawings. Shading is done with the {\tt
+fill}\index{fill?\texttt{fill}}\label{Dfill} statement. In its simplest
+form, the {\tt fill} statement requires a \tdescr{path expression} that
+gives the boundary of the region to be filled. In the syntax
$$ {\tt fill}\, \descr{path expression} $$
-the argument should be a cyclic path, i.e., a path that describes a closed curve
-via the {\tt ..cycle} or {\tt --cycle} notation. For example, the {\tt fill}
-statement in Figure~\ref{fig20} builds a closed path by extending the roughly
-semicircular path~{\tt p}.
-This path has a counter-clockwise orientation, but that does not matter because
-the {\tt fill} statement uses PostScript's\index{PostScript} non-zero
+the argument should be a cyclic path, i.e., a path that describes a
+closed curve via the {\tt ..cycle} or {\tt --cycle} notation. For
+example, the {\tt fill} statement in Figure~\ref{fig20} builds a closed
+path by extending the roughly semicircular path~{\tt p}. This path has
+a counter-clockwise orientation, but that does not matter because the
+{\tt fill} statement uses PostScript's\index{PostScript} non-zero
winding\index{winding number} number rule~\cite{ad:red}.
\begin{figure}[htp]
@@ -1676,7 +1944,7 @@ fill p{up}..(0,0){-1,-2}..{up}cycle;
draw p..(0,1cm)..cycle;
endfig;
\end{verbatim}
-\qquad \mathcenter{\epsfbox{manfig.21}}
+\qquad \mathcenter{\includegraphics{manfig-21}}
$$
\caption{MetaPost code and the corresponding output.}
\label{fig20}
@@ -1687,18 +1955,67 @@ $$ {\tt fill}\, \descr{path expression}\,
{\tt withcolor}\, \descr{color expression}
$$
specifies a shade of gray or (if you have a color printer) some
-rainbow color.
-
-Figure~\ref{fig21} illustrates several applications of the fill command to fill
-areas with shades of gray. The paths involved are intersecting circles {\tt a}
-and {\tt b} and a path {\tt ab} that bounds the region inside both circles.
-Circles {\tt a} and {\tt b} are derived from a predefined path
-{\tt fullcircle}\index{fullcircle?\texttt{fullcircle}}\label{Dfcirc}
-that approximates a circle of unit diameter centered on the origin. There is
-also a predefined path {\tt halfcircle}\index{halfcircle?\texttt{halfcircle}}\label{Dhcirc}
-that is the part
-of {\tt fullcircle} above the $x$ axis. Path~{\tt ab} is the initialized
-using a predefined macro {\tt buildcycle} that will be discussed shortly.
+rainbow color. The $\descr{color expression}$ can have five possible
+values, mapping to four possible color models:
+
+$$
+\begin{tabular}{|l|l|}
+Actual input & Remapped meaning\\
+{\tt withcolor} $\descr{rgbcolor} c$ & withrgbcolor $c$\\
+{\tt withcolor} $\descr{cmykcolor} c$ & withcmykcolor $c$\\
+{\tt withcolor} $\descr{numeric} c$ & withgreyscale $c$\\
+{\tt withcolor} $\descr{false}$ & withoutcolor \\
+{\tt withcolor} $\descr{true}$ & $\descr{current default color model}$\\
+\end{tabular}
+$$
+
+For the specific color models, there are also:
+$$ {\tt fill}\, \descr{path expression}\,
+ {\tt withrgbcolor}\, \descr{rgbcolor expression}
+$$
+$$ {\tt fill}\, \descr{path expression}\,
+ {\tt withcmykcolor}\, \descr{cmykcolor expression}
+$$
+$$ {\tt fill}\, \descr{path expression}\,
+ {\tt withgreyscale}\, \descr{numeric}
+$$
+$$ {\tt fill}\, \descr{path expression}\,
+ {\tt withoutcolor}
+$$
+
+An image object cannot have more then one color model, the last
+\ttt{withcolor}, \ttt{withrgbcolor}, \ttt{withcmykcolor},
+\ttt{withgreyscale} or \ttt{withoutcolor} specification sets the color
+model for any particular object.
+
+The model \ttt{withoutcolor} needs a bit more explanation: selecting
+this model means that MetaPost will not write a color selection
+statement to the PostScript output file for this object.
+
+The `current default' color model can be set up using the internal
+parameter \ttindex{defaultcolormodel}. Valid values are:
+$$
+\begin{tabular}{|l|l|}
+1 & no model\\
+3 & greyscale\\
+5 & rgb (default)\\
+7 & cmyk\\
+\end{tabular}
+$$
+
+
+Figure~\ref{fig21} illustrates several applications of the fill command
+to fill areas with shades of gray. The paths involved are intersecting
+circles {\tt a} and {\tt b} and a path {\tt ab} that bounds the region
+inside both circles. Circles {\tt a} and {\tt b} are derived from a
+predefined path {\tt
+fullcircle}\index{fullcircle?\texttt{fullcircle}}\label{Dfcirc} that
+approximates a circle of unit diameter centered on the origin. There is
+also a predefined path {\tt
+halfcircle}\index{halfcircle?\texttt{halfcircle}}\label{Dhcirc} that is
+the part of {\tt fullcircle} above the $x$ axis. Path~{\tt ab} is then
+initialized using a predefined macro {\tt buildcycle} that will be
+discussed shortly.
\begin{figure}[htp]
$$ \begin{verbatim}
@@ -1722,38 +2039,40 @@ label.lft(btex $U$ etex, (-1cm,.5cm));
draw bbox currentpicture;
endfig;
\end{verbatim}
-\qquad \mathcenter{\epsfbox{manfig.22}}
+\qquad \mathcenter{\includegraphics{manfig-22}}
$$
\caption{MetaPost code and the corresponding output.}
\index{fullcircle?\texttt{fullcircle}}\index{halfcircle?\texttt{halfcircle}}\index{buildcycle?\texttt{buildcycle}}
\label{fig21}
\end{figure}
-Filling circle {\tt a} with the light gray color {\tt .7white} and then doing the
-same with circle {\tt b} doubly fills the region where the disks overlap. The
-rule is that each {\tt fill} statement assigns the given color to all points in
-the region covered, wiping out whatever was there previously including lines and
-text as well as filled regions. Thus it is important to give {\tt fill} commands
-in the right order.
-In the above example, the overlap region gets the same color twice,
-leaving it light gray after the first two {\tt fill} statements. The third fill
+Filling circle {\tt a} with the light gray color {\tt .7white} and then
+doing the same with circle {\tt b} doubly fills the region where the
+disks overlap. The rule is that each {\tt fill} statement assigns the
+given color to all points in the region covered, wiping out whatever was
+there previously including lines and text as well as filled regions.
+Thus it is important to give {\tt fill} commands in the right order. In
+the above example, the overlap region gets the same color twice, leaving
+it light gray after the first two {\tt fill} statements. The third fill
statement assigns the darker color {\tt .4white} to the overlap region.
-At this point the circles and the overlap region have their final colors but
-there are no cutouts for the labels. The cutouts are achieved by the
-{\tt unfill}\index{unfill?\texttt{unfill}}\label{Dunfill}
-statements that effectively erase\index{erasing}
-the regions bounded by {\tt bbox pa}\index{bbox?\texttt{bbox}} and
-{\tt bbox pb}. More precisely, {\tt unfill} is shorthand for filling
-{\tt withcolor background}, where {\tt background} is normally equal to {\tt white}
-as is appropriate for printing on white paper. If necessary, you can assign a new
-color value to {\tt background}\index{background?\texttt{background}}\label{Dbground}.
+At this point the circles and the overlap region have their final colors
+but there are no cutouts for the labels. The cutouts are achieved by
+the {\tt unfill}\index{unfill?\texttt{unfill}}\label{Dunfill} statements
+that effectively erase\index{erasing} the regions bounded by {\tt bbox
+pa}\index{bbox?\texttt{bbox}} and {\tt bbox pb}. More precisely, {\tt
+unfill} is shorthand for filling {\tt withcolor background}, where {\tt
+background} is normally equal to {\tt white} as is appropriate for
+printing on white paper. If necessary, you can assign a new color value
+to {\tt
+background}\index{background?\texttt{background}}\label{Dbground}.
The labels need to be stored in pictures {\tt pa} and {\tt pb} to allow
-for measuring their bounding box before actually drawing them. The macro
-{\tt thelabel}\index{thelabel?\texttt{thelabel}} creates such
-pictures and shifts them into position so that they are ready to draw. Using the
-resulting pictures in {\tt draw} statements of the form\index{draw?\texttt{draw}}
+for measuring their bounding box before actually drawing them. The
+macro {\tt thelabel}\index{thelabel?\texttt{thelabel}} creates such
+pictures and shifts them into position so that they are ready to draw.
+Using the resulting pictures in {\tt draw} statements of the
+form\index{draw?\texttt{draw}}
$$ {\tt draw}\, \descr{picture expression} $$
adds them to {\tt currentpicture}\index{currentpicture?\texttt{currentpicture}}
so that they overwrite a portion of what has
@@ -1763,28 +2082,29 @@ already been drawn. In Figure~\ref{fig21} just the white rectangles produced by
\subsection{Building Cycles}
\label{buildcy}
-The {\tt buildcycle}\index{buildcycle?\texttt{buildcycle}} command constructs paths for use with
-the {\tt fill} or {\tt unfill} macros. When given two or more paths such as
-{\tt aa} and {\tt b},
-the {\tt buildcycle} macro tries to piece them together so as to form a cyclic
-path. In this case path {\tt aa} is a semicircle that starts just to the right
-of the intersection with path {\tt b}, then passes through {\tt b} and ends just
-outside the circle on the left as shown in Figure~\ref{fig22}a.
-
-Figure~\ref{fig22}b shows how {\tt buildcycle} forms a closed
-cycle from pieces of paths {\tt aa} and {\tt b}.
-The {\tt buildcycle} macro detects the two intersections\index{intersections}
-labeled 1 and 2 in
-Figure~\ref{fig22}b. Then it constructs the cyclic path shown in bold in the
-figure by going forward along path {\tt aa} from intersection~1 to
-intersection~2 and then forward around the counter-clockwise path {\tt b} back to
-intersection~1. It turns out that {\tt buildcycle(a,b)} would have produced the
-same result, but the reasoning behind this is a little confusing.
+The {\tt buildcycle}\index{buildcycle?\texttt{buildcycle}} command
+constructs paths for use with the {\tt fill} or {\tt unfill} macros.
+When given two or more paths such as {\tt aa} and {\tt b}, the {\tt
+buildcycle} macro tries to piece them together so as to form a cyclic
+path. In this case path {\tt aa} is a semicircle that starts just to
+the right of the intersection with path {\tt b}, then passes through
+{\tt b} and ends just outside the circle on the left as shown in
+Figure~\ref{fig22}a.
+
+Figure~\ref{fig22}b shows how {\tt buildcycle} forms a closed cycle from
+the pieces of paths {\tt aa} and {\tt b}. The {\tt buildcycle} macro
+detects the two intersections\index{intersections} labeled 1 and 2 in
+Figure~\ref{fig22}b. Then it constructs the cyclic path shown in bold
+in the figure by going forward along path {\tt aa} from intersection~1
+to intersection~2 and then forward around the counter-clockwise path
+{\tt b} back to intersection~1. It turns out that {\tt buildcycle(a,b)}
+would have produced the same result, but the reasoning behind this is a
+little confusing.
\begin{figure}[htp]
-$$ {\epsfbox{manfig.123} \atop (a)}
- \qquad {\epsfbox{manfig.223} \atop (b)}
+$$ {\includegraphics{manfig-123} \atop (a)}
+ \qquad {\includegraphics{manfig-223} \atop (b)}
$$
\caption[A demonstration of cycle building]
{(a)~The semicircular path~{\tt aa}
@@ -1794,18 +2114,20 @@ $$
\end{figure}
It is a easier to use the {\tt buildcycle} macro in situations like
-Figure~\ref{fig23} where there are more than two path arguments and each pair
-of consecutive paths has a unique intersection. For instance, the line~{\tt q0.5}
-and the curve~{\tt p2} intersect only at point~$P$; and the curve {\tt p2} and the
-line~{\tt q1.5} intersect only at point~$Q$. In fact, each of the points $P$,
-$Q$, $R$, $S$ is a unique intersection, and the result of\index{buildcycle?\texttt{buildcycle}}
+Figure~\ref{fig23} where there are more than two path arguments and each
+pair of consecutive paths has a unique intersection. For instance, the
+line~{\tt q0.5} and the curve~{\tt p2} intersect only at point~$P$; and
+the curve {\tt p2} and the line~{\tt q1.5} intersect only at point~$Q$.
+In fact, each of the points $P$, $Q$, $R$, $S$ is a unique intersection,
+and the result of\index{buildcycle?\texttt{buildcycle}}
$$ \hbox{\tt buildcycle(q0.5, p2, q1.5, p4)} $$
-takes {\tt q0.5} from $S$ to~$P$, then {\tt p2} from $P$ to~$Q$, then {\tt q1.5}
-from $Q$ to~$R$, and finally {\tt p4} from $R$ back to~$S$. An examination of the
-MetaPost code for Figure~\ref{fig23} reveals that you have to go backwards along
-{\tt p2} in order to get from $P$ to~$Q$. This works perfectly well as long as
-the intersection\index{intersection} points are uniquely defined but it can cause
-unexpected results when pairs of paths intersect more than once.
+takes {\tt q0.5} from $S$ to~$P$, then {\tt p2} from $P$ to~$Q$, then
+{\tt q1.5} from $Q$ to~$R$, and finally {\tt p4} from $R$ back to~$S$.
+An examination of the MetaPost code for Figure~\ref{fig23} reveals that
+you have to go backwards along {\tt p2} in order to get from $P$ to~$Q$.
+This works perfectly well as long as the
+intersection\index{intersection} points are uniquely defined but it can
+cause unexpected results when pairs of paths intersect more than once.
\begin{figure}[htp]
$$ \begin{verbatim}
@@ -1829,7 +2151,7 @@ dotlabel.lft(btex $R$ etex, p4 intersectionpoint q1.5);
dotlabel.bot(btex $S$ etex, p4 intersectionpoint q0.5);
endfig;
\end{verbatim}
-\atop \mathcenter{\epsfbox{manfig.24}}
+\atop \mathcenter{\includegraphics{manfig-24}}
$$
\caption{MetaPost code and the corresponding output.}
\label{fig23}
@@ -1839,132 +2161,143 @@ The general rule for the {\tt buildcycle} macro is that
$$ \hbox{\tt buildcycle(}p_1\hbox{\tt,}\, p_2\hbox{\tt,}\,
p_3\hbox{\tt,}\, \ldots \hbox{\tt,} p_k \hbox{\tt )}
$$
-chooses the intersection between each $p_i$ and $p_{i+1}$ to be as late as possible
-on $p_i$ and as early as possible on $p_{i+1}$. There is no
-simple rule for resolving conflicts between these two goals, so you should avoid
-cases where one intersection point occurs later on $p_i$ and another
-intersection\index{intersection} point occurs earlier on $p_{i+1}$.
-
-The preference for intersections as late as possible
-on $p_i$ and as early as possible on $p_{i+1}$ leads to ambiguity resolution in
-favor of forward-going subpaths. For cyclic paths such as path~{\tt b} in
-Figure~\ref{fig22} ``early'' and ``late'' are relative to a start/finish point
-which is where you get back to when you say ``{\tt ..cycle}''.
-For the path~{\tt b}, this turns out to be the rightmost point on the circle.
+chooses the intersection between each $p_i$ and $p_{i+1}$ to be as late
+as possible on $p_i$ and as early as possible on $p_{i+1}$. There is no
+simple rule for resolving conflicts between these two goals, so you
+should avoid cases where one intersection point occurs later on $p_i$
+and another intersection\index{intersection} point occurs earlier on
+$p_{i+1}$.
+
+The preference for intersections as late as possible on $p_i$ and as
+early as possible on $p_{i+1}$ leads to ambiguity resolution in favor of
+forward-going subpaths. For cyclic paths such as path~{\tt b} in
+Figure~\ref{fig22} ``early'' and ``late'' are relative to a start/finish
+point which is where you get back to when you say ``{\tt ..cycle}''.
+For the path~{\tt b}, this turns out to be the rightmost point on the
+circle.
A more direct way to deal with path intersections is via the
\tdescr{secondary binop}\index{secondary binop?\tdescr{secondary binop}}
-{\tt intersection\-point}\index{intersectionpoint?\texttt{intersectionpoint}}\label{Disecpt}
+{\tt
+intersection\-point}\index{intersectionpoint?\texttt{intersectionpoint}}\label{Disecpt}
that finds the points $P$, $Q$, $R$, and~$S$ in Figure~\ref{fig23}.
-This macro finds a point where two given
-paths intersect. If there is more than one intersection point, it just chooses
-one; if there is no intersection, the macro generates an error message.
+This macro finds a point where two given paths intersect. If there is
+more than one intersection point, it just chooses one; if there is no
+intersection, the macro generates an error message.
\subsection{Dealing with Paths Parametrically}
-The {\tt intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}} macro is based on a
-primitive operation called
-{\tt intersectiontimes}\index{intersectiontimes?\texttt{intersectiontimes}}\label{Disectt}.
-This \tdescr{secondary binop} is one of several
-operations that deal with paths parametrically. It locates an intersection
-between two paths by giving the ``time'' parameter on each path. This refers to
-the parameterization scheme from Section~\ref{curves} that described paths as
-piecewise cubic curves $\bigl(X(t),Y(t)\bigr)$ where $t$ ranges from zero to the
-number of curve segments. In other words, when a path is specified as passing
-through a sequence of points, where $t=0$ at the first point,
-then $t=1$ at the next, and $t=2$ at the next, etc. The result of
+The {\tt
+intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}}
+macro is based on a primitive operation called {\tt
+intersectiontimes}\index{intersectiontimes?\texttt{intersectiontimes}}\label{Disectt}.
+This \tdescr{secondary binop} is one of several operations that deal
+with paths parametrically. It locates an intersection between two paths
+by giving the ``time'' parameter on each path. This refers to the
+parameterization scheme from Section~\ref{curves} that described paths
+as piecewise cubic curves $\bigl(X(t),Y(t)\bigr)$ where $t$ ranges from
+zero to the number of curve segments. In other words, when a path is
+specified as passing through a sequence of points, where $t=0$ at the
+first point, then $t=1$ at the next, and $t=2$ at the next, etc. The
+result of
$$ \hbox{\tt a intersectiontimes b} $$
is $(-1,-1)$ if there is no intersection; otherwise you get
a pair $(t_a,t_b)$, where $t_a$ is a time on path {\tt a} when it intersects
path~{\tt b}, and $t_b$ is the corresponding time on path~{\tt b}.
-For example, suppose path~{\tt a} is denoted by the thin line in Figure~\ref{fig24}
-and path~{\tt b} is denoted by the thicker line. If the labels indicate time
-values on the paths, the pair of time values computed by
+For example, suppose path~{\tt a} is denoted by the thin line in
+Figure~\ref{fig24} and path~{\tt b} is denoted by the thicker line. If
+the labels indicate time values on the paths, the pair of time values
+computed by
$$ \hbox{\tt a intersectiontimes b} $$
must be one of
$$ (0.25,1.77),\ (0.75,1.40), {\rm or}\ (2.58,0.24), $$
-depending on which of the three intersection points is chosen by the MetaPost
-interpreter. The exact rules for choosing among multiple intersection points
-are a little complicated, but it turns out that you get the time values
-$(0.25,1.77)$ in this example. Smaller time values are preferred over larger
-ones so that $(t_a,t_b)$ is preferred to $(t'_a,t'_b)$ whenever $t'_a<t_a$ and
-$t_b<t'_b$. When no single alternative minimizes both the $t_a$ and $t_b$
-components the $t_a$ component tends to get priority, but the rules get more
-complicated when there are no integers between $t_a$
-and $t'_a$\index{intersection}.
-(For more details, see {\it The \MF book}.\cite[Chapter 14]{kn:c})
+depending on which of the three intersection points is chosen by the
+MetaPost interpreter. The exact rules for choosing among multiple
+intersection points are a little complicated, but it turns out that you
+get the time values $(0.25,1.77)$ in this example. Smaller time values
+are preferred over larger ones so that $(t_a,t_b)$ is preferred to
+$(t'_a,t'_b)$ whenever $t_a<t'_a$ and $t_b<t'_b$. When no single
+alternative minimizes both the $t_a$ and $t_b$ components the $t_a$
+component tends to get priority, but the rules get more complicated when
+there are no integers between $t_a$ and $t'_a$\index{intersection}.
+(For more details, see {\sl The \MF book} \cite[Chapter 14]{kn:c}).
\begin{figure}[htp]
-$$ \epsfbox{manfig.25} $$
+$$ \includegraphics{manfig-25} $$
\caption{Two intersecting paths with time values marked on each path.}
\label{fig24}
\end{figure}
-The {\tt intersectiontimes} operator is more flexible than {\tt intersectionpoint}
-because there are a number of things that can be done with time values on a path.
-One of the most important is just to ask ``where is path {\tt p} at
-time {\tt t}?'' The construction\index{point of?\texttt{point of}}\label{Dpntof}
+The {\tt intersectiontimes} operator is more flexible than {\tt
+intersectionpoint} because there are a number of things that can be done
+with time values on a path. One of the most important is just to ask
+``where is path {\tt p} at time {\tt t}?'' The construction\index{point
+of?\texttt{point of}}\label{Dpntof}
$$ {\tt point}\, \descr{numeric expression}\, {\tt of}\, \descr{path primary} $$
-answers this question. If the \tdescr{numeric expression} is less than zero or
-greater than the time value assigned to the last point on the path, the
-{\tt point of} construction normally yields an endpoint of the path. Hence, it
-is common to use the predefined constant
-{\tt infinity}\index{infinity?\texttt{infinity}}\label{Dinf}
-(equal to 4095.99998) as the
-\tdescr{numeric expression} in a {\tt point of} construction when dealing with
-the end of a path.
-
-Such ``infinite'' time values do not work for a cyclic path, since
-time values outside of the normal range can be handled by modular arithmetic in
-that case; i.e., a cyclic path~{\tt p} through points $z_0$, $z_1$, $z_2$,
-\ldots, $z_{n-1}$ has the normal parameter range $0\le t<n$, but
+answers this question. If the \tdescr{numeric expression} is less than
+zero or greater than the time value assigned to the last point on the
+path, the {\tt point of} construction normally yields an endpoint of the
+path. Hence, it is common to use the predefined constant {\tt
+infinity}\index{infinity?\texttt{infinity}}\label{Dinf} (equal to
+4095.99998) as the \tdescr{numeric expression} in a {\tt point of}
+construction when dealing with the end of a path.
+
+Such ``infinite'' time values do not work for a cyclic path, since time
+values outside of the normal range can be handled by modular arithmetic
+in that case; i.e., a cyclic path~{\tt p} through points $z_0$, $z_1$,
+$z_2$, \ldots, $z_{n-1}$ has the normal parameter range $0\le t<n$, but
$$ \hbox{\tt point t of p} $$
-can be computed for any~$t$ by first reducing $t$ modulo~$n$. If the modulus~$n$
-is not readily available,\index{length?\texttt{length}}\label{Dlength}
+can be computed for any~$t$ by first reducing $t$ modulo~$n$. If the
+modulus~$n$ is not readily
+available,\index{length?\texttt{length}}\label{Dlength}
$$ {\tt length}\, \descr{path primary} $$
-gives the integer value of the upper limit of the normal time parameter range
-for the specified path.
+gives the integer value of the upper limit of the normal time parameter
+range for the specified path.
-MetaPost uses the same correspondence between time values and points on a path to
-evaluate the {\tt subpath}\index{subpath?\texttt{subpath}}\label{Dsubpth} operator.
-The syntax for this operator is
+MetaPost uses the same correspondence between time values and points on
+a path to evaluate the {\tt
+subpath}\index{subpath?\texttt{subpath}}\label{Dsubpth} operator. The
+syntax for this operator is
$$ {\tt subpath}\, \descr{pair expression}\, {\tt of}\, \descr{path primary} $$
If the value of the \tdescr{pair expression} is $(t_1,t_2)$ and the
\tdescr{path primary} is $p$, the result is a path that follows $p$ from
-{\tt point $t_1$ of $p$} to {\tt point $t_2$ of $p$}. If $t_2<t_1$, the subpath
-runs backwards along~$p$.
+{\tt point $t_1$ of $p$} to {\tt point $t_2$ of $p$}. If $t_2<t_1$, the
+subpath runs backwards along~$p$.
An important operation based on the {\tt subpath} operator is the
\tdescr{tertiary binop}\index{tertiary binop?\tdescr{tertiary binop}}
-{\tt cutbefore}\index{cutbefore?\texttt{cutbefore}}\label{Dcutb}. For intersecting
-paths $p_1$ and $p_2$,
+{\tt cutbefore}\index{cutbefore?\texttt{cutbefore}}\label{Dcutb}. For
+intersecting paths $p_1$ and $p_2$,
$$ p_1\ {\tt cutbefore}\ p_2 $$
is equivalent to
$$ \hbox{\tt subpath (xpart($p_1$ intersectiontimes $p_2$), length $p_1$) of $p_1$}
$$
-except that it also sets the path variable
-{\tt cuttings}\index{cuttings?\texttt{cuttings}}\label{Dcuttings} to
-the portion of $p_1$ that gets cut off. In other words, {\tt cutbefore} returns
-its first argument with the part before the intersection cut off. With multiple
-intersections, it tries to cut off as little as possible. If the paths do not
-intersect, {\tt cutbefore} returns its first argument.
-
-There is also an analogous \tdescr{tertiary binop}\index{tertiary binop?\tdescr{tertiary binop}}
-called {\tt cutafter}\index{cutafter?\texttt{cutafter}}\label{Dcuta} that works by applying
-{\tt cutbefore} with
-time reversed along its first argument. Thus
+except that it also sets the path variable {\tt
+cuttings}\index{cuttings?\texttt{cuttings}}\label{Dcuttings} to the
+portion of $p_1$ that gets cut off. In other words, {\tt cutbefore}
+returns its first argument with the part before the intersection cut
+off. With multiple intersections, it tries to cut off as little as
+possible. If the paths do not intersect, {\tt cutbefore} returns its
+first argument.
+
+There is also an analogous \tdescr{tertiary binop}\index{tertiary
+binop?\tdescr{tertiary binop}} called {\tt
+cutafter}\index{cutafter?\texttt{cutafter}}\label{Dcuta} that works by
+applying {\tt cutbefore} with time reversed along its first argument.
+Thus
$$ p_1\ {\tt cutafter}\ p_2 $$
tries to cut off the part of $p_1$ after its last intersection with $p_2$.
Another operator\index{direction of?\texttt{direction of}}\label{Ddirof}
$$ {\tt direction}\, \descr{numeric expression}\, {\tt of}\, \descr{path primary}
$$
-finds a vector in the direction of the \tdescr{path primary}. This is defined
-for any time value analogously to the {\tt point of} construction. The resulting
-direction vector has the correct orientation and a somewhat arbitrary magnitude.
-Combining {\tt point of} and {\tt direction of} constructions yields the equation
-for a tangent line as illustrated in Figure~\ref{fig25}.
+finds a vector in the direction of the \tdescr{path primary}. This is
+defined for any time value analogously to the {\tt point of}
+construction. The resulting direction vector has the correct
+orientation and a somewhat arbitrary magnitude. Combining {\tt point
+of} and {\tt direction of} constructions yields the equation for a
+tangent line as illustrated in Figure~\ref{fig25}.
\begin{figure}[htp]
$$ \begin{verbatim}
@@ -1992,26 +2325,26 @@ pickup pencircle scaled 1pt;
draw fun;
endfig;
\end{verbatim}
-\atop \epsfbox{manfig.26}
+\atop \includegraphics{manfig-26}
$$
\caption{MetaPost code and the resulting figure}
\label{fig25}
\end{figure}
-If you know a slope and you want to find a point on a curve where the tangent
-line has that slope,
-the {\tt directiontime}\index{directiontime of?\texttt{directiontime of}}\label{Ddtimof}
-operator inverts the {\tt direction
-of} operation. Given a direction vector and a path,
+If you know a slope and you want to find a point on a curve where the
+tangent line has that slope, the {\tt directiontime}\index{directiontime
+of?\texttt{directiontime of}}\label{Ddtimof} operator inverts the {\tt
+direction of} operation. Given a direction vector and a path,
$$ {\tt directiontime}\, \descr{pair expression}\, {\tt of}\,
\descr{path primary}
$$
-returns a numeric value that gives the first time~$t$ when the path has the
-indicated direction. (If there is no such time, the result is $-1$).
-For example, if {\tt a} is the path drawn as a thin curve in Figure~\ref{fig24},
-{\tt directiontime (1,1) of a} returns 0.2084.
+returns a numeric value that gives the first time~$t$ when the path has
+the indicated direction. (If there is no such time, the result is
+$-1$). For example, if {\tt a} is the path drawn as a thin curve in
+Figure~\ref{fig24}, {\tt directiontime (1,1) of a} returns 0.2084.
-There is also an predefined macro \index{directionpoint of?\texttt{directionpoint of}}\label{Ddpntof}
+There is also an predefined macro \index{directionpoint
+of?\texttt{directionpoint of}}\label{Ddpntof}
$$ {\tt directionpoint}\, \descr{pair expression}\, {\tt of}\,
\descr{path primary}
$$
@@ -2019,13 +2352,13 @@ that finds the first point on a path where a given direction is achieved. The
{\tt directionpoint} macro produces an error message if the direction does not
occur on the path.
-Operators {\tt arclength}\index{arclength?\texttt{arclength}}\label{Darclng} and
-{\tt arctime of}\index{arctime of?\texttt{arctime of}}\label{Darctim} relate the ``time''
-on a path is related to the more familiar concept of
-arc length.\index{arc length}\footnote{The
-{\tt arclength} and {\tt arctime} operators are only found in MetaPost
-version 0.50 and higher.}
-The expression
+Operators {\tt
+arclength}\index{arclength?\texttt{arclength}}\label{Darclng} and {\tt
+arctime of}\index{arctime of?\texttt{arctime of}}\label{Darctim} relate
+the ``time'' on a path to the more familiar concept of arc
+length.\index{arc length}\footnote{The {\tt arclength} and {\tt arctime}
+operators are only found in MetaPost version 0.50 and higher.} The
+expression
$$ \hbox{{\tt arclength} \tdescr{path primary}} $$
gives the arc length of a path. If {\tt p} is a path and {\tt a} is a number
between 0 and {\tt arclength p},
@@ -2039,14 +2372,16 @@ $$ \hbox{\tt arclength subpath (0,t) of p} = {\tt a}. $$
Note how path {\tt fun} in Figure~\ref{fig25} is first constructed as
$$ \hbox{\verb|(0,-.1)..(1,.05){right}..(1.9,.02){right}..{curl .1}(3.2,.2)|} $$
-and then the {\tt yscaled}\index{yscaled?\texttt{yscaled}} and {\tt scaled}\index{scaled?\texttt{scaled}}
-operators are used to adjust the
-shape and size of the path. As the name suggests, an expression involving
-``{\tt yscaled 10}'' multiplies $y$ coordinates by ten so that every point $(x,y)$
-on the original path corresponds to a point $(x,10y)$ on the transformed path.
+and then the {\tt yscaled}\index{yscaled?\texttt{yscaled}} and {\tt
+scaled}\index{scaled?\texttt{scaled}} operators are used to adjust the
+shape and size of the path. As the name suggests, an expression
+involving ``{\tt yscaled 10}'' multiplies $y$ coordinates by ten so that
+every point $(x,y)$ on the original path corresponds to a point
+$(x,10y)$ on the transformed path.
Including {\tt scaled} and {\tt yscaled}, there are seven transformation
-operators that take a numeric or pair argument:\index{shifted?\texttt{shifted}}%
+operators that take a numeric or pair
+argument:\index{shifted?\texttt{shifted}}%
\index{rotated?\texttt{rotated}}\index{slanted?\texttt{slanted}}\index{scaled?\texttt{scaled}}\index{xscaled?\texttt{xscaled}}%
\index{yscaled?\texttt{yscaled}}\index{zscaled?\texttt{zscaled}}\label{Dtranop}
\begin{eqnarray*}
@@ -2059,17 +2394,20 @@ operators that take a numeric or pair argument:\index{shifted?\texttt{shifted}}%
(x,y){\tt\ yscaled\ }a &=& (x,\, ay); \\
(x,y){\tt\ zscaled\ }(a,b) &=& (ax-by,\, bx+ay).
\end{eqnarray*}
-Most of these operations are self-explanatory except for {\tt zscaled} which can
-be thought of as multiplication of complex numbers. The effect of {\tt zscaled}
-$(a,b)$ is to rotate and scale so as to map $(1,0)$ into $(a,b)$. The effect of
-{\tt rotated}~$\theta$ is rotate $\theta$ degrees counter-clockwise.
-
-Any combination of shifting, rotating, slanting, etc.\ is an affine transformation,
-the net effect of which is to transform any pair $(x,y)$ into
+Most of these operations are self-explanatory except for {\tt zscaled}
+which can be thought of as multiplication of complex numbers. The
+effect of {\tt zscaled} $(a,b)$ is to rotate and scale so as to map
+$(1,0)$ into $(a,b)$. The effect of {\tt rotated}~$\theta$ is rotate
+$\theta$ degrees counter-clockwise.
+
+Any combination of shifting, rotating, slanting, etc.\ is an affine
+transformation, the net effect of which is to transform any pair $(x,y)$
+into
$$ (t_x+t_{xx}x+t_{xy}y,\, t_y+t_{yx}x+t_{yy}y), $$
-for some sextuple $(t_x,t_y,t_{xx},t_{xy},t_{yx},t_{yy})$. This information can
-be stored in a variable of type transform so that
-{\tt transformed T}\index{transformed?\texttt{transformed}}\label{Dtrfrmd} might be equivalent to
+for some sextuple $(t_x,t_y,t_{xx},t_{xy},t_{yx},t_{yy})$. This
+information can be stored in a variable of type transform so that {\tt
+transformed T}\index{transformed?\texttt{transformed}}\label{Dtrfrmd}
+might be equivalent to
$$ \hbox{\tt xscaled -1 rotated 90 shifted (1,1)} $$
if {\tt T} is an appropriate transform variable. The
transform~{\tt T} could then be initialized with an
@@ -2079,21 +2417,24 @@ transform T;
T = identity xscaled -1 rotated 90 shifted (1,1);
\end{verbatim}
$$
-As this example indicates, transform expressions can be built up by applying
-transformation operators to other transforms. The predefined transformation
-{\tt identity}\index{identity?\texttt{identity}}\label{Dident} is a useful starting point
-for this process.
-This can be illustrated by paraphrasing the above equation for {\tt T} into
-English: ``{\tt T} should be the transform obtained by doing whatever
-{\tt identity} does, then scaling $x$~coordinates by $-1$, rotating $45^\circ$,
-and shifting by $(1,1)$.'' This works because {\tt identity} is the identity
-transformation which does nothing; i.e., {\tt transformed identity} is a no-op.
+As this example indicates, transform expressions can be built up by
+applying transformation operators to other transforms. The predefined
+transformation {\tt
+identity}\index{identity?\texttt{identity}}\label{Dident} is a useful
+starting point for this process. This can be illustrated by
+paraphrasing the above equation for {\tt T} into English: ``{\tt T}
+should be the transform obtained by doing whatever {\tt identity}
+does. Then scaling $x$~coordinates by $-1$, rotating $45^\circ$, and
+shifting by $(1,1)$.'' This works because {\tt identity} is the
+identity transformaion which does nothing; i.e., {\tt transformed
+identity} is a no-op.
The syntax for transform expressions and transformation operators is given in
Figure~\ref{sytrans}. It includes two more options for
\tdescr{transformer}:\index{reflectedabout?\texttt{reflectedabout}}
$$ \hbox{\tt reflectededabout(}p, q\hbox{\tt )} $$
-reflects about the line defined by points $p$ and $q$; and\index{rotatedaround?\texttt{rotatedaround}}
+reflects about the line defined by points $p$ and $q$;
+and\index{rotatedaround?\texttt{rotatedaround}}
$$ \hbox{\tt rotatedaround(}p,\theta\hbox{\tt )} $$
rotates $\theta$ degrees counter-clockwise around point $p$. For example,
the equation for initializing transform~{\tt T} could have been
@@ -2122,16 +2463,16 @@ $\tt \qquad \;|\; zscaled \descr{pair primary}$\\
$\tt \qquad \;|\; reflectedabout\hbox{\tt (}\descr{pair expression}
\hbox{\tt ,}\descr{pair expression}\hbox{\tt )}$\\
$\tt \qquad \;|\; rotatedaround\hbox{\tt (}\descr{pair expression}
- \hbox{\tt ,}\descr{numeric expression}\hbox{\tt )}$\\
+ \hbox{\tt ,}\descr{numeric expression}\hbox{\tt )}$
\end{ctabbing}
\caption{The syntax for transforms and related operators}
\label{sytrans}
\end{figure}
-There is also a unary operator {\tt inverse}\index{inverse?\texttt{inverse}}\label{Dinv}
-that takes a
-transform and finds another transform that undoes the effect of the first
-transform. Thus if
+There is also a unary operator {\tt
+inverse}\index{inverse?\texttt{inverse}}\label{Dinv} that takes a
+transform and finds another transform that undoes the effect of the
+first transform. Thus if
$$ p = q{\tt\ transformed\ }T $$
then
$$ q = p{\tt\ transformed\ inverse\ }T. $$
@@ -2140,10 +2481,10 @@ It is not legal to take the {\tt inverse} of an
unknown transform\index{transformation!unknown} but we
have already seen that you can say
$$ \hbox{\tt T = } \descr{transform expression} $$
-when {\tt T} has not been given a value yet. It is also possible to apply
-an unknown transform to a known pair or transform and use the result in a linear
-equation. Three such equations are sufficient to determine a transform. Thus
-the equations
+when {\tt T} has not been given a value yet. It is also possible to
+apply an unknown transform to a known pair or transform and use the
+result in a linear equation. Three such equations are sufficient to
+determine a transform. Thus the equations
$$ \begin{verbatim}
(0,1) transformed T' = (3,4);
(1,1) transformed T' = (7,1);
@@ -2164,9 +2505,10 @@ $$\openup\jot
t_x&=0,& t_y&=0.\cr}
$$
-Equations involving an unknown transform are treated as linear equations in the
-six parameters that define the transform. These six parameters can also be
-referred to directly as\index{xpart?\texttt{xpart}}\index{ypart?\texttt{ypart}}\index{xxpart?\texttt{xxpart}}%
+Equations involving an unknown transform are treated as linear equations
+in the six parameters that define the transform. These six parameters
+can also be referred to directly
+as\index{xpart?\texttt{xpart}}\index{ypart?\texttt{ypart}}\index{xxpart?\texttt{xxpart}}%
\index{xypart?\texttt{xypart}}\index{yxpart?\texttt{yxpart}}\index{yypart?\texttt{yypart}}\label{Dtrprt}
$$ {\tt xpart\ T},\ {\tt ypart\ T},\ {\tt xxpart\ T},\ {\tt xypart\ T},\
{\tt yxpart\ T},\ {\tt yypart\ T},
@@ -2201,7 +2543,7 @@ endfor
dotlabels.top(1,2,3); dotlabels.bot(4);
endfig;
\end{verbatim}
-\quad \mathcenter{\epsfbox{manfig.28}}
+\quad \mathcenter{\includegraphics{manfig-28}}
$$
\caption{MetaPost code and the resulting ``fractal'' figure}
\label{fig27}
@@ -2210,50 +2552,56 @@ $$
\subsection{Dashed Lines}
-The MetaPost language provides many ways of changing the appearance of a line
-besides just changing its width. One way is to use dashed lines as was done in
-Figures \ref{fig4} and~\ref{fig22}. The syntax for this is\index{dashed?\texttt{dashed}}
+The MetaPost language provides many ways of changing the appearance of a
+line besides just changing its width. One way is to use dashed lines as
+was done in Figures \ref{fig4} and~\ref{fig22}. The syntax for this
+is\index{dashed?\texttt{dashed}}
$$ {\tt draw}\, \descr{path expression}\, {\tt dashed}\, \descr{dash pattern} $$
-where a \tdescr{dash pattern}\index{dash pattern?\tdescr{dash pattern}} is really a special
-type of \tdescr{picture expression}. There is a predefined \tdescr{dash pattern}
-called {\tt evenly}\index{evenly?\texttt{evenly}}\label{Devenly} that makes dashes 3 PostScript
-points long separated by gaps of the same size.
-Another predefined dash pattern {\tt withdots}\index{withdots?\texttt{withdots}}\label{Dwdots}
-produces dotted lines with dots 5 PostScript points apart.\footnote{{\tt withdots}
-is only found in MetaPost version 0.50 and higher.}
-For dots further apart or longer dashes further apart, the
-\tdescr{dash pattern} can be
-scaled\index{scaled?\texttt{scaled}} as shown in Figure~\ref{fig28}
+where a \tdescr{dash pattern}\index{dash pattern?\tdescr{dash pattern}}
+is really a special type of \tdescr{picture expression}. There is a
+predefined \tdescr{dash pattern} called {\tt
+evenly}\index{evenly?\texttt{evenly}}\label{Devenly} that makes dashes 3
+PostScript points long separated by gaps of the same size. Another
+predefined dash pattern {\tt
+withdots}\index{withdots?\texttt{withdots}}\label{Dwdots} produces
+dotted lines with dots 5 PostScript points apart.\footnote{{\tt
+withdots} is only found in MetaPost version 0.50 and higher.} For dots
+further apart or longer dashes further apart, the \tdescr{dash pattern}
+can be scaled\index{scaled?\texttt{scaled}} as shown in
+Figure~\ref{fig28}.
\begin{figure}[htp]
-$$ \epsfbox{manfig.29} $$
+$$ \includegraphics{manfig-29} $$
\caption[Dashed lines and the corresponding dash patters]
{Dashed lines each labeled with the \tdescr{dash pattern} used to create
it.}
\label{fig28}
\end{figure}
-Another way to change a dash pattern is to alter its phase by shifting it
-horizontally. Shifting to the right makes the dashes move forward along the
-path and shifting to the left moves them backward. Figure~\ref{fig29} illustrates
-this effect. The dash pattern can be thought of as an infinitely repeating pattern
-strung out along a horizontal line where the portion of the line to the right of
-the $y$~axis is laid out along the path to be dashed\index{dash pattern?\tdescr{dash pattern}}.
+Another way to change a dash pattern is to alter its phase by shifting
+it horizontally. Shifting to the right makes the dashes move forward
+along the path and shifting to the left moves them backward.
+Figure~\ref{fig29} illustrates this effect. The dash pattern can be
+thought of as an infinitely repeating pattern strung out along a
+horizontal line where the portion of the line to the right of the
+$y$~axis is laid out along the path to be dashed\index{dash
+pattern?\tdescr{dash pattern}}.
\begin{figure}[htp]
-$$ \epsfbox{manfig.30} $$
+$$ \includegraphics{manfig-30} $$
\caption[Dashed lines and the corresponding dash patters]
{Dashed lines and the MetaPost statements for drawing them where {\tt e4}
refers to the dash pattern {\tt evenly scaled 4}.}
\label{fig29}
\end{figure}
-When you shift a dash pattern so that the $y$~axis crosses the middle of a dash,
-the first dash gets truncated. Thus the line with dash pattern {\tt e4} starts
-with a dash of length 12bp followed by a 12bp gap and another 12bp dash, etc.,
-while {\tt e4 shifted (-6bp,0)} produces a 6bp dash, a 12 bp gap, then a
-12bp dash, etc. This dash pattern could be specified more directly via the
-{\tt dashpattern}\index{dash pattern?\texttt{dash pattern}}\label{Ddshpat} function:
+When you shift a dash pattern so that the $y$~axis crosses the middle of
+a dash, the first dash gets truncated. Thus the line with dash pattern
+{\tt e4} starts with a dash of length 12bp followed by a 12bp gap and
+another 12bp dash, etc., while {\tt e4 shifted (-6bp,0)} produces a 6bp
+dash, a 12 bp gap, then a 12bp dash, etc. This dash pattern could be
+specified more directly via the {\tt dashpattern}\index{dash
+pattern?\texttt{dash pattern}}\label{Ddshpat} function:
$$ \hbox{\tt dashpattern(on 6bp off 12bp on 6bp)} $$
This means ``draw the first 6bp of the line, then skip the next 12bp, then draw
another 6bp and repeat.'' If the line to be dashed is more than 30bp long, the
@@ -2274,24 +2622,26 @@ $\tt \descr{on/off clause} \rightarrow on \descr{numeric tertiary}
\label{sydash}
\end{figure}
-Since a dash pattern is really just a special kind of picture, the
-{\tt dashpattern} function returns a picture. It is not really necessary to know
-the structure of such a picture, so the casual reader will probably want to skip
-on to Section~\ref{oopt}. For those who want to know, a little experimentation
-shows that if {\tt d} is
+Since a dash pattern is really just a special kind of picture, the {\tt
+dashpattern} function returns a picture. It is not really necessary to
+know the structure of such a picture, so the casual reader will probably
+want to skip on to Section~\ref{oopt}. For those who want to know, a
+little experimentation shows that if {\tt d} is
$$ \hbox{\tt dashpattern(on 6bp off 12bp on 6bp)}, $$
-then {\tt llcorner d} is $(0,24)$ and {\tt urcorner d} is $(24,24)$. Drawing
-{\tt d} directly without using it as a dash pattern produces two thin horizontal
-line segments like this:
-$$ \epsfbox{manfig.31} $$
-The lines in this example are specified as having width zero, but this does not
-matter because the line width is ignored when a picture is used as a dash pattern.
-
-The general rule for interpreting a picture {\tt d} as a dash pattern is that
-the line segments in {\tt d} are projected onto the $x$-axis and the resulting
-pattern is replicated to infinity in both directions by placing copies of the
-pattern end-to-end. The actual dash lengths are obtained by starting at $x=0$
-and scanning in the positive $x$ direction.
+then {\tt llcorner d} is $(0,24)$ and {\tt urcorner d} is $(24,24)$.
+Drawing {\tt d} directly without using it as a dash pattern produces two
+thin horizontal line segments like this:
+$$ \includegraphics{manfig-31} $$
+The lines in this example are specified as having width zero, but this
+does not matter because the line width is ignored when a picture is used
+as a dash pattern.
+
+The general rule for interpreting a picture {\tt d} as a dash pattern is
+that the line segments in {\tt d} are projected onto the $x$-axis and
+the resulting pattern is replicated to infinity in both directions by
+placing copies of the pattern end-to-end. The actual dash lengths are
+obtained by starting at $x=0$ and scanning in the positive $x$
+direction.
To make the idea of ``replicating to infinity'' more precise, let $P({\tt d})$
be the projection of {\tt d} onto the $x$~axis, and let
@@ -2304,14 +2654,14 @@ where $[d_{\rm min},d_{\rm max}]$
is the range of $x$~coordinates in $P(d)$. In fact, MetaPost uses
$$ \max(\left|y_0({\tt d})\right|,\, d_{\rm max}-d_{\rm min}), $$
where $y_0({\tt d})$ is the $y$ coordinate of the contents of {\tt d}.
-The contents of {\tt d} should lie on a horizontal line, but if they do not,
-the MetaPost interpreter just picks
-a $y$~coordinate that occurs in {\tt d}\index{dash pattern?\tdescr{dash pattern}}.
+The contents of {\tt d} should lie on a horizontal line, but if they do
+not, the MetaPost interpreter just picks a $y$~coordinate that occurs in
+{\tt d}\index{dash pattern?\tdescr{dash pattern}}.
-A picture used as a dashed pattern must contain no text or filled regions,
-but it can contain lines that are themselves dashed. This can give small dashes
-inside of larger dashes as shown in
-Figure~\ref{fig32}\index{dash pattern?\tdescr{dash pattern}!recursive}
+A picture used as a dashed pattern must contain no text or filled
+regions, but it can contain lines that are themselves dashed. This can
+give small dashes inside of larger dashes as shown in
+Figure~\ref{fig32}.\index{dash pattern?\tdescr{dash pattern}!recursive}
\begin{figure}[htp]
$$\begin{verbatim}
@@ -2323,37 +2673,61 @@ currentpicture:=nullpicture;
draw fullcircle scaled 1cm xscaled 3 dashed p;
endfig;
\end{verbatim}
-\quad \mathcenter{\epsfbox{manfig.32}}
+\quad \mathcenter{\includegraphics{manfig-32}}
$$
-\caption{MetaPost code and the corresponding output}
+\caption{MetaPost code for dashed patterns and the corresponding output}
\label{fig32}
\end{figure}
+\label{dashed-pens}
+Also, dashed patterns are intended to be used either with {\tt
+pencircle} or no pen at all; {\tt pensquare} and other complex pens
+should be avoided. This is because the output uses the PostScript
+primitive {\tt setdash}, which does not interact well with the filled
+paths created by polygonal pens. See Section~\ref{sec.pens}, p.\
+\pageref{sec.pens}.
+
+%\newpage
+
+\subsection{Local specials}
+
+If you want to attach a special bit of PostScript code, you can use
+$$
+{\tt withprescript} \descr{string expression}
+$$
+and
+$$
+{\tt withpostcript} \descr{string expression}
+$$
+the strings will be written to the output file before and after the
+current object, each beginning on their own line. You can specify
+multiple {\tt withprescript} or {\tt withpostscript} options if you
+like.
\subsection{Other Options}
\label{oopt}
-You might have noticed that the dashed lines produced by
-{\tt dashed evenly}\index{evenly?\texttt{evenly}} appear
-to have more black than white. This is an effect of the
-{\tt linecap}\index{linecap?\texttt{linecap}}\label{Dlinecap} parameter
-that controls the appearance of the ends of lines as well as the ends of dashes.
-There are also a number of other ways to affect the appearance of things drawn
-with MetaPost.
-
-The {\tt linecap} parameter has three different settings just as in PostScript.
-Plain MetaPost gives this
-internal variable\index{internal variables}\index{variables!internal} the
-default value {\tt rounded}\index{rounded?\texttt{rounded}}
-which causes line segments to be drawn with rounded ends like the segment from
-{\tt z0} to {\tt z3} in Figure~\ref{fig33}. Setting
-${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt butt}$\index{butt?\texttt{butt}}\label{Dbutt}
-cuts the ends off
-flush so that dashes produced by {\tt dashed evenly}\index{evenly?\texttt{evenly}} have
-length 3bp, not 3bp plus the line width. You can also get squared-off ends
-that extend past the specified endpoints by setting
-${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt squared}$\index{squared?\texttt{squared}}\label{Dsqred}
-as was done in the line from {\tt z2} to {\tt z5} in Figure~\ref{fig33}.
+You might have noticed that the dashed lines produced by {\tt dashed
+evenly}\index{evenly?\texttt{evenly}} appear to have more black than
+white. This is an effect of the {\tt
+linecap}\index{linecap?\texttt{linecap}}\label{Dlinecap} parameter that
+controls the appearance of the ends of lines as well as the ends of
+dashes. There are also a number of other ways to affect the appearance
+of things drawn with MetaPost.
+
+The {\tt linecap} parameter has three different settings just as in
+PostScript. Plain MetaPost gives this internal variable\index{internal
+variables}\index{variables!internal} the default value {\tt
+rounded}\index{rounded?\texttt{rounded}} which causes line segments to
+be drawn with rounded ends like the segment from {\tt z0} to {\tt z3} in
+Figure~\ref{fig33}. Setting ${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt
+butt}$\index{butt?\texttt{butt}}\label{Dbutt} cuts the ends off flush so
+that dashes produced by {\tt dashed
+evenly}\index{evenly?\texttt{evenly}} have length 3bp, not 3bp plus the
+line width. You can also get squared-off ends that extend past the
+specified endpoints by setting ${\tt linecap}\mathrel{\hbox{\tt:=}}{\tt
+squared}$\index{squared?\texttt{squared}}\label{Dsqred} as was done in
+the line from {\tt z2} to {\tt z5} in Figure~\ref{fig33}.
\begin{figure}[htp]
$$\begin{verbatim}
@@ -2371,20 +2745,21 @@ dotlabels.top(0,1,2,3,4,5);
endfig; linecap:=rounded;
\end{verbatim}
\qquad
-\mathcenter{\epsfbox{manfig.33}}
+\mathcenter{\includegraphics{manfig-33}}
$$
\caption{MetaPost code and the corresponding output}
\label{fig33}
\end{figure}
-Another parameter borrowed from PostScript affects the way a {\tt draw} statement
-treats sharp corners\index{corners} in the path to be drawn.
-The {\tt linejoin}\index{linejoin?\texttt{linejoin}}\label{Dlinejoin} parameter can
-be {\tt rounded}\index{rounded?\texttt{rounded}}\label{Drnded},
-{\tt beveled}\index{beveled?\texttt{beveled}}\label{Dbvled},
-or {\tt mitered}\index{mitered?\texttt{mitered}}\label{Dmitred} as shown in Figure~\ref{fig34}.
-The default value for plain MetaPost is {\tt rounded} which gives the effect of
-drawing with a circular brush.
+Another parameter borrowed from PostScript affects the way a {\tt draw}
+statement treats sharp corners\index{corners} in the path to be drawn.
+The {\tt linejoin}\index{linejoin?\texttt{linejoin}}\label{Dlinejoin}
+parameter can be {\tt
+rounded}\index{rounded?\texttt{rounded}}\label{Drnded}, {\tt
+beveled}\index{beveled?\texttt{beveled}}\label{Dbvled}, or {\tt
+mitered}\index{mitered?\texttt{mitered}}\label{Dmitred} as shown in
+Figure~\ref{fig34}. The default value for plain MetaPost is {\tt
+rounded} which gives the effect of drawing with a circular brush.
\begin{figure}[htp]
$$\begin{verbatim}
@@ -2403,37 +2778,39 @@ dotlabels.bot(0,1,2,3,4,5,6,7,8);
endfig; linejoin:=rounded;
\end{verbatim}
\qquad
-\mathcenter{\epsfbox{manfig.34}}
+\mathcenter{\includegraphics{manfig-34}}
$$
\caption{MetaPost code and the corresponding output}
\label{fig34}
\end{figure}
-When {\tt linejoin} is {\tt mitered}, sharp corners generate long pointed features
-as shown in Figure~\ref{fig35}. Since this might be undesirable, there is an
-internal variable\index{internal variables}\index{variables!internal}
-called {\tt miterlimit}\index{miterlimit?\texttt{miterlimit}}\label{Dmiterlim} that controls how
-extreme the situation can get before the mitered join is replaced by a beveled
-join. For Plain MetaPost, {\tt miterlimit} has a default value of 10.0 and line
-joins revert to beveled when the ratio of miter length to line width
-reaches this value.
+When {\tt linejoin} is {\tt mitered}, sharp corners generate long
+pointed features as shown in Figure~\ref{fig35}. Since this might be
+undesirable, there is an internal variable\index{internal
+variables}\index{variables!internal} called {\tt
+miterlimit}\index{miterlimit?\texttt{miterlimit}}\label{Dmiterlim} that
+controls how extreme the situation can get before the mitered join is
+replaced by a beveled join. For Plain MetaPost, {\tt miterlimit} has a
+default value of 10.0 and line joins revert to beveled when the ratio of
+miter length to line width reaches this value.
\begin{figure}[htp]
-$$ \epsfbox{manfig.35} $$
+$$ \includegraphics{manfig-35} $$
\caption{The miter length and line width whose ratio is limited by
{\tt miterlimit}.}
\label{fig35}
\end{figure}
-The {\tt linecap}, {\tt linejoin}, and {\tt miterlimit} parameters are especially
-important because they also affect things that get drawn behind the scenes.
-For instance, Plain MetaPost has statements for drawing
-arrows\index{arrows}, and the arrowheads are slightly rounded when {\tt linejoin}
-is {\tt rounded}. The effect depends on the line width and is quite subtle at the
-default line width of 0.5bp as shown in Figure~\ref{fig36}.
+The {\tt linecap}, {\tt linejoin}, and {\tt miterlimit} parameters are
+especially important because they also affect things that get drawn
+behind the scenes. For instance, Plain MetaPost has statements for
+drawing arrows\index{arrows}, and the arrowheads are slightly rounded
+when {\tt linejoin} is {\tt rounded}. The effect depends on the line
+width and is quite subtle at the default line width of 0.5bp as shown in
+Figure~\ref{fig36}.
\begin{figure}[htp]
-$$\epsfbox{manfig.36}$$
+$$\includegraphics{manfig-36}$$
\caption{Three ways of drawing arrows.}
\label{fig36}
\end{figure}
@@ -2441,87 +2818,91 @@ $$\epsfbox{manfig.36}$$
Drawing arrows like the ones in Figure~\ref{fig36} is simply a matter of
saying\index{drawarrow?\texttt{drawarrow}}\label{Ddrwarr}
$$ {\tt drawarrow}\, \descr{path expression} $$
-instead of {\tt draw} \tdescr{path expression}. This draws the given path with
-an arrowhead at the last point on the path. If you want the arrowhead at the
-beginning of the path, just use the unary operator
-{\tt reverse}\index{reverse?\texttt{reverse}}\label{Drevrse} to take the
-original path and make a new one with its time sense reversed; i.e., for a
-path~{\tt p} with {\tt length p}${}=n$,
+instead of {\tt draw} \tdescr{path expression}. This draws the given
+path with an arrowhead at the last point on the path. If you want the
+arrowhead at the beginning of the path, just use the unary operator {\tt
+reverse}\index{reverse?\texttt{reverse}}\label{Drevrse} to take the
+original path and make a new one with its time sense reversed; i.e., for
+a path~{\tt p} with {\tt length p}${}=n$,
$$ {\tt point\ } t {\tt\ of\ reverse\ p}
\quad {\rm and} \quad
{\tt point\ } n-t {\tt\ of\ p}
$$ are synonymous.
-As shown in Figure~\ref{fig36}, a statement beginning\index{drawdblarrow?\texttt{drawdblarrow}}%
+As shown in Figure~\ref{fig36}, a statement
+beginning\index{drawdblarrow?\texttt{drawdblarrow}}%
\index{arrows!double-headed}\label{Ddrwdar}
$$ {\tt drawdblarrow}\, \descr{path expression} $$
-draws a double-headed arrow. The size of the arrowhead is guaranteed to be
-larger than the line width, but it might need adjusting if the line width is
-very great. This is done by assigning a new value to the
+draws a double-headed arrow. The size of the arrowhead is guaranteed to
+be larger than the line width, but it might need adjusting if the line
+width is very great. This is done by assigning a new value to the
internal variable\index{internal variables}\index{variables!internal}
-{\tt ahlength}\index{ahlength?\texttt{ahlength}}\label{Dahlength}
-that determines arrowhead length as shown in Figure~\ref{fig37}.
-Increasing {\tt ahlength} from the default value of 4 PostScript points to
-1.5 centimeters produces the large arrowhead in Figure~\ref{fig37}. There
+{\tt ahlength}\index{ahlength?\texttt{ahlength}}\label{Dahlength} that
+determines arrowhead length as shown in Figure~\ref{fig37}. Increasing
+{\tt ahlength} from the default value of 4 PostScript points to 1.5
+centimeters produces the large arrowhead in Figure~\ref{fig37}. There
is also an {\tt ahangle}\index{ahangle?\texttt{ahangle}}\label{Dahangle}
-parameter that controls the angle
-at the tip of the arrowhead. The default value of this angle is 45 degrees
-as shown in the figure.
+parameter that controls the angle at the tip of the arrowhead. The
+default value of this angle is 45 degrees as shown in the figure.
\begin{figure}[htp]
-$$ \epsfbox{manfig.37} $$
+$$ \includegraphics{manfig-37} $$
\caption[A large arrowhead with key parameters labeled.]
{A large arrowhead with key parameters labeled and paths used to
draw it marked with white lines.}
\label{fig37}
\end{figure}
-The arrowhead is created by filling the triangular region that is outlined
-in white in Figure~\ref{fig37} and then drawing around it with the currently
-picked up pen. This combination of filling and drawing can be combined into
-a single {\tt filldraw} statement\index{filldraw?\texttt{filldraw}}\label{Dfildrw}:
+The arrowhead is created by filling the triangular region that is
+outlined in white in Figure~\ref{fig37} and then drawing around it with
+the currently picked up pen. This combination of filling and drawing
+can be combined into a single {\tt filldraw}
+statement\index{filldraw?\texttt{filldraw}}\label{Dfildrw}:
$$ {\tt filldraw}\, \descr{path expression}\,
\descr{optional {\tt dashed} and {\tt withcolor} and {\tt withpen} clauses};
$$
-The \tdescr{path expression} should be a closed cycle like the triangular path
-in Figure~\ref{fig37}. This path should not be confused with the path argument
-to {\tt drawarrow} which is indicated by a white line in the figure.
-
-White lines like the ones in the figure can be created by an
-{\tt undraw}\index{undraw?\texttt{undraw}}\label{Dundraw} statement.
-This is an erasing\index{erasing}
-version of {\tt draw} that draws {\tt withcolor background}\index{background?\texttt{background}}
-just as the {\tt unfill} statement does. There is also an
-{\tt unfilldraw}\index{unfilldraw?\texttt{unfilldraw}}\label{Dunfdrw}
-statement just in case someone finds a
-use for it.
-
-The {\tt filldraw}, {\tt undraw} and {\tt unfilldraw} statements and all the
-arrow drawing statements are like the {\tt fill} and {\tt draw} statements in that
-they take {\tt dashed}\index{dashed?\texttt{dashed}}, {\tt withpen}\index{withpen?\texttt{withpen}},
-and {\tt withcolor}\index{withcolor?\texttt{withcolor}} options.
-When you have a lot of drawing statements it is
-nice to be able to apply an option such as {\tt withcolor 0.8white} to all of
-them without having to type this repeatedly as was done in Figures \ref{fig33}
-and~\ref{fig34}. The statement for this purpose is\index{drawoptions?\texttt{drawoptions}}\label{Ddropts}
+The \tdescr{path expression} should be a closed cycle like the
+triangular path in Figure~\ref{fig37}. This path should not be confused
+with the path argument to {\tt drawarrow} which is indicated by a white
+line in the figure.
+
+White lines like the ones in the figure can be created by an {\tt
+undraw}\index{undraw?\texttt{undraw}}\label{Dundraw} statement. This is
+an erasing\index{erasing} version of {\tt draw} that draws {\tt
+withcolor background}\index{background?\texttt{background}} just as the
+{\tt unfill} statement does. There is also an {\tt
+unfilldraw}\index{unfilldraw?\texttt{unfilldraw}}\label{Dunfdrw}
+statement just in case someone finds a use for it.
+
+The {\tt filldraw}, {\tt undraw} and {\tt unfilldraw} statements and all
+the arrow drawing statements are like the {\tt fill} and {\tt draw}
+statements in that they take {\tt dashed}\index{dashed?\texttt{dashed}},
+{\tt withpen}\index{withpen?\texttt{withpen}}, and {\tt
+withcolor}\index{withcolor?\texttt{withcolor}} options. When you have a
+lot of drawing statements it is nice to be able to apply an option such
+as {\tt withcolor 0.8white} to all of them without having to type this
+repeatedly as was done in Figures \ref{fig33} and~\ref{fig34}. The
+statement for this purpose
+is\index{drawoptions?\texttt{drawoptions}}\label{Ddropts}
$$ \hbox{\tt drawoptions(} \descr{text} \hbox{\tt )} $$
-where the \tdescr{text} argument gives a sequence of {\tt dashed}, {\tt withcolor},
-and {\tt withpen} options to be applied automatically to all drawing statements.
-If you specify
+where the \tdescr{text} argument gives a sequence of {\tt dashed}, {\tt
+withcolor}, and {\tt withpen} options to be applied automatically to all
+drawing statements. If you specify
$$ \hbox{\tt drawoptions(withcolor .5[black,white])} $$
and then want to draw a black line, you can override the {\tt drawoptions}
by specifying
$$ {\tt draw}\, \descr{path expression}\, {\tt withcolor\ black} $$
To turn off {\tt drawoptions} all together, just give an empty list:
$$ \hbox{\tt drawoptions()} $$
-(This is done automatically by the {\tt beginfig}\index{beginfig?\texttt{beginfig}} macro).
+(This is done automatically by the {\tt
+beginfig}\index{beginfig?\texttt{beginfig}} macro).
Since irrelevant options are ignored, there is no harm in giving a statement
like
$$ \hbox{\tt drawoptions(dashed evenly)} $$
-followed by a sequence of {\tt draw} and {\tt fill} commands. It does not make
-sense to use a dash pattern when filling so the {\tt dashed evenly} gets ignored
-for {\tt fill} statements. It turns out that
+followed by a sequence of {\tt draw} and {\tt fill} commands. It does
+not make sense to use a dash pattern when filling so the {\tt dashed
+evenly} gets ignored for {\tt fill} statements. It turns out that
$$ \hbox{\tt drawoptions(withpen } \descr{pen expression} \hbox{\tt )} $$
does affect {\tt fill} statements as well as {\tt draw} statements.
In fact there is a special pen variable called
@@ -2529,33 +2910,37 @@ In fact there is a special pen variable called
{\tt fill} \ldots\ {\tt withpen currentpen} is equivalent to a {\tt filldraw}
statement.
-Precisely what does it mean to say that drawing options affect those statements
-where they make sense? The {\tt dashed} \tdescr{dash pattern} option only affects
+Precisely what does it mean to say that drawing options affect those
+statements where they make sense? The {\tt dashed} \tdescr{dash
+pattern} option only affects
$$ {\tt draw}\, \descr{path expression} $$
statements, and text appearing in the \tdescr{picture expression} argument to
$$ {\tt draw}\, \descr{picture expression} $$
-statement is only affected by the {\tt withcolor} \tdescr{color expression} option.
-For all other combinations of drawing statements and options, there is some effect.
-An option applied to a {\tt draw} \tdescr{picture expression} statement will in
-general affect some parts of the picture but not others. For instance,
-a {\tt dashed} or {\tt withpen} option will affect all the lines in the picture
-but none of the labels.
+statement is only affected by the {\tt withcolor} \tdescr{color
+expression} option. For all other combinations of drawing statements
+and options, there is some effect. An option applied to a {\tt draw}
+\tdescr{picture expression} statement will in general affect some parts
+of the picture but not others. For instance, a {\tt dashed} or {\tt
+withpen} option will affect all the lines in the picture but none of the
+labels.
\subsection{Pens}
+\label{sec.pens}
Previous sections have given numerous examples of {\tt pickup}
-\tdescr{pen expression} and {\tt withpen} \tdescr{pen expression}, but there have
-not been any examples of pen expressions other than
+\tdescr{pen expression} and {\tt withpen} \tdescr{pen expression}, but
+there have not been any examples of pen expressions other than
$$ {\tt pencircle\ scaled}\, \descr{numeric primary} $$
-which produces lines of a specified width. For calligraphic effects such in
-Figure~\ref{fig38}, you can apply any of the transformation operators discussed
-in Section~\ref{transsec}. The starting point for such transformations is
-{\tt pencircle}\index{pencircle?\texttt{pencircle}}\label{Dpncirc},
-a circle one PostScript point in diameter. Thus affine
-transformations produce a circular or elliptical\index{pens!elliptical} pen shape.
-The width of lines drawn with the pen depends on how nearly perpendicular the line
-is to the long axis of the ellipse.
+which produces lines of a specified width. For calligraphic effects
+such in Figure~\ref{fig38}, you can apply any of the transformation
+operators discussed in Section~\ref{transsec}. The starting point for
+such transformations is {\tt
+pencircle}\index{pencircle?\texttt{pencircle}}\label{Dpncirc}, a circle
+one PostScript point in diameter. Thus affine transformations produce a
+circular or elliptical\index{pens!elliptical} pen shape. The width of
+lines drawn with the pen depends on how nearly perpendicular the line is
+to the long axis of the ellipse.
\begin{figure}[htp]
$$\begin{verbatim}
@@ -2575,68 +2960,76 @@ draw z0--z1--z2--z3--z4--z5--z6 withcolor .7white;
dotlabels.top(0,1,2,3,4,5,6);
endfig;
\end{verbatim}
-\quad \mathcenter{\epsfbox{manfig.38}}
+\quad \mathcenter{\includegraphics{manfig-38}}
$$
\caption{MetaPost code and the resulting ``calligraphic'' figure.}
\label{fig38}\index{lft?\texttt{lft}}\index{bot?\texttt{bot}}\index{top?\texttt{top}}
\end{figure}
-Figure~\ref{fig38} demonstrates operators {\tt lft}\index{lft?\texttt{lft}}\label{Dlft},
-{\tt rt}\index{rt?\texttt{rt}}\label{Drt}, {\tt top}\index{top?\texttt{top}}\label{Dtop},
-and {\tt bot}\index{bot?\texttt{bot}}\label{Dbot}
-that answer the question, ``If the current pen is placed at the position
-given by the argument, where will its left, right, top, or bottom edge be?''
-In this case the current pen is the ellipse given in the {\tt pickup} statement
-and its bounding box is 0.1734 inches wide and 0.1010 inches high, so
-{\tt rt x3} is ${\tt x3}+{\tt 0.0867in}$ and {\tt bot y5} is
-${\tt y5}-{\tt 0.0505in}$.
-The {\tt lft}, {\tt rt}, {\tt top}, and {\tt bot} operators also accept arguments
-of type pair in which case they compute the $x$ and~$y$ coordinates of the
-leftmost, rightmost, topmost, or bottommost point on the pen shape. For example,
+Figure~\ref{fig38} demonstrates operators {\tt
+lft}\index{lft?\texttt{lft}}\label{Dlft}, {\tt
+rt}\index{rt?\texttt{rt}}\label{Drt}, {\tt
+top}\index{top?\texttt{top}}\label{Dtop}, and {\tt
+bot}\index{bot?\texttt{bot}}\label{Dbot} that answer the question, ``If
+the current pen is placed at the position given by the argument, where
+will its left, right, top, or bottom edge be?'' In this case the
+current pen is the ellipse given in the {\tt pickup} statement and its
+bounding box is 0.1734 inches wide and 0.1010 inches high, so {\tt rt
+x3} is ${\tt x3}+{\tt 0.0867in}$ and {\tt bot y5} is ${\tt y5}-{\tt
+0.0505in}$. The {\tt lft}, {\tt rt}, {\tt top}, and {\tt bot} operators
+also accept arguments of type pair in which case they compute the $x$
+and~$y$ coordinates of the leftmost, rightmost, topmost, or bottommost
+point on the pen shape. For example,
$$ {\tt rt}(x,y) = (x,y)+({\tt 0.0867in}, {\tt 0.0496in}) $$
-for the pen in Figure~\ref{fig38}. Note that {\tt beginfig}\index{beginfig?\texttt{beginfig}}
-resets the current pen to a default value of
+for the pen in Figure~\ref{fig38}. Note that {\tt
+beginfig}\index{beginfig?\texttt{beginfig}} resets the current pen to a
+default value of
$$ \hbox{\tt pencircle scaled 0.5bp} $$
-at the beginning of each figure. This value can be reselected at any time
-by giving the command
-{\tt pickup defaultpen}\index{defaultpen?\texttt{defaultpen}}\label{Ddefaultpen}.
-
-This would be the end of the story on pens, except that
-for compatibility with \MF\index{metafont?\MF}, MetaPost also allows pen shapes to be
-polygonal\index{pens!polygonal}.
-There is a predefined pen called
-{\tt pensquare}\index{pensquare?\texttt{pensquare}}\label{Dpnsqr} that
-can be transformed to yield pens shaped like parallelograms. In fact, there is
-even an operator called {\tt makepen}\index{makepen?\texttt{makepen}}\label{Dmkpen} that takes
-a convex-polygon-shaped path and makes a pen that shape and size. If the path is
-not exactly convex or polygonal, the {\tt makepen} operator will straighten the
-edges and/or drop some of the vertices.
-In particular, {\tt pensquare} is equivalent to
+at the beginning of each figure. This value can be reselected at any
+time by giving the command {\tt pickup
+defaultpen}\index{defaultpen?\texttt{defaultpen}}\label{Ddefaultpen}.
+
+This would be the end of the story on pens, except that for
+compatibility with \MF\index{metafont?\MF}, MetaPost also allows pen
+shapes to be polygonal\index{pens!polygonal}. There is a predefined pen
+called {\tt pensquare}\index{pensquare?\texttt{pensquare}}\label{Dpnsqr}
+that can be transformed to yield pens shaped like parallelograms.
+
+In fact, there is even an operator called {\tt
+makepen}\index{makepen?\texttt{makepen}}\label{Dmkpen} that takes a
+convex-polygon-shaped path and makes a pen that shape and size. If the
+path is not exactly convex or polygonal, the {\tt makepen} operator will
+straighten the edges and/or drop some of the vertices. In particular,
+{\tt pensquare} is equivalent to
$$ \hbox{\tt makepen((-.5,-.5)--(.5,-.5)--(.5,.5)--(-.5,.5)--cycle)} $$
-The inverse of {\tt makepen} is the
-{\tt makepath}\index{makepath?\texttt{makepath}}\label{Dmkpath} operator
-that takes a \tdescr{pen primary} and returns the corresponding path. Thus
-{\tt makepath pencircle} produces a circular path identical to
-{\tt fullcircle}\index{fullcircle?\texttt{fullcircle}}. This also works for a polygonal pen
-so that
+{\tt pensquare} and {\tt makepen} should not be used with dash
+patterns. See the end of Section~\ref{sec.pens}, p.\
+\pageref{dashed-pens}.
+
+The inverse of {\tt makepen} is the {\tt
+makepath}\index{makepath?\texttt{makepath}}\label{Dmkpath} operator that
+takes a \tdescr{pen primary} and returns the corresponding path. Thus
+{\tt makepath pencircle} produces a circular path identical to {\tt
+fullcircle}\index{fullcircle?\texttt{fullcircle}}. This also works for
+a polygonal pen so that
$$ {\tt makepath\ makepen}\, \descr{path expression} $$
will take any cyclic path and turn it into a convex polygon\index{convex polygons}.
\subsection{Clipping and Low-Level Drawing Commands}
-Drawing statements such as {\tt draw}, {\tt fill}, {\tt filldraw}, and {\tt unfill}
-are part of the Plain macro\index{Plain macros} package and are defined in terms
-of more primitive statements. The main difference between the drawing
-statements discussed in previous sections and the more primitive versions is that
-the primitive drawing statements all require you to specify a picture variable to
-hold the results. For {\tt fill}, {\tt draw}, and related statements, the results
-always go to a picture variable called
-{\tt currentpicture}\index{currentpicture?\texttt{currentpicture}}\label{Dcurpic}.
-The syntax for the primitive
-drawing statements that allow you to specify a picture variable is shown in
-Figure~\ref{sydraw}.
+Drawing statements such as {\tt draw}, {\tt fill}, {\tt filldraw}, and
+{\tt unfill} are part of the Plain macro\index{Plain macros} package and
+are defined in terms of more primitive statements. The main difference
+between the drawing statements discussed in previous sections and the
+more primitive versions is that the primitive drawing statements all
+require you to specify a picture variable to hold the results. For {\tt
+fill}, {\tt draw}, and related statements, the results always go to a
+picture variable called {\tt
+currentpicture}\index{currentpicture?\texttt{currentpicture}}\label{Dcurpic}.
+The syntax for the primitive drawing statements that allow you to
+specify a picture variable is shown in Figure~\ref{sydraw}.
\begin{figure}[htp]
\begin{ctabbing}
@@ -2650,6 +3043,12 @@ $\tt \qquad \;|\; addto \descr{picture variable}
$\tt \descr{option list} \rightarrow \descr{empty} \;|\;
\descr{drawing option} \descr{option list}$\\
$\tt \descr{drawing option} \rightarrow withcolor \descr{color expression}$\\
+$\tt \qquad \;|\; withrgbcolor \descr{rgbcolor expression} \;|\;
+ withcmykcolor \descr{cmykcolor expression}$\\
+$\tt \qquad \;|\; withgreyscale \descr{numeric expression} \;|\;
+ withoutcolor$\\
+$\tt \qquad \;|\; withprescript \descr{string expression} \;|\;
+ withpostscript \descr{string expression}$\\
$\tt \qquad \;|\; withpen \descr{pen expression} \;|\;
dashed \descr{picture expression}$
\end{ctabbing}
@@ -2661,21 +3060,22 @@ $\tt \qquad \;|\; withpen \descr{pen expression} \;|\;
\end{figure}
The syntax for primitive drawing commands is compatible with
-\MF\index{metafont?\MF}. Table~\ref{draweqv} shows how the primitive drawing statements
-relate to the familiar {\tt draw} and {\tt fill} statements. Each of the
-statements in the first column of the table could be ended with an
-\tdescr{option list} of its own, which is equivalent to appending the
-\tdescr{option list} to the corresponding entry in the second column of the table.
-For example,
+\MF\index{metafont?\MF}. Table~\ref{draweqv} shows how the primitive
+drawing statements relate to the familiar {\tt draw} and {\tt fill}
+statements. Each of the statements in the first column of the table
+could be ended with an \tdescr{option list} of its own, which is
+equivalent to appending the \tdescr{option list} to the corresponding
+entry in the second column of the table. For example,
$$ {\tt draw}\ p\ {\tt withpen\ pencircle} $$
is equivalent to
$$ {\tt addto\ currentpicture\ doublepath}\ p\
{\tt withpen\ currentpen\ withpen\ pencircle}
$$
-where {\tt currentpen}\index{currentpen?\texttt{currentpen}}\label{Dcurpen} is a special
-pen variable that always holds the last pen picked up.
-The second {\tt withpen} option silently overrides the {\tt withpen currentpen}
-from the expansion of {\tt draw}.
+where {\tt
+currentpen}\index{currentpen?\texttt{currentpen}}\label{Dcurpen} is a
+special pen variable that always holds the last pen picked up. The
+second {\tt withpen} option silently overrides the {\tt withpen
+currentpen} from the expansion of {\tt draw}.
\begin{table}[htp]
$$\begin{tabular}{|l|l|} \hline
@@ -2696,26 +3096,34 @@ $$\begin{tabular}{|l|l|} \hline
{\tt withcolor} $b$\\ \hline
\end{tabular}
$$
-\caption[Drawing statements and equivalent primitive commands]
- {Common drawing statements and equivalent primitive versions, where
- $q$ stands for {\tt currentpen}, $b$ stands for {\tt background},
- $p$ stands for any path, $c$ stands for a cyclic path, and {\it pic} stands
- for a \tdescr{picture expression}. Note that nonempty {\tt drawoptions}
- would complicate the entries in the second column.}
+\caption[Drawing statements and equivalent primitive commands] {Common
+ drawing statements and equivalent primitive versions, where $q$
+ stands for {\tt currentpen}, $b$ stands for {\tt background},
+ $p$ stands for any path, $c$ stands for a cyclic path, and {\it
+ pic} stands for a \tdescr{picture expression}. Note that
+ nonempty {\tt drawoptions} would complicate the entries in the
+ second column.}
\label{draweqv}
\index{drawoptions?\texttt{drawoptions}}
\end{table}
-There are two more primitive drawing commands that do not accept any drawing
-options. One is the {\tt setbounds} command that was discussed in
-Section~\ref{meas}; the other is the
-{\tt clip} command\index{clip?\texttt{clip}}\label{Dclip}:
+
+The {\tt image}\index{image?\texttt{image}}\label{Dimage} macro from
+Plain MetaPost takes any text as its argument, executes it, and returns
+the resulting picture. The value of {\tt currentpicture} is not
+affected.
+
+There are two more primitive drawing commands that do not accept any
+drawing options. One is the {\tt setbounds} command that was discussed
+in Section~\ref{meas}; the other is the {\tt clip}
+command\index{clip?\texttt{clip}}\label{Dclip}:
$$ {\tt clip}\, \descr{picture variable}\, {\tt to}\, \descr{path expression} $$
Given a cyclic path, this statement trims the contents of the
\tdescr{picture variable} to eliminate everything outside of the cyclic path.
There is no ``high level'' version of this statement, so you have to use
$$ {\tt clip\ currentpicture\ to}\, \descr{path expression} $$
-if you want to clip {\tt currentpicture}\index{currentpicture?\texttt{currentpicture}}.
+if you want to clip {\tt
+currentpicture}\index{currentpicture?\texttt{currentpicture}}.
Figure~\ref{fig40} illustrates clipping.
\begin{figure}[htp]
@@ -2735,30 +3143,34 @@ draw p3;
endfig;
\end{verbatim}
\qquad
-\mathcenter{\epsfbox{manfig.40}}
+\mathcenter{\includegraphics{manfig-40}}
$$
\caption{MetaPost code and the resulting ``clipped'' figure.}
\label{fig40}
\end{figure}
-All the primitive drawing operations would be useless without one last operation
-called {\tt shipout}. The statement\index{shipout?\texttt{shipout}}\label{Dship}
+All the primitive drawing operations would be useless without one last
+operation called {\tt shipout}. The
+statement\index{shipout?\texttt{shipout}}\label{Dship}
$$ {\tt shipout}\, \descr{picture expression} $$
-This writes out a picture as a PostScript\index{PostScript} file whose name ends
-{\tt.}{\it nnn}, where {\tt nnn} is the decimal representation of the value of
-the internal variable\index{internal variables}\index{variables!internal}
-{\tt charcode}\index{charcode?\texttt{charcode}}\label{Dcharcode}.
-(The name ``{\tt charcode}'' is for compatibility with \MF\index{metafont?\MF}.)
-Normally, {\tt beginfig}\index{beginfig?\texttt{beginfig}} sets {\tt charcode}, and
-{\tt endfig}\index{endfig?\texttt{endfig}} invokes {\tt shipout}.
+This writes out a picture as a PostScript\index{PostScript} file whose
+name ends {\tt.}{\it nnn}, where {\tt nnn} is the decimal representation
+of the value of the internal variable\index{internal
+variables}\index{variables!internal} {\tt
+charcode}\index{charcode?\texttt{charcode}}\label{Dcharcode}. (The name
+``{\tt charcode}'' is for compatibility with \MF\index{metafont?\MF}.)
+Normally, {\tt beginfig}\index{beginfig?\texttt{beginfig}} sets {\tt
+charcode}, and {\tt endfig}\index{endfig?\texttt{endfig}} invokes {\tt
+shipout}.
\section{Macros}
\label{macros}
-As alluded to earlier, MetaPost has a set of automatically included macros called
-the Plain macro package\index{Plain macros}, and some of the commands discussed in
-previous sections are defined as macros instead of being built into MetaPost.
-The purpose of this section is to explain how to write such macros.
+As alluded to earlier, MetaPost has a set of automatically included
+macros called the Plain macro package\index{Plain macros}, and some of
+the commands discussed in previous sections are defined as macros
+instead of being built into MetaPost. The purpose of this section is to
+explain how to write such macros.
Macros with no arguments are very simple.
A macro definition\index{replacement text?\tdescr{replacement text}}%
@@ -2766,59 +3178,67 @@ A macro definition\index{replacement text?\tdescr{replacement text}}%
$$ {\tt def}\, \descr{symbolic token}\, \hbox{\tt =}\,
\descr{replacement text}\, {\tt enddef}
$$
-makes the \tdescr{symbolic token} an abbreviation for the \tdescr{replacement text},
-where the \tdescr{replacement text} can be virtually any sequence of tokens. For
-example, the Plain macro package could almost define the {\tt fill} statement like
+makes the \tdescr{symbolic token} an abbreviation for the
+\tdescr{replacement text}, where the \tdescr{replacement text} can be
+virtually any sequence of tokens. For example, the Plain macro package
+could almost define the {\tt fill} statement like
this\index{fill?\texttt{fill}}:
$$ \hbox{\tt def fill = addto currentpicture contour enddef} $$
-Macros with arguments are similar, except they have formal parameters that tell
-how to use the arguments in the \tdescr{replacement text}. For example, the
-{\tt rotatedaround}\index{rotatedaround?\texttt{rotatedaround}} macro is defined like this:
+Macros with arguments are similar, except they have formal parameters
+that tell how to use the arguments in the \tdescr{replacement text}.
+For example, the {\tt
+rotatedaround}\index{rotatedaround?\texttt{rotatedaround}} macro is
+defined like this:
$$\begin{verbatim}
def rotatedaround(expr z, d) =
shifted -z rotated d shifted z enddef;
\end{verbatim}
$$
-The {\tt expr}\index{expr?\texttt{expr}} in this definition means that formal parameters
-{\tt z} and {\tt d} can be arbitrary expressions. (They should be pair expressions
-but the MetaPost interpreter does not immediately check for that.)
+The {\tt expr}\index{expr?\texttt{expr}} in this definition means that
+formal parameters {\tt z} and {\tt d} can be arbitrary expressions.
+(They should be pair expressions but the MetaPost interpreter does not
+immediately check for that.)
-Since MetaPost is an interpreted language, macros with arguments are a lot like
-subroutines\index{subroutines}. MetaPost macros are often used like subroutines,
-so the language includes programming concepts to support this.
-These concepts include local variables, loops, and conditional statements.
+Since MetaPost is an interpreted language, macros with arguments are a
+lot like subroutines\index{subroutines}. MetaPost macros are often used
+like subroutines, so the language includes programming concepts to
+support this. These concepts include local variables, loops, and
+conditional statements.
\subsection{Grouping}
\label{grsec}
Grouping in MetaPost is essential for functions\index{functions} and
-local\index{variables!local}\index{locality} variables.
-The basic idea is that a group is
-a sequence of statements possibly followed by an expression with the provision
-that certain symbolic tokens\index{tokens!symbolic} can have their old meanings
-restored at the end of the group. If the group ends with an expression, the
-group behaves like a function call that returns that expression. Otherwise,
-the group is just a compound statement\index{compound statement}.
-The syntax for a group is\index{begingroup?\texttt{begingroup}}\index{endgroup?\texttt{endgroup}}
+local\index{variables!local}\index{locality} variables. The basic idea
+is that a group is a sequence of statements possibly followed by an
+expression with the provision that certain symbolic
+tokens\index{tokens!symbolic} can have their old meanings restored at
+the end of the group. If the group ends with an expression, the group
+behaves like a function call that returns that expression. Otherwise,
+the group is just a compound statement\index{compound statement}. The
+syntax for a group
+is\index{begingroup?\texttt{begingroup}}\index{endgroup?\texttt{endgroup}}
$$ {\tt begingroup}\, \descr{statement list}\, {\tt endgroup} $$
or
$$ {\tt begingroup}\, \descr{statement list}\, \descr{expression}\, {\tt endgroup}
$$
-where a \tdescr{statement list} is a sequence of statements each followed by a
-semicolon. A group with an \tdescr{expression} after the \tdescr{statement list}
-behaves like a \tdescr{primary} in Figure~\ref{syexpr} or like a
-\tdescr{numeric atom} in Figure~\ref{synprim}.
-
-Since the \tdescr{replacement text} for the {\tt beginfig}\index{beginfig?\texttt{beginfig}}
-macro starts with {\tt begingroup} and the \tdescr{replacement text} for
-{\tt endfig}\index{endfig?\texttt{endfig}} ends with {\tt endgroup},
-each figure in a MetaPost input file behaves like a
-group. This is what allows figures can have local variables.
-We have already seen in Section~\ref{vardecl} that
-variable names beginning with {\tt x} or {\tt y} are local in the sense that they
-have unknown values at the beginning of each figure and these values are forgotten
-at the end of each figure. The following example illustrates how locality works:
+where a \tdescr{statement list} is a sequence of statements each
+followed by a semicolon. A group with an \tdescr{expression} after the
+\tdescr{statement list} behaves like a \tdescr{primary} in
+Figure~\ref{syexpr} or like a \tdescr{numeric atom} in
+Figure~\ref{synprim}.
+
+Since the \tdescr{replacement text} for the {\tt
+beginfig}\index{beginfig?\texttt{beginfig}} macro starts with {\tt
+begingroup} and the \tdescr{replacement text} for {\tt
+endfig}\index{endfig?\texttt{endfig}} ends with {\tt endgroup}, each
+figure in a MetaPost input file behaves like a group. This is what
+allows figures can have local variables. We have already seen in
+Section~\ref{vardecl} that variable names beginning with {\tt x} or {\tt
+y} are local in the sense that they have unknown values at the beginning
+of each figure and these values are forgotten at the end of each figure.
+The following example illustrates how locality works:
\begin{eqnarray*}
&& \hbox{\tt x23 = 3.1;}\\
&& \hbox{\tt beginfig(17);}\\
@@ -2840,8 +3260,9 @@ indicating that {\tt x23} has returned to its former value of {\tt 3.1} and
The locality of {\tt x} and {\tt y} variables is achieved by the
statement\index{save?\texttt{save}}\label{Dsave}
$$ \hbox{\tt save x,y} $$
-in the \tdescr{replacement text} for {\tt beginfig}\index{beginfig?\texttt{beginfig}}.
-In general, variables are made local by the statement
+in the \tdescr{replacement text} for {\tt
+beginfig}\index{beginfig?\texttt{beginfig}}. In general, variables are
+made local by the statement
$$ {\tt save}\, \descr{symbolic token list} $$
where \tdescr{symbolic token list} is a comma-separated list of
tokens:\index{tokens!symbolic}
@@ -2850,32 +3271,36 @@ $\tt \descr{symbolic token list} \rightarrow \descr{symbolic token}$\\
$\tt \qquad \;|\; \descr{symbolic token}\hbox{\tt ,}
\descr{symbolic token list}$
\end{ctabbing}
-All variables whose names begin with one of the specified symbolic tokens become
-unknown numerics and their present values are saved for restoration at the end
-of the current group. If the {\tt save} statement is used outside of a group, the
-original values are simply discarded.
-
-The main purpose of the {\tt save} statement is to allow macros to use variables
-without interfering with existing variables or variables in other calls to the
-same macro. For example, the predefined macro {\tt whatever}\index{whatever}
-has the \tdescr{replacement text}
+All variables whose names begin with one of the specified symbolic
+tokens become unknown numerics and their present values are saved for
+restoration at the end of the current group. If the {\tt save}
+statement is used outside of a group, the original values are simply
+discarded.
+
+The main purpose of the {\tt save} statement is to allow macros to use
+variables without interfering with existing variables or variables in
+other calls to the same macro. For example, the predefined macro {\tt
+whatever}\index{whatever} has the \tdescr{replacement text}
$$ \hbox{\tt begingroup save ?; ? endgroup} $$
-This returns an unknown numeric quantity, but it is no longer called question
-mark since that name was local to the group. Asking the name via
-{\tt show\index{show?\texttt{show}} whatever} yields\index{CAPSULE?\texttt{CAPSULE}}
+This returns an unknown numeric quantity, but it is no longer called
+question mark since that name was local to the group. Asking the name
+via {\tt show\index{show?\texttt{show}} whatever}
+yields\index{CAPSULE?\texttt{CAPSULE}}
$$ \hbox{\tt >> \%CAPSULE}{\it nnnn} $$
where {\it nnnn} is an identification number that is chosen when {\tt save}
makes the name question mark disappear.
-In spite of the versatility of {\tt save}, it cannot be used to make local changes
-to any of MetaPost's
-internal variables\index{internal variables}\index{variables!internal}.
-A statement such as\index{linecap?\texttt{linecap}}
+In spite of the versatility of {\tt save}, it cannot be used to make
+local changes to any of MetaPost's internal variables\index{internal
+variables}\index{variables!internal}. A statement such
+as\index{linecap?\texttt{linecap}}
$$ \hbox{\tt save linecap} $$
-would cause MetaPost to temporarily forget the special meaning of this variable
-and just make it an unknown numeric. If you want to draw one dashed line with
-{\tt linecap:=butt} and then go back to the previous value, you can use the
-{\tt interim}\index{interim?\texttt{interim}}\label{Dinterm} statement as follows:
+would cause MetaPost to temporarily forget the special meaning of this
+variable and just make it an unknown numeric. If you want to draw one
+dashed line with {\tt linecap:=butt} and then go back to the previous
+value, you can use the {\tt
+interim}\index{interim?\texttt{interim}}\label{Dinterm} statement as
+follows:
\begin{eqnarray*}
&& \hbox{\tt begingroup interim linecap:=butt;}\\
&& {\tt draw}\, \descr{path expression}\, \hbox{\tt dashed evenly; endgroup}
@@ -2904,36 +3329,39 @@ $$\tt rotatedaround\hbox{\tt (}
\descr{expression}\hbox{\tt ,} \descr{expression}\hbox{\tt )}
$$
-The keyword {\tt expr}\index{expr?\texttt{expr}}\index{parameter!expr} in the macro
-definition means that the
-parameters can be expressions of any type. When the definition specifies
-{\tt (expr z, d)}, the formal parameters {\tt z} and {\tt d} behave like
-variables of the appropriate
-types. Within the \tdescr{replacement text}, they can be used in expressions
-just like variables, but they cannot be redeclared or assigned to. There is no
-restriction against unknown or partially known arguments. Thus the
-definition\index{midpoint?\texttt{midpoint}}
+The keyword {\tt expr}\index{expr?\texttt{expr}}\index{parameter!expr}
+in the macro definition means that the parameters can be expressions of
+any type. When the definition specifies {\tt (expr z, d)}, the formal
+parameters {\tt z} and {\tt d} behave like variables of the appropriate
+types. Within the \tdescr{replacement text}, they can be used in
+expressions just like variables, but they cannot be redeclared or
+assigned to. There is no restriction against unknown or partially known
+arguments. Thus the definition\index{midpoint?\texttt{midpoint}}
$$ \hbox{\tt def midpoint(expr a, b) = (.5[a,b]) enddef} $$
works perfectly well when {\tt a} and {\tt b} are unknown. An
equation such as
$$ \hbox{\tt midpoint(z1,z2) = (1,1)} $$
could be used to help determine {\tt z1} and {\tt z2}.
-Notice that the above definition for {\tt midpoint} works for numerics, pairs,
-or colors as long as both parameters have the same type. If for some reason we
-want a {\tt middlepoint}\index{middlepoint?\texttt{middlepoint}} macro that works for
-a single path or picture, it would be
-necessary to do an {\tt if}\index{if?\texttt{if}} test on the argument type. This uses
-the fact there is a unary operator\index{path?\texttt{path}}
+Notice that the above definition for {\tt midpoint} works for numerics,
+pairs, or colors as long as both parameters have the same type. If for
+some reason we want a {\tt
+middlepoint}\index{middlepoint?\texttt{middlepoint}} macro that works
+for a single path or picture, it would be necessary to do an {\tt
+if}\index{if?\texttt{if}} test on the argument type. This uses the fact
+there is a unary operator\index{path?\texttt{path}}
$$ {\tt path}\, \descr{primary} $$
-that returns a boolean result indicating whether its argument is a path. Since
-the basic {\tt if} test has the syntax\index{else?\texttt{else}}\index{fi?\texttt{fi}}
+that returns a boolean result indicating whether its argument is a path.
+Since the basic {\tt if} test has the
+syntax\index{else?\texttt{else}}\index{fi?\texttt{fi}}
$$ {\tt if}\, \descr{boolean expression}\hbox{\tt:}\, \descr{balanced tokens}\,
\hbox{\tt else:}\, \descr{balanced tokens}\, {\tt fi}
$$
-where the \tdescr{balanced tokens}\index{balanced tokens?\tdescr{balanced tokens}} can be anything
-that is balanced with respect to {\tt if} and {\tt fi}, the complete
-{\tt middlepoint}\index{midpoint?\texttt{midpoint}} macro with type test looks like this:
+where the \tdescr{balanced tokens}\index{balanced
+tokens?\tdescr{balanced tokens}} can be anything that is balanced with
+respect to {\tt if} and {\tt fi}, the complete {\tt
+middlepoint}\index{midpoint?\texttt{midpoint}} macro with type test
+looks like this:
$$\begin{verbatim}
def middlepoint(expr a) = if path a: (point .5*length a of a)
else: .5(llcorner a + urcorner a) fi enddef;
@@ -2946,10 +3374,11 @@ to be shortened to\index{elseif?\texttt{elseif}}
$$ \hbox{\tt if $e_1$: \ldots\ elseif $e_2$: \ldots\ else: \ldots\ fi} $$
where $e_1$ and $e_2$ represent boolean expressions.
-Note that {\tt if} tests are not statements and the \tdescr{balanced tokens} in
-the syntax rules can be any sequence of balanced tokens even if they do not form
-a complete expression or statement. Thus we could have saved two tokens at the
-expense of clarity by defining {\tt midpoint} like this:
+Note that {\tt if} tests are not statements and the \tdescr{balanced
+tokens} in the syntax rules can be any sequence of balanced tokens even
+if they do not form a complete expression or statement. Thus we could
+have saved two tokens at the expense of clarity by defining {\tt
+midpoint} like this:
$$\begin{verbatim}
def midpoint(expr a) = if path a: (point .5*length a of
else: .5(llcorner a + urcorner fi a) enddef;
@@ -2969,10 +3398,11 @@ $\tt \qquad \;|\; elseif \descr{boolean expression} \hbox{\tt :}
\label{syif}
\end{figure}
-The real purpose of macros and {\tt if} tests is to automate repetitive tasks and
-allow important subtasks to be solved separately. For example, Figure~\ref{fig42}
-uses macros \verb|draw_marked|, \verb|mark_angle|, and \verb|mark_rt_angle| to
-mark lines and angles that appear in the figure.
+The real purpose of macros and {\tt if} tests is to automate repetitive
+tasks and allow important subtasks to be solved separately. For
+example, Figure~\ref{fig42} uses macros \verb|draw_marked|,
+\verb|mark_angle|, and \verb|mark_rt_angle| to mark lines and angles
+that appear in the figure.
\begin{figure}[htp]
$$\begin{verbatim}
@@ -3005,27 +3435,30 @@ mark_rt_angle(z.p, z0, a);
mark_rt_angle(z.p, z1, b);
endfig;
\end{verbatim}
-\quad \mathcenter{\epsfbox{manfig.42}}
+\quad \mathcenter{\includegraphics{manfig-42}}
$$
\caption{MetaPost code and the corresponding figure}
\label{fig42}
\end{figure}
-The task of the \verb|draw_marked|\index{draw_marked?\texttt{draw\_marked}} macro is to draw a path
-with a given number of cross marks near its midpoint. A convenient starting place
-is the subproblem of drawing a single cross mark perpendicular to a path {\tt p}
-at some time {\tt t}. The \verb|draw_mark|\index{draw_mark?\texttt{draw\_mark}} macro in
-Figure~\ref{drawmarked} does this by first finding a vector {\tt dm} perpendicular
-to~{\tt p} at~{\tt t}. To simplify positioning the cross mark,
-the \verb|draw_marked| macro is defined to take an arc length\index{arc length}
-{\tt a} along {\tt p} and use the {\tt arctime}\index{arctime} operator to
-compute~{\tt t}
-
-With the subproblem of drawing a single mark out of the way, the \verb|draw_marked|
-macro only needs to draw the path and call \verb|draw_mark| with the appropriate
-arc length values. The \verb|draw_marked| macro in Figure~\ref{drawmarked}
-uses {\tt n} equally-spaced {\tt a} values centered on
-{\tt .5*arclength~p}\index{arclength?\texttt{arclength}}.
+The task of the
+\verb|draw_marked|\index{draw_marked?\texttt{draw\_marked}} macro is to
+draw a path with a given number of cross marks near its midpoint. A
+convenient starting place is the subproblem of drawing a single cross
+mark perpendicular to a path {\tt p} at some time {\tt t}. The
+\verb|draw_mark|\index{draw_mark?\texttt{draw\_mark}} macro in
+Figure~\ref{drawmarked} does this by first finding a vector {\tt dm}
+perpendicular to~{\tt p} at~{\tt t}. To simplify positioning the cross
+mark, the \verb|draw_marked| macro is defined to take an arc
+length\index{arc length} {\tt a} along {\tt p} and use the {\tt
+arctime}\index{arctime} operator to compute~{\tt t}
+
+With the subproblem of drawing a single mark out of the way, the
+\verb|draw_marked| macro only needs to draw the path and call
+\verb|draw_mark| with the appropriate arc length values. The
+\verb|draw_marked| macro in Figure~\ref{drawmarked} uses {\tt n}
+equally-spaced {\tt a} values centered on {\tt
+.5*arclength~p}\index{arclength?\texttt{arclength}}.
\begin{figure}[htp]
$$\begin{verbatim}
@@ -3057,17 +3490,20 @@ $$
\label{drawmarked}
\end{figure}
-Since \verb|draw_marked| works for curved lines, it can be used to draw the arcs
-that the \verb|mark_angle|\index{mark_angle?\texttt{mark\_angle}} macro generates. Given points
-{\tt a}, {\tt b}, and {\tt c} that define a counter-clockwise angle at {\tt b},
-the \verb|mark_angle| needs to generate a small arc from segment {\tt ba} to
-segment {\tt bc}. The macro definition in Figure~\ref{markangle} does this by
-creating an arc {\tt p} of radius one and then computing a scale factor {\tt s}
-that makes it big enough to see clearly.
-
-The \verb|mark_rt_angle|\index{mark_rt_angle?\texttt{mark\_rt\_angle}} macro is much simpler.
-It takes a generic right-angle corner and uses the {\tt zscaled}\index{zscaled?\texttt{zscaled}}
-operator to rotate it and scale it as necessary.
+Since \verb|draw_marked| works for curved lines, it can be used to draw
+the arcs that the
+\verb|mark_angle|\index{mark_angle?\texttt{mark\_angle}} macro
+generates. Given points {\tt a}, {\tt b}, and {\tt c} that define a
+counter-clockwise angle at {\tt b}, the \verb|mark_angle| needs to
+generate a small arc from segment {\tt ba} to segment {\tt bc}. The
+macro definition in Figure~\ref{markangle} does this by creating an arc
+{\tt p} of radius one and then computing a scale factor {\tt s} that
+makes it big enough to see clearly.
+
+The \verb|mark_rt_angle|\index{mark_rt_angle?\texttt{mark\_rt\_angle}}
+macro is much simpler. It takes a generic right-angle corner and uses
+the {\tt zscaled}\index{zscaled?\texttt{zscaled}} operator to rotate it
+and scale it as necessary.
\begin{figure}[htp]
$$\begin{verbatim}
@@ -3096,15 +3532,17 @@ $$
\subsection{Suffix and Text Parameters}
-Macro parameters need not always be expressions as in the previous examples.
-Replacing the keyword {\tt expr} with {\tt suffix}\index{suffix?\texttt{suffix}} or
-{\tt text}\index{text?\texttt{text}} in a macro definition declares the parameters to be
-variable names or arbitrary sequences of tokens. For example, there is a
-predefined macro called {\tt hide}\index{hide?\texttt{hide}} that takes a
-text parameter\index{parameter!text} and
-interprets it as a sequence of statements while ultimately producing an empty
-\tdescr{replacement text}. In other words, {\tt hide} executes its argument and
-then gets the next token as if nothing happened. Thus
+Macro parameters need not always be expressions as in the previous
+examples. Replacing the keyword {\tt expr} with {\tt
+suffix}\index{suffix?\texttt{suffix}} or {\tt
+text}\index{text?\texttt{text}} in a macro definition declares the
+parameters to be variable names or arbitrary sequences of tokens. For
+example, there is a predefined macro called {\tt
+hide}\index{hide?\texttt{hide}} that takes a text
+parameter\index{parameter!text} and interprets it as a sequence of
+statements while ultimately producing an empty \tdescr{replacement
+text}. In other words, {\tt hide} executes its argument and then gets
+the next token as if nothing happened. Thus
$$ \hbox{\tt show hide(numeric a,b; a+b=3; a-b=1) a;} $$
prints ``\verb|>> 2|.''
@@ -3114,14 +3552,14 @@ def ignore(expr a) = enddef;
def hide(text t) = ignore(begingroup t; 0 endgroup) enddef;
\end{verbatim}
$$
-The statements represented by the text parameter {\tt t} would be evaluated as part
-of the group that forms the argument to {\tt ignore}. Since {\tt ignore} has an
-empty \tdescr{replacement text}, expansion of the {\tt hide} macro ultimately
-produces nothing.
-
-Another example of a predefined macro with a text parameter is
-{\tt dashpattern}\index{dashpattern?\texttt{dashpattern}}. The definition of {\tt dashpattern}
-starts
+The statements represented by the text parameter {\tt t} would be
+evaluated as part of the group that forms the argument to {\tt ignore}.
+Since {\tt ignore} has an empty \tdescr{replacement text}, expansion of
+the {\tt hide} macro ultimately produces nothing.
+
+Another example of a predefined macro with a text parameter is {\tt
+dashpattern}\index{dashpattern?\texttt{dashpattern}}. The definition of
+{\tt dashpattern} starts
$$\begin{verbatim}
def dashpattern(text t) =
begingroup save on, off;
@@ -3130,24 +3568,27 @@ $$
then it defines {\tt on} and {\tt off} to be macros that create the desired
picture when the text parameter~{\tt t} appears in the replacement text.
-Text parameters are very general, but their generality sometimes gets in the way.
-If you just want to pass a variable name to a macro, it is better to declare it
-as a suffix parameter\index{parameter!suffix}. For example,\index{incr?\texttt{incr}}
+Text parameters are very general, but their generality sometimes gets in
+the way. If you just want to pass a variable name to a macro, it is
+better to declare it as a suffix parameter\index{parameter!suffix}. For
+example,\index{incr?\texttt{incr}}
$$ \hbox{\verb|def incr(suffix $) = begingroup $:=$+1; $ endgroup enddef;|} $$
defines a macro that will take any numeric variable, add one to it, and return
the new value. Since variable names can be more than one token long,
$$ \hbox{\tt incr(a3b)} $$
-is perfectly acceptable if {\tt a3b} is a numeric variable.
-Suffix parameters are slightly more general than variable names because the
-definition in Figure~\ref{syvar} allows a \tdescr{suffix}\index{suffix?\tdescr{suffix}}
-to start with a \tdescr{subscript}\index{subscript?\tdescr{subscript}}.
-
-Figure~\ref{fig45} shows how suffix and expr parameters can be used together.
-The {\tt getmid}\index{getmid?\texttt{getmid}} macro takes a path variable and creates arrays
-of points and directions whose names are obtained by appending {\tt mid},
-{\tt off}, and {\tt dir} to the path variable. The {\tt joinup}\index{joinup?\texttt{joinup}}
-macro takes arrays of points and directions and creates a path of length {\tt n}
-that passes through each {\tt pt[i]} with direction {\tt d[i]} or
+is perfectly acceptable if {\tt a3b} is a numeric variable. Suffix
+parameters are slightly more general than variable names because the
+definition in Figure~\ref{syvar} allows a
+\tdescr{suffix}\index{suffix?\tdescr{suffix}} to start with a
+\tdescr{subscript}\index{subscript?\tdescr{subscript}}.
+
+Figure~\ref{fig45} shows how suffix and expr parameters can be used
+together. The {\tt getmid}\index{getmid?\texttt{getmid}} macro takes a
+path variable and creates arrays of points and directions whose names
+are obtained by appending {\tt mid}, {\tt off}, and {\tt dir} to the
+path variable. The {\tt joinup}\index{joinup?\texttt{joinup}} macro
+takes arrays of points and directions and creates a path of length {\tt
+n} that passes through each {\tt pt[i]} with direction {\tt d[i]} or
$-\hbox{\tt d[i]}$.
\begin{figure}[htp]
@@ -3189,7 +3630,7 @@ for i=0 upto 3:
endfor
endfig;
\end{verbatim}
-\quad \mathcenter{\epsfbox{manfig.45}}
+\quad \mathcenter{\includegraphics{manfig-45}}
$$
\caption{MetaPost code and the corresponding figure}
\label{fig45}
@@ -3202,11 +3643,11 @@ parentheses as in
$$ \hbox{\tt joinup(p.mid, p.dir)(36)} $$
instead of
$$ \hbox{\tt joinup(p.mid, p.dir, 36)} $$
-In fact, both forms are acceptable. Parameters in a macro call can be separated
-by commas or by {\tt )(} pairs. The only restriction is that a
-text parameter\index{parameter!text}
-must be followed by a right parenthesis. For instance, a macro {\tt foo} with one
-text parameter and one expr parameter can be called
+In fact, both forms are acceptable. Parameters in a macro call can be
+separated by commas or by {\tt )(} pairs. The only restriction is that
+a text parameter\index{parameter!text} must be followed by a right
+parenthesis. For instance, a macro {\tt foo} with one text parameter
+and one expr parameter can be called
$$ \hbox{\tt foo(a,b)(c)} $$
in which case the text parameter is ``{\tt a,b}'' and the expr parameter is
{\tt c}, but
@@ -3217,79 +3658,86 @@ still looking for the expr parameter.
\subsection{Vardef Macros}
-A macro definition can begin with {\tt vardef}\index{vardef?\texttt{vardef}} instead of
-{\tt def}. Macros defined in this way are called vardef macros. They are
-particularly well-suited to applications where macros are being used like functions
-or subroutines. The main idea is that a vardef macro is like a variable of type
-``macro.''
+A macro definition can begin with {\tt
+vardef}\index{vardef?\texttt{vardef}} instead of {\tt def}. Macros
+defined in this way are called vardef macros. They are particularly
+well-suited to applications where macros are being used like functions
+or subroutines. The main idea is that a vardef macro is like a variable
+of type ``macro.''
Instead of {\tt def} \tdescr{symbolic token}, a vardef macro begins
$$ {\tt vardef}\, \descr{generic variable} $$
-where a \tdescr{generic variable}\index{generic variable?\tdescr{generic variable}} is a variable
-name with numeric subscripts replaced by the
-generic subscript\index{subscript!generic} symbol {\tt []}\index{[]?\texttt{[]}}.
-In other words, the name following {\tt vardef} obeys exactly the same syntax as
-the name given in a variable declaration. It is a sequence of tags and generic
-subscript symbols starting with a tag, where a tag\index{tags} is a symbolic token
-that is not a macro or a primitive operator as explained in Section~\ref{vardecl}.
-
-The simplest case is when the name of a vardef macro consists of a single tag.
-Under such circumstances, {\tt def} and {\tt vardef} provide roughly the same
-functionality. The most obvious difference is that
-{\tt begingroup}\index{begingroup?\texttt{begingroup}} and {\tt endgroup}\index{endgroup?\texttt{endgroup}}
-are automatically inserted at the beginning and end of the
-\tdescr{replacement text} of every vardef macro. This makes the
-\tdescr{replacement text} a group so that a vardef
-macro behaves like a subroutine or a function call.
+where a \tdescr{generic variable}\index{generic variable?\tdescr{generic
+variable}} is a variable name with numeric subscripts replaced by the
+generic subscript\index{subscript!generic} symbol {\tt
+[]}\index{[]?\texttt{[]}}. In other words, the name following {\tt
+vardef} obeys exactly the same syntax as the name given in a variable
+declaration. It is a sequence of tags and generic subscript symbols
+starting with a tag, where a tag\index{tags} is a symbolic token that is
+not a macro or a primitive operator as explained in
+Section~\ref{vardecl}.
+
+The simplest case is when the name of a vardef macro consists of a
+single tag. Under such circumstances, {\tt def} and {\tt vardef}
+provide roughly the same functionality. The most obvious difference is
+that {\tt begingroup}\index{begingroup?\texttt{begingroup}} and {\tt
+endgroup}\index{endgroup?\texttt{endgroup}} are automatically inserted
+at the beginning and end of the \tdescr{replacement text} of every
+vardef macro. This makes the \tdescr{replacement text} a group so that
+a vardef macro behaves like a subroutine or a function call.
Another property of vardef macros is that they allow multi-token macro
-names and macro names involving generic subscripts.
-When a vardef macro name has generic subscripts, numeric values have to be given
-when the macro is called. After a macro definition
+names and macro names involving generic subscripts. When a vardef macro
+name has generic subscripts, numeric values have to be given when the
+macro is called. After a macro definition
$$ \hbox{\tt vardef a[]b(expr p) =}\, \descr{replacement text}\,
\hbox{\tt enddef;}
$$
-{\tt a2b((1,2))} and {\tt a3b((1,2)..(3,4))} are macro calls. But how can the
-\tdescr{replacement text} tell the difference between {\tt a2b} and {\tt a3b}?
-Two implicit suffix parameters\index{parameter!suffix} are automatically
-provided for this purpose.
-Every vardef macro has suffix parameters \verb|#@|\index{#@?\texttt{\#@}}
-and \verb|@|\index{@?\texttt{@}}, where \verb|@| is the last token in the name from the
-macro call and \verb|#@| is everything preceding the last token. Thus \verb|#@|
-is {\tt a2} when the name is given as {\tt a2b} and {\tt a3} when the name is
-given as {\tt a3b}.
-
-Suppose, for example, that the {\tt a[]b} macro is to take its argument and
-shift it by an amount that depends on the macro name. The macro could be defined
-like this:
+{\tt a2b((1,2))} and {\tt a3b((1,2)..(3,4))} are macro calls. But how
+can the \tdescr{replacement text} tell the difference between {\tt a2b}
+and {\tt a3b}? Two implicit suffix parameters\index{parameter!suffix}
+are automatically provided for this purpose. Every vardef macro has
+suffix parameters \verb|#@|\index{#@?\texttt{\#@}} and
+\verb|@|\index{@?\texttt{@}}, where \verb|@| is the last token in the
+name from the macro call and \verb|#@| is everything preceding the last
+token. Thus \verb|#@| is {\tt a2} when the name is given as {\tt a2b}
+and {\tt a3} when the name is given as {\tt a3b}.
+
+Suppose, for example, that the {\tt a[]b} macro is to take its argument
+and shift it by an amount that depends on the macro name. The macro
+could be defined like this:
$$ \hbox{\verb|vardef a[]b(expr p) = p shifted (#@,b) enddef;|} $$
Then {\tt a2b((1,2))} means {\tt (1,2) shifted (a2,b)}
and {\tt a3b((1,2)..(3,4))} means
$$ \hbox{\tt ((1,2)..(3,4)) shifted (a3,b)}. $$
-If the macro had been {\tt a.b[]}, \verb|#@| would always be {\tt a.b} and the
-\verb|@| parameter would give the numeric subscript. Then {\tt a@} would refer to
-an element of the array {\tt a[]}. Note that \verb|@| is a suffix parameter, not
-an expr parameter, so an expression like {\tt @+1} would be illegal. The only way
-to get at the numeric values of subscripts in a
-suffix parameter\index{parameter!suffix} is by extracting
-them from the string returned by the {\tt str}\index{str?\texttt{str}}\label{Dstr}
-operator. This operator takes a suffix and returns a string
-representation of a suffix. Thus {\tt str @} would be \verb|"3"| in {\tt a.b3}
-and \verb|"3.14"| in {\tt a.b3.14} or {\tt a.b[3.14]}. Since the syntax for a
-\tdescr{suffix}\index{suffix?\tdescr{suffix}} in Figure~\ref{syvar} requires negative
-subscripts to be in brackets, {\tt str @} returns {\tt "[-3]"} in {\tt a.b[-3]}.
-
-The {\tt str} operator is generally for emergency use only. It is better to
-use suffix parameters only as variable names or suffixes. The best example of a
-vardef macro involving suffixes is the {\tt z} macro that defines the
-{\tt z} convention\index{z convention?{\tt z} convention}. The definition involves a special
-token \verb|@#|\index{@#?\texttt{@\#}} that refers to the suffix following the macro name:
+If the macro had been {\tt a.b[]}, \verb|#@| would always be {\tt a.b}
+and the \verb|@| parameter would give the numeric subscript. Then {\tt
+a@} would refer to an element of the array {\tt a[]}. Note that
+\verb|@| is a suffix parameter, not an expr parameter, so an expression
+like {\tt @+1} would be illegal. The only way to get at the numeric
+values of subscripts in a suffix parameter\index{parameter!suffix} is by
+extracting them from the string returned by the {\tt
+str}\index{str?\texttt{str}}\label{Dstr} operator. This operator takes
+a suffix and returns a string representation of a suffix. Thus {\tt str
+@} would be \verb|"3"| in {\tt a.b3} and \verb|"3.14"| in {\tt a.b3.14}
+or {\tt a.b[3.14]}. Since the syntax for a
+\tdescr{suffix}\index{suffix?\tdescr{suffix}} in Figure~\ref{syvar}
+requires negative subscripts to be in brackets, {\tt str @} returns {\tt
+"[-3]"} in {\tt a.b[-3]}.
+
+The {\tt str} operator is generally for emergency use only. It is
+better to use suffix parameters only as variable names or suffixes. The
+best example of a vardef macro involving suffixes is the {\tt z} macro
+that defines the {\tt z} convention\index{z convention?{\tt z}
+convention}. The definition involves a special token
+\verb|@#|\index{@#?\texttt{@\#}} that refers to the suffix following the
+macro name:
$$ \hbox{\verb|vardef z@#=(x@#,y@#) enddef;|} $$
-This means that any variable name whose first token is {\tt z} is equivalent to
-a pair of variables whose names are obtained by replacing {\tt z} with {\tt x}
-and~{\tt y}. For instance, {\tt z.a1} calls the {\tt z} macro with the suffix
-parameter \verb|@#| set to {\tt a1}.
+This means that any variable name whose first token is {\tt z} is
+equivalent to a pair of variables whose names are obtained by replacing
+{\tt z} with {\tt x} and~{\tt y}. For instance, {\tt z.a1} calls the
+{\tt z} macro with the suffix parameter \verb|@#| set to {\tt a1}.
In general,
$$ {\tt vardef}\, \descr{generic variable} \hbox{\verb|@#|} $$
@@ -3298,19 +3746,21 @@ MetaPost interpreter
to look for a suffix following the name given in the macro call and makes this
available as the \verb|@#| suffix parameter.
-To summarize the special features of vardef macros, they allow a broad class of
-macro names as well as macro names followed by a special suffix parameter.
-Furthermore, {\tt begingroup} and {\tt endgroup} are automatically added to the
-\tdescr{replacement text} of a vardef macro. Thus using {\tt vardef}
-instead of {\tt def} to define the {\tt joinup}\index{joinup?\texttt{joinup}} macro in
-Figure~\ref{fig45} would have avoided the need to include {\tt begingroup} and
-{\tt endgroup} explicitly in the macro definition.
-
-In fact, most of the macro definitions given in previous examples could equally
-well use {\tt vardef} instead of {\tt def}. It usually does not matter very much
-which you use, but a good general rule is to use {\tt vardef} if you intend the
-macro to be used like a function or a subroutine. The following comparison
-should help in deciding when to use {\tt vardef}.
+To summarize the special features of vardef macros, they allow a broad
+class of macro names as well as macro names followed by a special suffix
+parameter. Furthermore, {\tt begingroup} and {\tt endgroup} are
+automatically added to the \tdescr{replacement text} of a vardef macro.
+Thus using {\tt vardef} instead of {\tt def} to define the {\tt
+joinup}\index{joinup?\texttt{joinup}} macro in Figure~\ref{fig45} would
+have avoided the need to include {\tt begingroup} and {\tt endgroup}
+explicitly in the macro definition.
+
+In fact, most of the macro definitions given in previous examples could
+equally well use {\tt vardef} instead of {\tt def}. It usually does not
+matter very much which you use, but a good general rule is to use {\tt
+vardef} if you intend the macro to be used like a function or a
+subroutine. The following comparison should help in deciding when to
+use {\tt vardef}.
\begin{itemize}
\item Vardef macros are automatically surrounded by {\tt begingroup}
@@ -3320,29 +3770,32 @@ contain subscripts.
\item A vardef macro can have access to the suffix that follows the macro name
when the macro is called.
\item When a symbolic token is used in the name of a vardef macro it remains
-a tag\index{tags} and can still be used in other variable names. Thus {\tt p5dir}
-is a legal variable name even though {\tt dir} is a vardef macro, but an ordinary
-macro such as {\tt ...}\index{...?\texttt{...}} cannot be used in a variable name.
-(This is fortunate since {\tt z5...z6} is supposed to be a path expression, not
-an elaborate variable name).
+a tag\index{tags} and can still be used in other variable names. Thus
+{\tt p5dir} is a legal variable name even though {\tt dir} is a vardef
+macro, but an ordinary macro such as {\tt ...}\index{...?\texttt{...}}
+cannot be used in a variable name. (This is fortunate since {\tt
+z5...z6} is supposed to be a path expression, not an elaborate variable
+name).
\end{itemize}
\subsection{Defining Unary and Binary Macros}
-It has been mentioned several times that some of the operators and commands
-discussed so far are actually predefined macros. These include unary operators
-such as {\tt round}\index{round?\texttt{round}} and {\tt unitvector}\index{unitvector?\texttt{unitvector}},
-statements such as {\tt fill}\index{fill?\texttt{fill}} and {\tt draw}\index{draw?\texttt{draw}},
-and binary operators such as {\tt dotprod}\index{dotprod?\texttt{dotprod}} and
-{\tt intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}}. The main difference
-between these macros and the ones we already know how to define is their argument
-syntax.
+It has been mentioned several times that some of the operators and
+commands discussed so far are actually predefined macros. These include
+unary operators such as {\tt round}\index{round?\texttt{round}} and {\tt
+unitvector}\index{unitvector?\texttt{unitvector}}, statements such as
+{\tt fill}\index{fill?\texttt{fill}} and {\tt
+draw}\index{draw?\texttt{draw}}, and binary operators such as {\tt
+dotprod}\index{dotprod?\texttt{dotprod}} and {\tt
+intersectionpoint}\index{intersectionpoint?\texttt{intersectionpoint}}.
+The main difference between these macros and the ones we already know
+how to define is their argument syntax.
The {\tt round} and {\tt unitvector} macros are examples of what
-Figure~\ref{syexpr} calls \tdescr{unary op}. That is, they are followed by a
-primary expression. To specify a macro argument of this type, the macro definition
-should look like this:
+Figure~\ref{syexpr} calls \tdescr{unary op}. That is, they are followed
+by a primary expression. To specify a macro argument of this type, the
+macro definition should look like this:
$$ \hbox{\tt vardef round primary u =}\, \descr{replacement text}\,
\hbox{\tt enddef;}
$$
@@ -3354,14 +3807,16 @@ syntax.
As the {\tt round} example suggests, a macro can be defined to take a
\tdescr{secondary}\index{secondary?\tdescr{secondary}},
\tdescr{tertiary}\index{tertiary?\tdescr{tertiary}}, or an
-\tdescr{expression}\index{expression?\tdescr{expression}} parameter. For example, the
-predefined definition of the {\tt fill} macro is roughly\index{fill?\texttt{fill}}
+\tdescr{expression}\index{expression?\tdescr{expression}} parameter.
+For example, the predefined definition of the {\tt fill} macro is
+roughly\index{fill?\texttt{fill}}
$$ \hbox{\tt def fill expr c = addto currentpicture contour c enddef;} $$
-It is even possible to define a macro to play the role of
-\tdescr{of operator}\index{of operator?\tdescr{of operator}} in Figure~\ref{syexpr}.
-For example, the {\tt direction of}\index{direction of?\texttt{direction of}} macro has a definition
-of this form:
+It is even possible to define a macro to play the role of \tdescr{of
+operator}\index{of operator?\tdescr{of operator}} in
+Figure~\ref{syexpr}. For example, the {\tt direction
+of}\index{direction of?\texttt{direction of}} macro has a definition of
+this form:
$$ \hbox{\tt vardef direction expr t of p =}\, \descr{replacement text}\,
\hbox{\tt enddef;}
$$
@@ -3372,25 +3827,28 @@ form\index{dotprod?\texttt{dotprod}}\index{primarydef?\texttt{primarydef}}
$$ \hbox{\tt primarydef w dotprod z =}\, \descr{replacement text}\,
\hbox{\tt enddef;}
$$
-This makes {\tt dotprod} a \tdescr{primary binop}\index{primary binop?\tdescr{primary binop}}.
-Similarly, {\tt secondarydef}\index{secondarydef?\texttt{secondarydef}} and
-{\tt tertiarydef}\index{tertiarydef?\texttt{tertiarydef}} introduce
-\tdescr{secondary binop}\index{secondary binop?\tdescr{secondary binop}} and
-\tdescr{tertiary binop}\index{tertiary binop?\tdescr{tertiary binop}} definitions. These all
-define ordinary macros, not vardef macros; e.g., there is
-no ``{\tt primaryvardef}.''
+This makes {\tt dotprod} a \tdescr{primary binop}\index{primary
+binop?\tdescr{primary binop}}. Similarly, {\tt
+secondarydef}\index{secondarydef?\texttt{secondarydef}} and {\tt
+tertiarydef}\index{tertiarydef?\texttt{tertiarydef}} introduce
+\tdescr{secondary binop}\index{secondary binop?\tdescr{secondary binop}}
+and \tdescr{tertiary binop}\index{tertiary binop?\tdescr{tertiary
+binop}} definitions. These all define ordinary macros, not vardef
+macros; e.g., there is no ``{\tt primaryvardef}.''
Thus macro definitions can be introduced by {\tt def}, {\tt vardef},
-{\tt primarydef}, {\tt secondarydef}, or {\tt tertiarydef}.
-A \tdescr{replacement text}\index{replacement text?\tdescr{replacement text}} is any list of tokens
-that is balanced with respect to {\tt def}-{\tt enddef} pairs where all five macro
-definition tokens are treated like {\tt def} for the purpose of
-{\tt def}-{\tt enddef} matching.
-
-The rest of the syntax for macro definitions is summarized in Figure~\ref{symacro}.
-The syntax contains a few surprises. The macro parameters can have a
-\tdescr{delimited part} and an \tdescr{undelimited part}. Normally, one of
-these is \tdescr{empty}, but it is possible to have both parts nonempty:
+{\tt primarydef}, {\tt secondarydef}, or {\tt tertiarydef}. A
+\tdescr{replacement text}\index{replacement text?\tdescr{replacement
+text}} is any list of tokens that is balanced with respect to {\tt
+def}-{\tt enddef} pairs where all five macro definition tokens are
+treated like {\tt def} for the purpose of {\tt def}-{\tt enddef}
+matching.
+
+The rest of the syntax for macro definitions is summarized in
+Figure~\ref{symacro}. The syntax contains a few surprises. The macro
+parameters can have a \tdescr{delimited part} and an \tdescr{undelimited
+part}. Normally, one of these is \tdescr{empty}, but it is possible to
+have both parts nonempty:
$$ \hbox{\tt def foo(text a) expr b =}\, \descr{replacement text}\,
\hbox{\tt enddef;}
$$
@@ -3429,34 +3887,38 @@ $\tt \descr{binary def} \rightarrow primarydef \;|\; secondarydef \;|\;
\label{symacro}
\end{figure}
-The syntax also allows the \tdescr{undelimited part} to specify an argument type
-of {\tt suffix}\index{suffix?\texttt{suffix}} or {\tt text}\index{text?\texttt{text}}. An example of
-a macro with an undelimited suffix parameter\index{parameter!suffix}
-is the predefined macro {\tt incr}\index{incr?\texttt{incr}}\label{Dincr} that is actually
+The syntax also allows the \tdescr{undelimited part} to specify an
+argument type of {\tt suffix}\index{suffix?\texttt{suffix}} or {\tt
+text}\index{text?\texttt{text}}. An example of a macro with an
+undelimited suffix parameter\index{parameter!suffix} is the predefined
+macro {\tt incr}\index{incr?\texttt{incr}}\label{Dincr} that is actually
defined like this:
$$ \hbox{\verb|vardef incr suffix $ = $:=$+1; $ enddef;|} $$
-This makes {\tt incr} a function that takes a variable, increments it, and
-returns the new value. Undelimited suffix parameters may be parenthesized,
-so {\tt incr a} and {\tt incr(a)} are both legal if {\tt a} is a numeric
-variable. There is also a similar predefined macro {\tt decr}\index{decr?\texttt{decr}}
-that subtracts~1.
-
-Undelimited text parameters\index{parameter!text} run to the end of a statement.
-More precisely, an undelimited text parameter is the list of tokens following the
-macro call up to the first ``{\tt ;}\index{semicolon}'' or
-``{\tt endgroup}\index{endgroup?\texttt{endgroup}}'' or ``{\tt end}\index{end?\texttt{end}}''
-except that an argument containing ``{\tt begingroup}'' will always
-include the matching ``{\tt endgroup}.''
-An example of an undelimited text parameter comes from the predefined macro
-{\tt cutdraw}\index{cutdraw?\texttt{cutdraw}}\label{Dctdraw} whose definition is
+This makes {\tt incr} a function that takes a variable, increments it,
+and returns the new value. Undelimited suffix parameters may be
+parenthesized, so {\tt incr a} and {\tt incr(a)} are both legal if {\tt
+a} is a numeric variable. There is also a similar predefined macro {\tt
+decr}\index{decr?\texttt{decr}} that subtracts~1.
+
+Undelimited text parameters\index{parameter!text} run to the end of a
+statement. More precisely, an undelimited text parameter is the list of
+tokens following the macro call up to the first ``{\tt
+;}\index{semicolon}'' or ``{\tt
+endgroup}\index{endgroup?\texttt{endgroup}}'' or ``{\tt
+end}\index{end?\texttt{end}}'' except that an argument containing ``{\tt
+begingroup}'' will always include the matching ``{\tt endgroup}.'' An
+example of an undelimited text parameter comes from the predefined macro
+{\tt cutdraw}\index{cutdraw?\texttt{cutdraw}}\label{Dctdraw} whose
+definition is
roughly\index{linecap?\texttt{linecap}}\index{butt?\texttt{butt}}\index{interim?\texttt{interim}}
$$\begin{verbatim}
def cutdraw text t =
begingroup interim linecap:=butt; draw t; endgroup enddef;
\end{verbatim}
$$
-This makes {\tt cutdraw} synonymous with {\tt draw} except for the {\tt linecap}
-value. (This macro is provided mainly for compatibility with \MF\index{metafont?\MF}.)
+This makes {\tt cutdraw} synonymous with {\tt draw} except for the {\tt
+linecap} value. (This macro is provided mainly for compatibility with
+\MF\index{metafont?\MF}.)
\section{Loops}
@@ -3467,38 +3929,43 @@ $$ {\tt for}\, \descr{symbolic token}\, \hbox{\tt =}\,
\descr{expression}\, {\tt upto}\, \descr{expression}:\
\descr{loop text}\, {\tt endfor}
$$
-It is equally simple to construct a loop that counts downward: just replace
-{\tt upto} by {\tt downto}\index{downto?\texttt{downto}}\label{Ddwnto}
-make the second \tdescr{expression} smaller than the first.
-This section covers more complicated types of progressions, loops where the loop
-counter behaves like a suffix parameter, and ways of exiting from a loop.
-
-The first generalization is suggested by the fact that {\tt upto}\index{upto?\texttt{upto}}
-is a predefined macro for\index{step?\texttt{step}}\index{until?\texttt{until}}
+It is equally simple to construct a loop that counts downward: just
+replace {\tt upto} by {\tt
+downto}\index{downto?\texttt{downto}}\label{Ddwnto} make the second
+\tdescr{expression} smaller than the first. This section covers more
+complicated types of progressions, loops where the loop counter behaves
+like a suffix parameter, and ways of exiting from a loop.
+
+The first generalization is suggested by the fact that {\tt
+upto}\index{upto?\texttt{upto}} is a predefined macro
+for\index{step?\texttt{step}}\index{until?\texttt{until}}
$$ \hbox{\tt step 1 until} $$
-and {\tt downto}\index{downto?\texttt{downto}} is a macro for {\tt step -1 until}.
-A loop begining
+and {\tt downto}\index{downto?\texttt{downto}} is a macro for {\tt step
+-1 until}. A loop begining
$$ \hbox{\tt for i=a step b until c} $$
-scans a sequence of {\tt i} values {\tt a}, ${\tt a}+{\tt b}$, ${\tt a}+2{\tt b}$,
-\ldots, stopping before {\tt i} passes {\tt c}; i.e., the loop scans {\tt i} values
-where ${\tt i}\le {\tt c}$ if ${\tt b}>0$ and ${\tt i}\ge {\tt c}$ if ${\tt i}<0$.
-
-It is best to use this feature only when the step size is an integer or some
-number that can be represented exactly in fixed point arithmetic\index{arithmetic}
-as a multiple of $1\over65536$. Otherwise, error will accumulate and the loop
-index might not reach the expected termination value. For instance,
+scans a sequence of {\tt i} values {\tt a}, ${\tt a}+{\tt b}$, ${\tt
+a}+2{\tt b}$, \ldots, stopping before {\tt i} passes {\tt c}; i.e., the
+loop scans {\tt i} values where ${\tt i}\le {\tt c}$ if ${\tt b}>0$ and
+${\tt i}\ge {\tt c}$ if ${\tt i}<0$.
+
+It is best to use this feature only when the step size is an integer or
+some number that can be represented exactly in fixed point
+arithmetic\index{arithmetic} as a multiple of $1\over65536$. Otherwise,
+error will accumulate and the loop index might not reach the expected
+termination value. For instance,
$$ \hbox{\tt for i=0 step .1 until 1: show i; endfor} $$
shows ten {\tt i} values the last of which is 0.90005.
-The standard way of avoid the problems associated with non-integer step sizes is
-to iterate over integer values and then multiply by a scale factor when using
-the loop index as was done in Figures \ref{fig1} and~\ref{fig40}.
+The standard way of avoid the problems associated with non-integer step
+sizes is to iterate over integer values and then multiply by a scale
+factor when using the loop index as was done in Figures \ref{fig1}
+and~\ref{fig40}.
-Alternatively, the values to iterate over can be given explicitly. Any sequence
-of zero or more expressions separated by commas can be used in place of
-{\tt a step b upto c}. In fact, the expressions need not all be the same type
-and they need not have known values. Thus
-$$ \hbox{\tt for t=3.14, 2.78, (a,2a), "hello": show a; endfor} $$
+Alternatively, the values to iterate over can be given explicitly. Any
+sequence of zero or more expressions separated by commas can be used in
+place of {\tt a step b upto c}. In fact, the expressions need not all
+be the same type and they need not have known values. Thus
+$$ \hbox{\tt for t=3.14, 2.78, (a,2a), "hello": show t; endfor} $$
shows the four values listed.
Note that the loop body in the above example is a statement followed by a
@@ -3511,22 +3978,23 @@ is equivalent to
$$ \hbox{\tt draw (3,1)--(6,2)--(7,5)--(4,6)--(1,3)--cycle;} $$
(See Figure~\ref{fig17} for a more realistic example of this.)
-If a loop is like a macro definition, the loop index is like an
-expr parameter\index{parameter!expr}. It can represent any value, but it is
+If a loop is like a macro definition, the loop index is like an expr
+parameter\index{parameter!expr}. It can represent any value, but it is
not a variable and it cannot be changed by an assignment
-statement\index{assignment}. In order to do that, you need a
-{\tt forsuffixes}\index{forsuffixes?\texttt{forsuffixes}} loop. A {\tt forsuffixes} loop is
-a lot like a {\tt for} loop, except the loop index behaves like a
-suffix parameter\index{parameter!suffix}. The syntax is
+statement\index{assignment}. In order to do that, you need a {\tt
+forsuffixes}\index{forsuffixes?\texttt{forsuffixes}} loop. A {\tt
+forsuffixes} loop is a lot like a {\tt for} loop, except the loop index
+behaves like a suffix parameter\index{parameter!suffix}. The syntax is
$$ {\tt forsuffixes}\, \descr{symbolic token}\, \hbox{\tt =}\,
\descr{suffix list}:\ \descr{loop text}\, {\tt endfor}
$$
-where a \tdescr{suffix list} is a comma-separated list of suffixes.
-If some of the suffixes are \tdescr{empty}, the \tdescr{loop text} gets executed
-with the loop index parameter set to the empty suffix.
+where a \tdescr{suffix list} is a comma-separated list of suffixes. If
+some of the suffixes are \tdescr{empty}, the \tdescr{loop text} gets
+executed with the loop index parameter set to the empty suffix.
-A good example of a {\tt forsuffixes} loop is the definition of the
-{\tt dotlabels}\index{dotlabels?\texttt{dotlabels}} macro\index{str?\texttt{str}}:
+A good example of a {\tt forsuffixes} loop is the definition of the {\tt
+dotlabels}\index{dotlabels?\texttt{dotlabels}}
+macro\index{str?\texttt{str}}:
$$\begin{verbatim}
vardef dotlabels@#(text t) =
forsuffixes $=t: dotlabel@#(str$,z$); endfor enddef;
@@ -3544,10 +4012,11 @@ $$ {\tt forever}\hbox{\tt :}\, \descr{loop text}\, {\tt endfor} $$
To terminate such a loop when a boolean condition becomes true, use an exit
clause\index{exitif?\texttt{exitif}}:
$$ {\tt exitif}\, \descr{boolean expression} \hbox{\tt ;} $$
-When the MetaPost interpreter encounters an exit clause, it evaluates the
-\tdescr{boolean expression} and exits the current loop if the expression is
-true. If it is more convenient to exit the loop when an expression becomes false,
-use the predefined macro {\tt exitunless}\index{exitunless?\texttt{exitunless}}.
+When the MetaPost interpreter encounters an exit clause, it evaluates
+the \tdescr{boolean expression} and exits the current loop if the
+expression is true. If it is more convenient to exit the loop when an
+expression becomes false, use the predefined macro {\tt
+exitunless}\index{exitunless?\texttt{exitunless}}.
Thus MetaPost's version of a {\bf while} loop is
$$ \hbox{\tt forever: exitunless}\, \descr{boolean expression} \hbox{\tt ;}\,
@@ -3558,10 +4027,11 @@ in the \tdescr{loop text}. In fact any {\tt for}, {\tt forever}, or
{\tt forsuffixes} loop can contain any number of exit clauses.
The summary of loop syntax shown in Figure~\ref{syloop} does not mention
-exit clauses explicitly because a \tdescr{loop text} can be virtually any
-sequence of tokens. The only restriction is that a \tdescr{loop text} must
-be balanced with respect to {\tt for} and {\tt endfor}. Of course this balancing
-process treats {\tt forsuffixes} and {\tt forever} just like {\tt for}.
+exit clauses explicitly because a \tdescr{loop text} can be virtually
+any sequence of tokens. The only restriction is that a \tdescr{loop
+text} must be balanced with respect to {\tt for} and {\tt endfor}. Of
+course this balancing process treats {\tt forsuffixes} and {\tt forever}
+just like {\tt for}.
\begin{figure}[htp]
\begin{ctabbing}
@@ -3593,16 +4063,16 @@ $\tt \descr{suffix list} \rightarrow \descr{suffix}
\section{Making Boxes}
\label{boxessec}
-This section describes auxiliary macros not included in Plain MetaPost that
-make it convenient to do things that {\it pic} is good at \cite{ke:pic}. What
-follows is a description of how to use the macros contained in the
-file {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}}. This file is included in a special
-directory reserved for MetaPost macros and support software\footnote{The name
-of this directory is likely to be something like \verb|/usr/lib/mp/lib|, but
-this is system dependent.}
-and can be accessed by giving the MetaPost command {\tt input boxes} before any
-figures that use the box making macros.
-The syntax for the {\tt input} command is \index{input?\texttt{input}}
+This section describes auxiliary macros not included in Plain MetaPost
+that make it convenient to do things that {\it pic} is good at
+\cite{ke:pic}. What follows is a description of how to use the macros
+contained in the file {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}}.
+This file is included in a special directory reserved for MetaPost
+macros and support software\footnote{The name of this directory is
+likely to be something like \verb|/usr/lib/mp/lib|, but this is system
+dependent.} and can be accessed by giving the MetaPost command {\tt
+input boxes} before any figures that use the box making macros. The
+syntax for the {\tt input} command is \index{input?\texttt{input}}
$$ {\tt input}\, \descr{file name} $$
where a final ``{\tt .mp}'' can be omitted from the file name. The {\tt input}
command looks first in the current directory and then in the special macro
@@ -3628,39 +4098,42 @@ The argument to {\tt drawboxed} should be a comma-separated list of box names,
where a box name\index{box name} is a \tdescr{suffix} with which {\tt boxit}
has been called.
-For the command {\tt boxit.bb(pic)}, the box name is {\tt bb} and the contents
-of the box is the picture {\tt pic}. In this case, {\tt bb.c} the position
-where the center of picture {\tt pic} is to be placed, and {\tt bb.sw},
-{\tt bb.se}, {\tt bb.ne}, and {\tt bb.nw} are the corners of a rectangular path
-that will surround the resulting picture. Variables {\tt bb.dx} and {\tt bb.dy}
-give the spacing between the shifted version of {\tt pic} and the surrounding
-rectangle, and {\tt bb.off} is the amount by which {\tt pic} has to be shifted
-to achieve all this.
-
-When the {\tt boxit} macro is called with box name~$b$, it gives linear equations
-that force $b${\tt.sw}, $b${\tt.se}, $b${\tt.ne}, and $b${\tt.nw} to be the
-corners of a rectangle
-aligned on the $x$ and $y$ axes with the box contents centered inside as
-indicated by the gray rectangle in Figure~\ref{fig48}. The values of $b${\tt.dx},
-$b${\tt.dy}, and $b${\tt.c} are left unspecified so that the user can give
-equations for positioning the boxes. If no such equations are given, macros
-such as {\tt drawboxed} can detect this and give default values.
-The default values for {\tt dx} and {\tt dy} variables are controlled by the
-internal variables\index{internal variables}\index{variables!internal}
-{\tt defaultdx}\index{defaultdx?\texttt{defaultdx}}\label{Ddefaultdx} and
+For the command {\tt boxit.bb(pic)}, the box name is {\tt bb} and the
+contents of the box is the picture {\tt pic}. In this case, {\tt bb.c}
+the position where the center of picture {\tt pic} is to be placed, and
+{\tt bb.sw}, {\tt bb.se}, {\tt bb.ne}, and {\tt bb.nw} are the corners
+of a rectangular path that will surround the resulting picture.
+Variables {\tt bb.dx} and {\tt bb.dy} give the spacing between the
+shifted version of {\tt pic} and the surrounding rectangle, and {\tt
+bb.off} is the amount by which {\tt pic} has to be shifted to achieve
+all this.
+
+When the {\tt boxit} macro is called with box name~$b$, it gives linear
+equations that force $b${\tt.sw}, $b${\tt.se}, $b${\tt.ne}, and
+$b${\tt.nw} to be the corners of a rectangle aligned on the $x$ and $y$
+axes with the box contents centered inside as indicated by the gray
+rectangle in Figure~\ref{fig48}. The values of $b${\tt.dx},
+$b${\tt.dy}, and $b${\tt.c} are left unspecified so that the user can
+give equations for positioning the boxes. If no such equations are
+given, macros such as {\tt drawboxed} can detect this and give default
+values. The default values for {\tt dx} and {\tt dy} variables are
+controlled by the internal variables\index{internal
+variables}\index{variables!internal} {\tt
+defaultdx}\index{defaultdx?\texttt{defaultdx}}\label{Ddefaultdx} and
{\tt defaultdy}\index{defaultdy?\texttt{defaultdy}}\label{Ddefaultdy}.
\begin{figure}[htp]
-$$ \epsfbox{manfig.48} $$
+$$ \includegraphics{manfig-48} $$
\caption[How a {\tt boxit} picture relates to the associated variables]
{The relationship between the picture given to {\tt boxit} and the
associated variables. The picture is indicated by a gray rectangle.}
\label{fig48}
\end{figure}
-If $b$ represents a box name, {\tt drawboxed($b$)} draws the rectangular boundary
-of box~$b$ and then the contents of the box. This bounding rectangle can be
-accessed separately as {\tt bpath~b}, or in general\index{bpath?\texttt{bpath}}\label{Dbpath}
+If $b$ represents a box name, {\tt drawboxed($b$)} draws the rectangular
+boundary of box~$b$ and then the contents of the box. This bounding
+rectangle can be accessed separately as {\tt bpath~$b$}, or in
+general\index{bpath?\texttt{bpath}}\label{Dbpath}
$$ {\tt bpath}\, \descr{box name} $$
It is useful in combination with operators like
{\tt cutbefore}\index{cutbefore?\texttt{cutbefore}} and {\tt cutafter}\index{cutafter?\texttt{cutafter}}
@@ -3670,10 +4143,11 @@ to $b${\tt.c},\index{drawarrow?\texttt{drawarrow}}
$$ \hbox{\tt drawarrow $p$ cutbefore bpath $a$ cutafter bpath $b$} $$
draws an arrow from the edge of box $a$ to the edge of box $b$.
-Figure~\ref{fig49} shows a practical example including some arrows drawn with
-{\tt cutafter bpath} \tdescr{box name}. It is
-instructive to compare Figure~\ref{fig49} to the similar figure in the pic
-manual \cite{ke:pic}. The figure uses a macro\index{boxjoin?\texttt{boxjoin}}\label{Dbxjoin}
+Figure~\ref{fig49} shows a practical example including some arrows drawn
+with {\tt cutafter bpath} \tdescr{box name}. It is instructive to
+compare Figure~\ref{fig49} to the similar figure in the pic manual
+\cite{ke:pic}. The figure uses a
+macro\index{boxjoin?\texttt{boxjoin}}\label{Dbxjoin}
$$ \hbox{\tt boxjoin(} \descr{equation text} \hbox{\tt )} $$
to control the relationship between consecutive boxes. Within the
\tdescr{equation text}, {\tt a} and {\tt b} represent the box names given in
@@ -3719,7 +4193,7 @@ drawarrow subpath (0,.7) of (z.ptr..{left}ndc3.c) dashed evenly;
label.rt(btex \strut ndblock etex, z.ptr); endfig;
\end{verbatim}
$}
-\atop \vcenter{\vskip8pt\hbox{\epsfbox{manfig.49}}}
+\atop \vcenter{\vskip8pt\hbox{\includegraphics{manfig-49}}}
$$
\caption{MetaPost code and the corresponding figure}
\label{fig49}
@@ -3735,43 +4209,47 @@ $$ \hbox{\tt a.se=ni.sw; a.ne=ni.nw} $$
The next pair of boxes is box~{\tt ni} and box~{\tt di}. This time the
implicitly generated equations are
$$ \hbox{\tt ni.se=di.sw; ni.ne=di.nw} $$
-This process continues until a new {\tt boxjoin}\index{boxjoin?\texttt{boxjoin}} is given.
-In this case the new declaration is
+This process continues until a new {\tt
+boxjoin}\index{boxjoin?\texttt{boxjoin}} is given. In this case the new
+declaration is
$$ \hbox{\tt boxjoin(a.sw=b.nw; a.se=b.ne)} $$
which causes boxes to be stacked below each other.
-After calling {\tt boxit} for the first eight boxes {\tt a} through {\tt dk},
-the box heights are constrained to match but the widths are still unknown.
-Thus the {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}} macro needs to assign default
-values to the \tdescr{box name}{\tt.dx} and \tdescr{box name}{\tt.dy}
-variables. First, {\tt di.dx} and {\tt di.dy} get default values so that all
-the boxes are forced to be large enough to contain the contents of box~{\tt di}.
-
-The macro that actually assigns default values to {\tt dx} and {\tt dy} variables
-is called {\tt fixsize}\index{fixsize?\texttt{fixsize}}\label{Dfixsiz}.
-It takes a list of box names and
-considers them one at a time, making sure that each box has a fixed size and
-shape. A macro called {\tt fixpos}\index{fixpos?\texttt{fixpos}}\label{Dfixpos} then takes
-this same list
-of box names and assigns default values to the \tdescr{box name}{\tt.off}
-variables as needed to fix the position of each box. By using {\tt fixsize}
-to fix the dimensions of each box before assigning default positions to any
-of them, the number of needing default positions can usually be cut to at most
-one.
-
-Since the bounding path for a box cannot be computed until the size, shape, and
-position of the box is determined, the {\tt bpath}\index{bpath?\texttt{bpath}} macro applies
-{\tt fixsize} and {\tt fixpos} to its argument. Other macros that do this
+After calling {\tt boxit} for the first eight boxes {\tt a} through {\tt
+dk}, the box heights are constrained to match but the widths are still
+unknown. Thus the {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}}
+macro needs to assign default values to the \tdescr{box name}{\tt.dx}
+and \tdescr{box name}{\tt.dy} variables. First, {\tt di.dx} and {\tt
+di.dy} get default values so that all the boxes are forced to be large
+enough to contain the contents of box~{\tt di}.
+
+The macro that actually assigns default values to {\tt dx} and {\tt dy}
+variables is called {\tt
+fixsize}\index{fixsize?\texttt{fixsize}}\label{Dfixsiz}. It takes a
+list of box names and considers them one at a time, making sure that
+each box has a fixed size and shape. A macro called {\tt
+fixpos}\index{fixpos?\texttt{fixpos}}\label{Dfixpos} then takes this
+same list of box names and assigns default values to the \tdescr{box
+name}{\tt.off} variables as needed to fix the position of each box. By
+using {\tt fixsize} to fix the dimensions of each box before assigning
+default positions to any of them, the number of needing default
+positions can usually be cut to at most one.
+
+Since the bounding path for a box cannot be computed until the size,
+shape, and position of the box is determined, the {\tt
+bpath}\index{bpath?\texttt{bpath}} macro applies {\tt fixsize} and {\tt
+fixpos} to its argument. Other macros that do this
include\index{pic?\texttt{pic}}\label{Dpic}
$$ {\tt pic}\, \descr{box name} $$
where the \tdescr{box name} is a suffix, possibly in parentheses. This returns
the contents of the named box as a picture positioned so that
$$ {\tt draw\ pic} \descr{box name} $$
-draws the box contents without the bounding rectangle. This operation can also
-be accomplished by the {\tt drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}\label{Ddrunbx}
+draws the box contents without the bounding rectangle. This operation
+can also be accomplished by the {\tt
+drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}\label{Ddrunbx}
macro that takes a comma-separated list of box names. There is also a
-{\tt drawboxes}\index{drawboxes?\texttt{drawboxes}}\label{Ddrbxes} macro that draws just the
-bounding rectangles.
+{\tt drawboxes}\index{drawboxes?\texttt{drawboxes}}\label{Ddrbxes} macro
+that draws just the bounding rectangles.
Another way to draw empty rectangles is by just saying\label{Deboxit}
$$ {\tt boxit} \descr{box name} \hbox{\tt ()} $$
@@ -3797,29 +4275,30 @@ The {\tt circleit} macro defines pair variable just as {\tt boxit} does, except
that there are no corner points \tdescr{box name}{\tt.ne},
\tdescr{box name}{\tt.sw}, etc. A call to
$$ \hbox{\tt circleit.a(}\ldots \hbox{\tt )} $$
-gives relationships among points {\tt a.c}, {\tt a.s},
-{\tt a.e}, {\tt a.n}, {\tt a.w}
-and distances {\tt a.dx} and {\tt a.dy}. Together with {\tt a.c} and {\tt a.off},
-these variables describe how the picture is centered in an oval as can be seen
-from the Figure~\ref{fig50}.
+gives relationships among points {\tt a.c}, {\tt a.s}, {\tt a.e}, {\tt
+a.n}, {\tt a.w} and distances {\tt a.dx} and {\tt a.dy}. Together with
+{\tt a.c} and {\tt a.off}, these variables describe how the picture is
+centered in an oval as can be seen from the Figure~\ref{fig50}.
\begin{figure}[htp]
-$$ \epsfbox{manfig.50} $$
+$$ \includegraphics{manfig-50} $$
\caption[How a {\tt circleit} picture relates to the associated variables]
{The relationship between the picture given to {\tt circleit} and the
associated variables. The picture is indicated by a gray rectangle.}
\label{fig50}
\end{figure}
-The {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}}, {\tt drawunboxed}\index{drawunboxed?\texttt{drawunboxed}},
-{\tt drawboxes}\index{drawboxes?\texttt{drawboxes}}, {\tt pic}\index{pic?\texttt{pic}}, and
-{\tt bpath}\index{bpath?\texttt{bpath}} macros work for {\tt circleit} boxes just as they do
-for {\tt boxit} boxes. By default, the boundary path for a {\tt circleit} box is
-a circle large enough to surround the box contents with a small safety margin
-controlled by the
-internal variable\index{internal variables}\index{variables!internal}
-{\tt circmargin}\label{Dcmargin}. Figure~\ref{fig51} gives
-a basic example of the use of {\tt bpath} with {\tt circleit} boxes.
+The {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}}, {\tt
+drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}, {\tt
+drawboxes}\index{drawboxes?\texttt{drawboxes}}, {\tt
+pic}\index{pic?\texttt{pic}}, and {\tt
+bpath}\index{bpath?\texttt{bpath}} macros work for {\tt circleit} boxes
+just as they do for {\tt boxit} boxes. By default, the boundary path
+for a {\tt circleit} box is a circle large enough to surround the box
+contents with a small safety margin controlled by the internal
+variable\index{internal variables}\index{variables!internal} {\tt
+circmargin}\label{Dcmargin}. Figure~\ref{fig51} gives a basic example
+of the use of {\tt bpath} with {\tt circleit} boxes.
\begin{figure}[htbp]
$$\begin{verbatim}
@@ -3840,10 +4319,10 @@ drawshadowed(a,b);
drawarrow a.s -- b.n;
endfig;
\end{verbatim}
-\qquad \mathcenter{\epsfbox{manfig.51}} $$
-\caption[MetaPost code and the resulting figure.]
- {MetaPost code and the resulting figure. Note that the {\tt drawshadowed}
- macro used here is not part of the {\tt boxit.mp} macro package.}
+\qquad \mathcenter{\includegraphics{manfig-51}} $$
+\caption[MetaPost code and the resulting figure.] {MetaPost code and
+ the resulting figure. Note that the {\tt drawshadowed} macro
+ used here is not part of the {\tt boxes.mp} macro package.}
\label{fig51}
\index{drawshadowed?\texttt{drawshadowed}}
\end{figure}
@@ -3856,10 +4335,11 @@ $$ \hbox{\verb|circleit.ee(btex\strut Stop etex)|}
\quad{\rm and}\quad
\hbox{\verb|circleit.ee(btex\strut Stop etex)|}.
$$
-The general rule is that {\tt bpath.}$c$ comes out circular if $c${\tt.dx},
-$c${\tt.dy}, and $c\hbox{\tt.dx}-c\hbox{\tt.dy}$ are all unknown. Otherwise, the
-macros select an oval big enough to contain the given picture with the safety
-margin {\tt circmargin}\index{circmargin?\texttt{circmargin}}.
+The general rule is that {\tt bpath.}$c$ comes out circular if
+$c${\tt.dx}, $c${\tt.dy}, and $c\hbox{\tt.dx}-c\hbox{\tt.dy}$ are all
+unknown. Otherwise, the macros select an oval big enough to contain the
+given picture with the safety margin {\tt
+circmargin}\index{circmargin?\texttt{circmargin}}.
\begin{figure}[htp]
@@ -3897,7 +4377,7 @@ label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c);
endfig;
\end{verbatim}
$}
-\atop \vcenter{\vskip8pt\hbox{\epsfbox{manfig.52}}}
+\atop \vcenter{\vskip8pt\hbox{\includegraphics{manfig-52}}}
$$
\caption{MetaPost code and the corresponding figure}
\label{fig52}
@@ -3905,24 +4385,150 @@ $$
\end{figure}
+\section{Utility Routines}
+
+\index{utility routines}
+\index{mplib?\texttt{mplib}}
+\index{metapost/base?\texttt{metapost/base}}
+
+This section describes some of the utility routines included in the
+\texttt{mplib} directory of the development source hierarchy. Future
+versions of this documentation may include more; meanwhile, please read
+the source files, most have explanatory comments at the top. They are
+also included in the MetaPost and larger \TeX\ distributions, typically
+in a \texttt{texmf/metapost/base} directory.
+
+
+\subsection{\texttt{TEX.mp}}
+
+\label{dTEX}
+\index{TEX.mp?\texttt{TEX.mp}}
+\index{labels, with variable text}
+\index{string expressions, as labels}
+
+\texttt{TEX.mp} provides a way to typeset the text of a MetaPost string
+expression. Suppose, for example, you need labels of the form $n_0$,
+$n_1$, \ldots, $n_{10}$ across the $x$ axis. You can do this (relatively)
+conveniently with \texttt{TEX.mp}, as follows:
+$$\begin{verbatim}
+input TEX;
+beginfig(100)
+ last := 10;
+ for i := 0 upto last:
+ label(TEX("$n_{" & decimal(i) & "}$"), (5mm*i,0));
+ endfor
+ ...
+endfig;
+\end{verbatim}
+$$
+In contrast, the basic \texttt{btex} command (see p.\ \pageref{Dbtex})
+typesets verbatim text. That is, \texttt{btex~s~etex} typesets the
+literal character `s'; \texttt{TEX(s)} typesets the value of the
+MetaPost text variable~$s$.
+
+\index{latex?\LaTeX, typesetting labels with} In version 0.9,
+\texttt{TEX.mp} acquired two additional routines to facilitate using
+\LaTeX\ to typeset labels: \texttt{TEXPRE} and \texttt{TEXPOST}. Their
+values are remembered, and included before and after (respectively) each
+call to \texttt{TEX}. Otherwise, each \texttt{TEX} call is effectively
+typeset independently. \texttt{TEX} calls also do not interfere with
+uses of \ttindex{verbatimtex} (p.\ \pageref{Dverbatimtex}).
+
+Here's the same example as above, using the \LaTeX\ commands \verb|\(|
+and \verb|\)|:
+
+$$\begin{verbatim}
+input TEX;
+TEXPRE("%&latex" & char(10) & "\documentclass{article}\begin{document}");
+TEXPOST("\end{document}");
+beginfig(100)
+ last := 10;
+ for i := 0 upto last:
+ label(TEX("\( n_{" & decimal(i) & "} \)"), (5mm*i,0));
+ endfor
+ ...
+endfig;
+\end{verbatim}
+$$
+Explanation:
+\begin{itemize}
+
+\item
+The \texttt{\%\&latex} causes \LaTeX\ to be invoked instead of \TeX.
+(See below, also.) Web2C- and MiKTeX-based \TeX\ implementations, at
+least, understand this \texttt{\%\&} specification; see, e.g., the Web2C
+documentation for details, \url{http://tug.org/web2c}. (Information on
+how to do the same with other systems would be most welcome.)
+
+\item
+The \texttt{char(10)} puts a newline (ASCII character code 10, decimal)
+in the output.
+
+\item
+The \verb|\documentclass...| is the usual way to start a \LaTeX\
+document.
+
+\item
+The \verb|TEXPOST("\end{document}")| is not strictly necessary, due to
+the behavior of \texttt{mpto}, but it is safer to include it.
+
+\end{itemize}
+
+Unfortunately, \TeX\ \verb|\special| instructions vanish in this
+process. So it is not possible to use packages such as \texttt{xcolor}
+and \texttt{hyperref}.
+
+In case you're curious, these routines are implemented very simply: they
+write \texttt{btex} commands to a temporary file and then use
+\texttt{scantokens} (p.\ \pageref{Dscantokens}) to process it. The
+\texttt{makempx} mechanism (p.\ \pageref{Dmakempx}) does all the work of
+running \TeX.
+
+The \verb|%&| magic on the first line is not the only way to specify
+invoking a different program than (plain) \TeX. It has the advantage of
+maximum flexibility: different \texttt{TEX} constructs can use different
+\TeX\ processors. But at least two other methods are possible:
+
+\begin{itemize}
+\item Set the environment variable \texttt{TEX} to \texttt{latex}---or
+whatever processor you want to invoke. (To handle \ConTeXt\ fragments,
+\ttt{texexec} could be used.) This might be convenient when writing a
+script, or working on a project that always requires \texttt{latex}.
+
+\item Invoke MetaPost with the command-line option \ttt{-tex=latex} (or
+whatever processor, of course). This might be useful from a Makefile,
+or just a one-off run.
+\end{itemize}
+
+\subsection{\texttt{mproof.tex}}
+
+\index{mproof.tex?\texttt{mproof.tex}}
+
+\texttt{mproof.tex} is a (plain) \TeX\ routine, not MetaPost at all. It
+writes a proof sheet for MetaPost output. Call it like this:
+
+$$\hbox{\tt tex mproof {\sl MetaPost-output-filename}}$$
+Then process the resulting \texttt{dvi} file as usual.
+
\section{Debugging}
-MetaPost inherits from \MF\index{metafont?\MF} numerous facilities for interactive
-debugging, most of which can only be mentioned briefly here. Further information
-on error messages, debugging, and generating tracing information can be found in
-{\it The\ \MF book} \cite{kn:c}.
+MetaPost inherits from \MF\index{metafont?\MF} numerous facilities for
+interactive debugging, most of which can only be mentioned briefly here.
+Further information on error messages, debugging, and generating tracing
+information can be found in {\sl The\ \MF book} \cite{kn:c}.
Suppose your input file says
$$ \hbox{\tt draw z1--z2;} $$
on line 17 without first giving known values to {\tt z1} and {\tt z2}.
-Figure~\ref{errmsg} shows what the MetaPost interpreter prints on your terminal
-when it finds the error. The actual error message is the line beginning with
-``{\tt !}''; the next six lines give the context that shows exactly what input
-was being read when the error was found; and the ``{\tt ?}'' on last line is a
-prompt for your response. Since the error message talks about an undefined
-$x$~coordinate, this value is printed on the first line after the ``{\tt >>}''.
-In this case the $x$~coordinate of {\tt z1} is just the unknown variable {\tt x1},
-so the interpreter prints the variable name {\tt x1} just as it would if it
+Figure~\ref{errmsg} shows what the MetaPost interpreter prints on your
+terminal when it finds the error. The actual error message is the line
+beginning with ``{\tt !}''; the next six lines give the context that
+shows exactly what input was being read when the error was found; and
+the ``{\tt ?}'' on last line is a prompt for your response. Since the
+error message talks about an undefined $x$~coordinate, this value is
+printed on the first line after the ``{\tt >>}''. In this case the
+$x$~coordinate of {\tt z1} is just the unknown variable {\tt x1}, so the
+interpreter prints the variable name {\tt x1} just as it would if it
were told to\index{show?\texttt{show}} ``{\tt show x1}'' at this point.
\begin{figure}[htp]
@@ -3949,35 +4555,36 @@ Each line of input is printed on two lines like this:
\descr{descriptor}\ \hbox{Text read so far} \\
&& \hbox{Text yet to be read}
\end{eqnarray*}
-The \tdescr{descriptor} identifies the input source. It is either a line number
-like ``{\tt l.17}'' for line 17 of the current file; or it can be a macro name
-followed by ``{\tt ->}''; or it is a descriptive phrase in angle brackets.
-Thus, the meaning of the context listing in Figure~\ref{errmsg} is that the
-interpreter has just read line 17 of the input file up to ``{\tt --},'' the
-expansion of the {\tt --} macro has just started, and the initial
-``\verb|{|'' has been reinserted to allow for user input before scanning
-this token.
+The \tdescr{descriptor} identifies the input source. It is either a
+line number like ``{\tt l.17}'' for line 17 of the current file; or it
+can be a macro name followed by ``{\tt ->}''; or it is a descriptive
+phrase in angle brackets. Thus, the meaning of the context listing in
+Figure~\ref{errmsg} is that the interpreter has just read line 17 of the
+input file up to ``{\tt --},'' the expansion of the {\tt --} macro has
+just started, and the initial ``\verb|{|'' has been reinserted to allow
+for user input before scanning this token.
Among the possible responses to a {\tt ?} prompt are the following:
\begin{description}
-\item[x] terminates the run so that you can fix you input file and start over.
+\item[x] terminates the run so that you can fix your input file and start over.
\item[h] prints a help message followed by another {\tt ?} prompt.
\item[\tdescr{return}] causes the interpreter to proceed as best it can.
\item[?] prints a listing of the options available, followed by another
{\tt ?} prompt.
\end{description}
-Error messages and responses to {\tt show} commands are also written into the
-transcript\index{files!transcript} file whose name is obtained from the name
-of the main input file by changing ``{\tt .mp}'' to ``{\tt .log}''. When the
-internal variable\index{internal variables}\index{variables!internal}
-{\tt tracingonline}\index{tracingonline?\texttt{tracingonline}} is at its default
-value of zero, some {\tt show} commands print their results in full detail only
-in transcript file.
+Error messages and responses to {\tt show} commands are also written
+into the transcript\index{files!transcript} file whose name is obtained
+from the name of the main input file by changing ``{\tt .mp}'' to ``{\tt
+.log}''. When the internal variable\index{internal
+variables}\index{variables!internal} {\tt
+tracingonline}\index{tracingonline?\texttt{tracingonline}} is at its
+default value of zero, some {\tt show} commands print their results in
+full detail only in the transcript file.
-Only one type of {\tt show}\index{show?\texttt{show}} command has been discussed so far:
-{\tt show} followed by a comma-separated list of expressions prints symbolic
-representations of the expressions.
+Only one type of {\tt show}\index{show?\texttt{show}} command has been
+discussed so far: {\tt show} followed by a comma-separated list of
+expressions prints symbolic representations of the expressions.
The {\tt showtoken}\index{showtoken?\texttt{showtoken}}\label{Dshtok}
command can be used to show the
@@ -3997,10 +4604,11 @@ one of the listed tokens. This even works for {\tt vardef} macros. For
example, {\tt showvariable z} yields
$$ \hbox{\verb|z@#=macro:->begingroup(x(SUFFIX2),y(SUFFIX2))endgroup|} $$
-There is also a {\tt showdependencies}\index{showdependencies?\texttt{showdependencies}}\label{Dshdep}
-command that takes no arguments and prints a list of all {\em dependent} variables
-and how the linear equations given so far make them depend on other variables.
-Thus after
+There is also a {\tt
+showdependencies}\index{showdependencies?\texttt{showdependencies}}\label{Dshdep}
+command that takes no arguments and prints a list of all {\em dependent}
+variables and how the linear equations given so far make them depend on
+other variables. Thus after
$$ \hbox{\tt z2-z1=(5,10); z1+z2=(a,b);} $$
{\tt showdependencies} prints what is shown in Figure~\ref{shdep}. This could
be useful in answering a question like ``What does it mean
@@ -4019,30 +4627,29 @@ $$
\label{shdep}
\end{figure}
-When all else fails, the predefined macro
-{\tt tracingall}\index{tracingall?\texttt{tracingall}}\label{Dtall}
-causes the interpreter to print a detailed listing of everything it is doing.
-Since the tracing information is often quite voluminous, it may be better to use
-the {\tt loggingall}\index{loggingall?\texttt{loggingall}}\label{Dlogall}
-macro that produces the same information
-but only writes it in the transcript\index{files!transcript} file. There is also
-a {\tt tracingnone}\index{tracingnone?\texttt{tracingnone}}\label{Dtnone}
-macro that turns off all the tracing output.
-
-Tracing output is controlled by the set of
-internal variables\index{internal variables}\index{variables!internal}
-summarized below.
-When any one of these variables is given a positive value, the corresponding form
-of tracing is turned on. Here is the set of tracing variables and what happens
-when each of them is positive:
+When all else fails, the predefined macro {\tt
+tracingall}\index{tracingall?\texttt{tracingall}}\label{Dtall} causes
+the interpreter to print a detailed listing of everything it is doing.
+Since the tracing information is often quite voluminous, it may be
+better to use the {\tt
+loggingall}\index{loggingall?\texttt{loggingall}}\label{Dlogall} macro
+that produces the same information but only writes it in the
+transcript\index{files!transcript} file. There is also a {\tt
+tracingnone}\index{tracingnone?\texttt{tracingnone}}\label{Dtnone} macro
+that turns off all the tracing output.
+
+Tracing output is controlled by the set of internal
+variables\index{internal variables}\index{variables!internal} summarized
+below. When any one of these variables is given a positive value, the
+corresponding form of tracing is turned on. Here is the set of tracing
+variables and what happens when each of them is positive:
\begin{description}
\item[{\tt tracingcapsules}]\index{tracingcapsules?\texttt{tracingcapsules}}\label{Dtcapsules}%
shows the values of temporary quantities (capsules) when they become known.
%
\item[{\tt tracingchoices}]\index{tracingchoices?\texttt{tracingchoices}}\label{Dtchoices}%
-shows the B\'ezier control\index{control points} points of each new path when they
-are chosen.
-%
+shows the B\'ezier control\index{control points} points of each new path
+when they are chosen. %
\item[{\tt tracingcommands}]\index{tracingcommands?\texttt{tracingcommands}}\label{Dtcommands}%
shows the commands before they are performed. A setting ${}>1$ also shows
{\tt if}\index{if?\texttt{if}} tests and loops before they are expanded;
@@ -4077,9 +4684,10 @@ MetaPost interpreter's limited resources were used.
\section*{Acknowledgement}
-I would like to thank Don Knuth for making this work possible by developing
-\MF\ and placing it in the public domain. I am also indebted to him for helpful
-suggestions, particularly with regard to the treatment of included \TeX\ material.
+I would like to thank Don Knuth for making this work possible by
+developing \MF\ and placing it in the public domain. I am also indebted
+to him for helpful suggestions, particularly with regard to the
+treatment of included \TeX\ material.
\appendix
@@ -4099,44 +4707,49 @@ suggestions, particularly with regard to the treatment of included \TeX\ materia
\setcounter{totalnumber}{10}
Tables \ref{ivartab}--\ref{pseudotab} summarize the built-in features of
-Plain MetaPost and the features defined in the {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}}
-macro file. As explained in Section~\ref{boxessec}, the {\tt boxes.mp} macro
-file is not automatically preloaded and the macros defined there are not
-accessible until you ask for them via the command\index{input?\texttt{input}}
+Plain MetaPost and the features defined in the {\tt
+boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} macro file. As explained in
+Section~\ref{boxessec}, the {\tt boxes.mp} macro file is not
+automatically preloaded and the macros defined there are not accessible
+until you ask for them via the command\index{input?\texttt{input}}
$$ \hbox{\tt input boxes} $$
Features that depend on {\tt boxes.mp} are marked by \bx\ symbols.
-Features from the Plain\index{Plain macros} macro package are marked are marked
-by \pl\ symbols, and MetaPost primitives are not marked by \bx\ or \pl.
-The distinction between primitives and plain macros can be ignored by the casual
-user, but it is important to remember that features marked by a \bx\ can only
-be used after reading in the {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} macro file.
-
-The tables in this appendix give the name each feature, the page number where
-it is explained, and a short description. A few features are not explained
-elsewhere and have no page number listed. These features exist primarily for
-compatibility with \MF\index{metafont?\MF} and are intended to be self-explanatory.
-Certain other features from \MF\ are omitted entirely because they are of
-limited interest to the MetaPost users and/or would require long explanations.
-All of these are documented in {\it The \MF book} \cite{kn:c} as explained
-in Appendix~\ref{MPvsMF}.
+Features from the Plain\index{Plain macros} macro package are marked by
+\pl\ symbols, and MetaPost primitives are not marked by \bx\ or \pl.
+The distinction between primitives and plain macros can be ignored by
+the casual user, but it is important to remember that features marked by
+a \bx\ can only be used after reading in the {\tt
+boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} macro file.
+
+The tables in this appendix give the name of each feature, the page
+number where it is explained, and a short description. A few features
+are not explained elsewhere and have no page number listed. These
+features exist primarily for compatibility with \MF\index{metafont?\MF}
+and are intended to be self-explanatory. Certain other features from
+\MF\ are omitted entirely because they are of limited interest to the
+MetaPost users and/or would require long explanations. All of these are
+documented in {\sl The \MF book} \cite{kn:c} as explained in
+Appendix~\ref{MPvsMF}.
Table~\ref{ivartab} lists internal variables that take on numeric values.
Table~\ref{pvartab} lists predefined variables of other types.
Table~\ref{consttab} lists predefined constants. Some of these are implemented
as variables whose values are intended to be left unchanged.
-Tables \ref{optabA}--\ref{optabD} summarize MetaPost operators and list the
-possible argument and result types for each one. A ``--'' entry for the left
-argument indicates a unary operator; ``--'' entries for both arguments indicate a
-nullary operator. Operators that take suffix parameters are not listed in
-these tables because they are treated as ``function-like macros''.
+Tables \ref{optabA}--\ref{optabD} summarize MetaPost operators and list
+the possible argument and result types for each one. A ``--'' entry for
+the left argument indicates a unary operator; ``--'' entries for both
+arguments indicate a nullary operator. Operators that take suffix
+parameters are not listed in these tables because they are treated as
+``function-like macros''.
-The last two tables are Table~\ref{cmdtab} for commands and Table~\ref{pseudotab}
-macros that behave like functions or procedures. Such macros take parenthesized
-argument lists and/or suffix parameters, returning either a value whose type is
-listed in the table, or nothing. The latter case is for macros that behave
-like procedures. Their return values are listed as ``--''.
+The last two tables are Table~\ref{cmdtab} for commands and
+Table~\ref{pseudotab} macros that behave like functions or procedures.
+Such macros take parenthesized argument lists and/or suffix parameters,
+returning either a value whose type is listed in the table, or nothing.
+The latter case is for macros that behave like procedures. Their return
+values are listed as ``--''.
The figures in this appendix present the syntax of the MetaPost language
starting with expressions in Figures \ref{syexpr1}--\ref{sypseudo}.
@@ -4151,7 +4764,7 @@ Figures \ref{syprog} and \ref{sycmds} give the syntax for MetaPost programs,
including statements and commands. They do not mention loops\index{loops}
and {\tt if}\index{if?\texttt{if}}
tests because these constructions do not behave like statements. The syntax
-given in Figures \ref{syexpr1}--\ref{pseudotab} applies to the result of
+given in Figures \ref{syexpr1}--\ref{sycondloop} applies to the result of
expanding all conditionals and loops. Conditionals and loops do have a
syntax, but they deal with almost arbitrary sequences of tokens.
Figure~\ref{sycondloop} specifies conditionals in terms of
@@ -4180,6 +4793,8 @@ $$\begin{tabular}{|l|r|l|}
clearance around contents of a circular or oval box\\\hline
\tt day& --&
the current day of the month\\\hline
+\tt defaultcolormodel& --&
+ the initial color model (default: 5, rgb)\\\hline
\bx\tt defaultdx& \pageref{Ddefaultdx}&
usual horizontal space around box contents (default 3{\tt bp})\\\hline
\bx\tt defaultdy& \pageref{Ddefaultdy}&
@@ -4198,10 +4813,15 @@ $$\begin{tabular}{|l|r|l|}
controls miter length as in PostScript\\\hline
\tt month& --&
the current month (e.g, 3 $\equiv$ March)\\\hline
+\tt mpprocset& --&
+ \vtop{\hbox{set this to~1 if you want to include a PostScript
+dictionary}\hbox{of abbreviations in the output}}\\\hline
\tt pausing& --&
${}>0$ to display lines on the terminal before they are read\\\hline
-\tt prologues& \pageref{Dprologs}&
+\tt prologues& \pageref{Dprologues}&
${}>0$ to output conforming PostScript using built-in fonts\\\hline
+\tt restoreclipcolor& --&
+ restore the graphics state after clip operations (default: 1)\\\hline
\tt showstopping& --&
${}>0$ to stop after each {\tt show} command\\\hline
\tt time& --&
@@ -4230,6 +4850,8 @@ $$\begin{tabular}{|l|r|l|}
${}>0$ to show memory usage at end of job\\\hline
\tt tracingtitles& --&
${}>0$ to show titles online when they appear\\\hline
+\tt troffmode& \pageref{Dtroffmode}&
+ set to~1 if a {\tt -troff} or {\tt -T} option was given\\\hline
\tt truecorners& \pageref{Dtruecorn}&
${}>0$ to make {\tt llcorner} etc. ignore {\tt setbounds}\\\hline
\tt warningcheck& \pageref{Dwarncheck}&
@@ -4322,6 +4944,8 @@ $$\begin{tabular}{|l|l|r|l|}
{\tt linejoin} value for mitered joins [0]\\\hline
\pl\tt mm& numeric& \pageref{Dmm}&
One millimeter in {\tt bp} units [2.83464]\\\hline
+\tt mpversion& string& \pageref{Dmpversion}&
+ MetaPost version number\\\hline
\tt nullpicture& picture& \pageref{Dnlpic}&
Empty picture\\\hline
\pl\tt origin& pair& --&
@@ -4378,13 +5002,13 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
Concatenation---works for paths $l\hbox{\tt\&}r$ if\\
& path& path& path& &
$r$ starts exactly where the $l$ ends\\\hline
-\tt \verb|*|& numeric& color& color& \pageref{Dmldiv}&
+\tt \verb|*|& numeric& (cmyk)color& (cmyk)color& \pageref{Dmldiv}&
Multiplication\\
& & numeric& numeric& &
\\
& & pair& pair& &
\\\hline
-\tt \verb|*|& color& numeric& color& \pageref{Dmldiv}&
+\tt \verb|*|& (cmyk)color& numeric& (cmyk)color& \pageref{Dmldiv}&
Multiplication\\
& numeric& & numeric& &
\\
@@ -4392,7 +5016,7 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
\\\hline
\tt \verb|**|& numeric& numeric& numeric& \pageref{Dpow}&
Exponentiation\\\hline
-\tt \verb|+|& color& color& color& \pageref{Dadd}&
+\tt \verb|+|& (cmyk)color& (cmyk)color& (cmyk)color& \pageref{Dadd}&
Addition\\
& numeric& numeric& numeric& &
\\
@@ -4402,19 +5026,19 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
Pythagorean addition $\sqrt{l^2+r^2}$\\\hline
\tt \verb|+-+|& numeric& numeric& numeric& \pageref{Dpysub}&
Pythagorean subtraction $\sqrt{l^2-r^2}$\\\hline
-\tt \verb|-|& color& color& color& \pageref{Dadd}&
+\tt \verb|-|& (cmyk)color& (cmyk)color& (cmyk)color& \pageref{Dadd}&
Subtraction\\
& numeric& numeric& numeric& &
\\
& pair& pair& pair& &
\\\hline
-\tt \verb|-|& --& color& color& \pageref{Dneg}&
+\tt \verb|-|& --& (cmyk)color& (cmyk)color& \pageref{Dneg}&
Negation\\
& & numeric& numeric& &
\\
& & pair& pair& &
\\\hline
-\tt \verb|/|& color& numeric& color& \pageref{Dmldiv}&
+\tt \verb|/|& (cmyk)color& numeric& (cmyk)color& \pageref{Dmldiv}&
Division\\
& numeric& & numeric& &
\\
@@ -4426,7 +5050,7 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
\\
\tt \verb|<>|& pair& pair& & &
\\
-& color& color& & &
+& (cmyk)color& (cmyk)color& & &
\\
& transform& transform& & &
\\\hline
@@ -4452,6 +5076,8 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
box\\
& & pen& & &
\\\hline
+\tt \verb|blackpart|& --& cmykcolor& numeric& \pageref{Dcmykprt}&
+ Extract the fourth component\\\hline
\tt \verb|bluepart|& --& color& numeric& \pageref{Drgbprt}&
Extracts the third component\\\hline
\tt \verb|boolean|& --& any& boolean& \pageref{Dboolop}&
@@ -4486,6 +5112,10 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
\hline
\tt \verb|char|& --& numeric& string& \pageref{Dchar}&
Character with a given ASCII code\\\hline
+\tt \verb|cmykcolor|& --& any& boolean& \pageref{Dccolrop}&
+ Is the expression of type cmykcolor?\\\hline
+\tt \verb|colormodel|& --& image object& numeric& --&
+ What is the color model of the image object?\\\hline
\tt \verb|color|& --& any& boolean& \pageref{Dcolrop}&
Is the expression of type color?\\\hline
\tt \verb|cosd|& --& numeric& numeric& \pageref{Dcosd}&
@@ -4498,6 +5128,8 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
Left argument with part before the\\
& & & & &
intersection dropped\\\hline
+\tt \verb|cyanpart|& --& cmykcolor& numeric& \pageref{Dcmykprt}&
+ Extract the first component\\\hline
\tt \verb|cycle|& --& path& boolean& \pageref{Dcycop}&
Determines whether a path is cyclic\\\hline
\tt \verb|decimal|& --& numeric& string& \pageref{Ddecop}&
@@ -4526,6 +5158,8 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
The point size of a font\\\hline
\tt \verb|greenpart|& --& color& numeric& \pageref{Drgbprt}&
Extract the second component\\\hline
+\tt \verb|greypart|& --& numeric& numeric& --&
+ Extract the first (only) component\\\hline
\tt \verb|hex|& --& string& numeric& --&
Interpret as a hexadecimal number\\\hline
\tt \verb|infont|& string& string& picture& \pageref{Sinfont}&
@@ -4560,6 +5194,8 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
\\
& & pen& & &
\\\hline
+\tt \verb|magentapart|& --& cmykcolor& numeric& \pageref{Dcmykprt}&
+ Extract the second component\\\hline
\tt \verb|makepath|& --& pen& path& \pageref{Dmkpath}&
Cyclic path bounding the pen shape\\\hline
\tt \verb|makepen|& --& path& pen& \pageref{Dmkpen}&
@@ -4598,7 +5234,7 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
\tt \verb|numeric|& --& any& boolean& \pageref{Dnumop}&
Is the expression of type numeric?\\\hline
\tt \verb|oct|& --& string& numeric& --&
- Interpret a string as an octal number\\\hline
+ Interpret string as octal number\\\hline
\tt \verb|odd|& --& numeric& boolean& --&
Is the closest integer odd or even?\\\hline
\tt \verb|or|& boolean& boolean& boolean& \pageref{Dor}&
@@ -4625,12 +5261,14 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
Last B\'ezier control point on path\\
\tt \verb|of|& & & & &
segment ending at the given time\\\hline
-\tt \verb|redpart|& --& color& numeric& \pageref{Drgbprt}&
+\tt \verb|redpart|& --& color& numeric& \pageref{Drgbprt}&
Extract the first component\\\hline
\tt \verb|reverse|& --& path& path& \pageref{Drevrse}&
- `time'-reversed path with beginning\\
+ `time'-reversed path, beginning\\
& & & & &
swapped with ending\\\hline
+\tt \verb|rgbcolor|& --& any& boolean& \pageref{Drcolrop}&
+ Is the expression of type color?\\\hline
\tt \verb|rotated|& picture& numeric& picture& \pageref{Dtranop}&
Rotate counterclockwise a given\\
& path& & path& &
@@ -4642,27 +5280,32 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
& transform& & transform& &
\\\hline
\pl\tt \verb|round|& --& numeric& numeric& \pageref{Dround}&
- round each component to the nearest\\
+ round each component to the\\
& & pair& pair& &
- integer\\\hline
+ nearest integer\\\hline
\pl\tt \verb|rt|& --& numeric& numeric& \pageref{Drt}&
Right side of current pen when\\
& & pair& pair& &
centered at given coordinate(s)\\\hline
\tt \verb|scaled|& picture& numeric& picture& \pageref{Dtranop}&
- Scale all coordinates by the given\\
+ Scale all coordinates by the\\
& path& & path& &
- amount\\
+ given amount\\
& pair& & pair& &
\\
& pen& & pen& &
\\
& transform& & transform& &
\\\hline
+\tt \verb|scantokens|& --& string& token sequence& \pageref{Dscantokens}&
+ Converts a string to a token or \\
+& & & & &token sequence. Provides string\\
+& & & & &to numeric conversion, etc.
+ \\\hline
\tt \verb|shifted|& picture& pair& picture& \pageref{Dtranop}&
- Add the given shift amount to each\\
+ Add the given shift amount to\\
& path& & path& &
- pair of coordinates\\
+ each pair of coordinates\\
& pair& & pair& &
\\
& pen& & pen& &
@@ -4768,6 +5411,8 @@ $$\begin{tabular}{|l|l|l|l|r|l|}
$t_{xx}$ entry in transformation matrix\\\hline
\tt \verb|xypart|& --& transform& number& \pageref{Dtrprt}&
$t_{xy}$ entry in transformation matrix\\\hline
+\tt \verb|yellowpart|& --& cmykcolor& numeric& \pageref{Dcmykprt}&
+ Extract the third component\\\hline
\tt \verb|ypart|& --& pair& number& \pageref{Dyprt}&
$y$ or $t_y$ component\\
& & transform& & &
@@ -4910,6 +5555,8 @@ $$\begin{tabular}{|l|l|l|r|l|}
contents\\\hline
\bx\tt \verb|drawboxes|& list of suffixes& --& \pageref{Ddrbxes}&
Draw the named boxes\\\hline
+\pl\tt \verb|drawdot|& pair& --& \pageref{Ddrawdot}&
+ Draw a dot at the given point\\\hline
\pl\tt \verb|drawoptions|& drawing options& --& \pageref{Ddropts}&
Set options for drawing commands\\\hline
\bx\tt \verb|drawunboxed|& list of suffixes& --& \pageref{Ddrunbx}&
@@ -4920,7 +5567,9 @@ $$\begin{tabular}{|l|l|l|r|l|}
named boxes\\\hline
\bx\tt \verb|fixsize|& list of suffixes& --& \pageref{Dfixsiz}&
Solve for size of named boxes\\\hline
-\pl\tt \verb|incr|& numeric variable& numeric& \pageref{Dincr}&
+\pl\tt \verb|image|& string& picture& \pageref{Dimage}&
+ Return picture from text\\\hline
+\pl\tt \verb|incr|& numeric variable& numeric& \pageref{Dincr}&
Increment and return new value\\\hline
\pl\tt \verb|label|& suffix, picture, pair& --& \pageref{Dlabel}&
Draw picture near given point\\\hline
@@ -5026,14 +5675,14 @@ $\tt $\\
$\tt \descr{nullary op} \rightarrow false \;|\; normaldeviate \;|\; nullpicture \;|\; pencircle$\\
$\tt \qquad \;|\; true \;|\; whatever$\\
$\tt \descr{unary op} \rightarrow \descr{type}$\\
-$\tt \qquad \;|\; abs \;|\; angle \;|\; arclength \;|\; ASCII \;|\; bbox \;|\; bluepart \;|\; bot \;|\; ceiling$\\
-$\tt \qquad \;|\; center \;|\; char \;|\; cosd \;|\; cycle \;|\; decimal \;|\; dir \;|\; floor \;|\; fontsize$\\
-$\tt \qquad \;|\; greenpart \;|\; hex \;|\; inverse \;|\; known \;|\; length \;|\; lft \;|\; llcorner$\\
-$\tt \qquad \;|\; lrcorner\;|\; makepath \;|\; makepen \;|\; mexp \;|\; mlog \;|\; not \;|\; oct \;|\; odd$\\
+$\tt \qquad \;|\; abs \;|\; angle \;|\; arclength \;|\; ASCII \;|\; bbox \;|\; blackpart \;|\; bluepart \;|\; bot \;|\; ceiling$\\
+$\tt \qquad \;|\; center \;|\; char \;|\; cosd \;|\; cyanpart \;|\; cycle \;|\; decimal \;|\; dir \;|\; floor \;|\; fontsize$\\
+$\tt \qquad \;|\; greenpart \;|\; greypart \;|\; hex \;|\; inverse \;|\; known \;|\; length \;|\; lft \;|\; llcorner$\\
+$\tt \qquad \;|\; lrcorner\;|\; magentapart \;|\; makepath \;|\; makepen \;|\; mexp \;|\; mlog \;|\; not \;|\; oct \;|\; odd$\\
$\tt \qquad \;|\; redpart \;|\; reverse \;|\; round \;|\; rt \;|\; sind \;|\; sqrt \;|\; top \;|\; ulcorner$\\
$\tt \qquad \;|\; uniformdeviate \;|\; unitvector \;|\; unknown \;|\; urcorner \;|\; xpart \;|\; xxpart$\\
-$\tt \qquad \;|\; xypart \;|\; ypart \;|\; yxpart \;|\; yypart$\\
-$\tt \descr{type} \rightarrow boolean \;|\; color \;|\; numeric \;|\; pair$\\
+$\tt \qquad \;|\; xypart \;|\; yellowpart \;|\; ypart \;|\; yxpart \;|\; yypart$\\
+$\tt \descr{type} \rightarrow boolean \;|\; cmykcolor \;|\; color \;|\; numeric \;|\; pair$\\
$\tt \qquad \;|\; path \;|\; pen \;|\; picture \;|\; string \;|\; transform$\\
$\tt \descr{primary binop} \rightarrow \hbox{\tt *} \;|\; \hbox{\tt /} \;|\; \hbox{\tt **} \;|\; and$\\
$\tt \qquad \;|\; dotprod \;|\; div \;|\; infont \;|\; mod$\\
@@ -5091,6 +5740,7 @@ $\tt \descr{on\hbox{\tt /}off clause} \rightarrow on \descr{numeric tertiary} \;
\begin{figure}[htp]
\begin{ctabbing}
$\tt \descr{boolean expression} \rightarrow \descr{expression}$\\
+$\tt \descr{cmykcolor expression} \rightarrow \descr{expression}$\\
$\tt \descr{color expression} \rightarrow \descr{expression}$\\
$\tt \descr{numeric atom} \rightarrow \descr{atom}$\\
$\tt \descr{numeric expression} \rightarrow \descr{expression}$\\
@@ -5104,6 +5754,7 @@ $\tt \descr{path subexpression} \rightarrow \descr{subexpression}$\\
$\tt \descr{pen expression} \rightarrow \descr{expression}$\\
$\tt \descr{picture expression} \rightarrow \descr{expression}$\\
$\tt \descr{picture variable} \rightarrow \descr{variable}$\\
+$\tt \descr{rgbcolor expression} \rightarrow \descr{expression}$\\
$\tt \descr{string expression} \rightarrow \descr{expression}$\\
$\tt \descr{suffix parameter} \rightarrow \descr{parameter}$\\
$\tt \descr{transform primary} \rightarrow \descr{primary}$
@@ -5200,6 +5851,9 @@ $\tt \qquad \;|\; addto \descr{picture variable} contour \descr{path expression}
$\tt \qquad \;|\; addto \descr{picture variable} doublepath \descr{path expression} \descr{option list}$\\
$\tt \descr{option list} \rightarrow \descr{empty} \;|\; \descr{drawing option} \descr{option list}$\\
$\tt \descr{drawing option} \rightarrow withcolor \descr{color expression}$\\
+$\tt \qquad \;|\; withrgcolor \descr{rgbcolor expression} \;|\; withcmykcolor \descr{cmykcolor expression}$\\
+$\tt \qquad \;|\; withgreyscale \descr{numeric expression} \;|\; withoutcolor$\\
+$\tt \qquad \;|\; withprescript \descr{string expression} \;|\; withpostscript \descr{string expression}$\\
$\tt \qquad \;|\; withpen \descr{pen expression} \;|\; dashed \descr{picture expression}$\\
$\tt $\\
$\tt \descr{drawing command} \rightarrow draw \descr{picture expression} \descr{option list}$\\
@@ -5212,6 +5866,12 @@ $\tt \descr{tracing command} \rightarrow tracingall \;|\; loggingall \;|\; traci
\caption{The syntax for commands}
\index{option list?\tdescr{option list}}\index{picture variable?\tdescr{picture variable}}%
\label{sycmds}
+
+% is this really true? in practice, in real implementations?
+%\bigskip
+%By the way, the default for \ttindex{randomseed} is, in effect,
+%$\textsl{day} + \textsl{time}*\epsilon$. Unfortunately, \textsl{time}
+%is in minutes.
\end{figure}
\begin{figure}[htp]
@@ -5245,23 +5905,24 @@ $\tt \descr{suffix list} \rightarrow \descr{suffix} \;|\; \descr{suffix list}\hb
\setcounter{totalnumber}{\value{svtotnum}}
-\section{MetaPost Versus METAFONT}
+\section{MetaPost Versus \MF}
\label{MPvsMF}
-Since the \MF\index{metafont?\MF} and MetaPost languages have so much in common, expert
-users of \MF\ will want to skip most of the explanations in this document and
-concentrate on concepts that are unique to MetaPost. The comparisons in this
-appendix are intended to help experts that are familiar with {\it The\ \MF book}
-as well as other users that want to benefit from Knuth's more detailed
-explanations \cite{kn:c}.
-
-Since \MF\ is intended for making \TeX\ fonts, it has a number of primitives for
-generating the {\tt tfm}\index{tfm file?{\tt tfm} file}\index{files!tfm?{\tt tfm}} files that
-\TeX\ needs for character dimensions, spacing information,
-ligatures\index{ligatures} and kerning\index{kerning}. MetaPost can also be
-used for generating fonts, and it also has \MF's primitives for making
-{\tt tfm} files. These are listed in Table~\ref{tfmprim}. Explanations can be
-found in the \MF\ documentation \cite{kn:c,kn:mf3}
+Since the \MF\index{metafont?\MF} and MetaPost languages have so much in
+common, expert users of \MF\ will want to skip most of the explanations
+in this document and concentrate on concepts that are unique to
+MetaPost. The comparisons in this appendix are intended to help experts
+that are familiar with {\sl The\ \MF book} as well as other users that
+want to benefit from Knuth's more detailed explanations \cite{kn:c}.
+
+Since \MF\ is intended for making \TeX\ fonts, it has a number of
+primitives for generating the {\tt tfm}\index{tfm file?{\tt tfm}
+file}\index{files!tfm?{\tt tfm}} files that \TeX\ needs for character
+dimensions, spacing information, ligatures\index{ligatures} and
+kerning\index{kerning}. MetaPost can also be used for generating fonts,
+and it also has \MF's primitives for making {\tt tfm} files. These are
+listed in Table~\ref{tfmprim}. Explanations can be found in the \MF\
+documentation \cite{kn:c,kn:mf3}.
\begin{table}[htp]
$$\begin{tabular}{|l|l|} \hline
@@ -5284,25 +5945,27 @@ $$
\label{tfmprim}
\end{table}
-Even though MetaPost has the primitives for generating fonts, many of the
-font-making primitives and internal variables that are part of Plain
-\MF\index{metafont?\MF} are not defined in Plain MetaPost\index{Plain macros}. Instead,
-there is a separate macro package called {\tt mfplain}\index{mfplain?\texttt{mfplain}} that
-defines the macros required to allow MetaPost to process Knuth's Computer Modern
-fonts as shown in Table~\ref{mfponly} \cite{kn:e}.
-To load these macros, put ``\verb|&mfplain|'' before the name of the
-input file. This can be done at the {\tt **} prompt after invoking the MetaPost
-interpreter with no arguments, or on a command line that looks something like
-this:\footnote{Command line syntax is system dependent. Quotes are needed on
-most Unix\reg systems to protect special characters like {\tt\&}.}
-$$ \hbox{\verb|mp '&mfplain' cmr10|} $$
+Even though MetaPost has the primitives for generating fonts, many of
+the font-making primitives and internal variables that are part of Plain
+\MF\index{metafont?\MF} are not defined in Plain MetaPost\index{Plain
+macros}. Instead, there is a separate macro package called {\tt
+mfplain}\index{mfplain?\texttt{mfplain}} that defines the macros
+required to allow MetaPost to process Knuth's Computer Modern fonts as
+shown in Table~\ref{mfponly} \cite{kn:e}. To load these macros, put
+``\verb|&mfplain|'' before the name of the input file. This can be done
+at the {\tt **} prompt after invoking the MetaPost interpreter with no
+arguments, or on a command line that looks something like
+this:\footnote{Command line syntax is system dependent. Quotes are
+needed on most Unix systems to protect special characters like
+{\tt\&}.}
+$$ \hbox{\verb|mpost '&mfplain' cmr10|} $$
The analog of a \MF\ command line like
$$ \hbox{\verb|mf '\mode=lowres; mag=1.2; input cmr10'|} $$
is
-$$ \hbox{\verb|mp '&mfplain \mode=lowres; mag=1.2; input cmr10'|} $$
-The result is a set of PostScript files, one for each character in the font.
-Some editing would be required in order to merge them into a downloadable Type~3
-PostScript font \cite{ad:red}.
+$$ \hbox{\verb|mpost '&mfplain \mode=lowres; mag=1.2; input cmr10'|} $$
+The result is a set of PostScript files, one for each character in the
+font. Some editing would be required in order to merge them into a
+downloadable Type~3 PostScript font \cite{ad:red}.
\begin{table}[htp]
$$
@@ -5351,25 +6014,27 @@ openit
\end{tabular}
\renewcommand{\FancyVerbFormatLine}[1]{#1}
$$
-\caption{Macros and internal variables defined only in the {\tt mfplain} package.}
+\caption{Macros and internal variables defined only in the {\tt mfplain}
+package.}
\label{mfponly}
\end{table}
Another limitation of the {\tt mfplain} package is that certain internal
-variables from Plain \MF\index{metafont?\MF} cannot be given reasonable MetaPost
-definitions. These include {\tt displaying}, {\tt currentwindow},
-\verb|screen_rows|, and \verb|screen_cols| which depend on \MF's ability to
-display images on the computer screen. In addition, \verb|pixels_per_inch| is
-irrelevant since MetaPost uses fixed units of PostScript points.
-
-The reason why some macros and
-internal variables\index{internal variables}\index{variables!internal}
-are not meaningful in MetaPost
-is that \MF\ primitive commands {\tt cull}, {\tt display}, {\tt openwindow},
-{\tt numspecial} and {\tt totalweight} are not implemented in MetaPost. Also not
-implemented are a number of internal variables as well as the
-\tdescr{drawing option} {\tt withweight}. Here is a complete listing of the
-internal variables whose primitive meanings in \MF\ do not make sense in MetaPost:
+variables from Plain \MF\index{metafont?\MF} cannot be given reasonable
+MetaPost definitions. These include {\tt displaying}, {\tt
+currentwindow}, \verb|screen_rows|, and \verb|screen_cols| which depend
+on \MF's ability to display images on the computer screen. In addition,
+\verb|pixels_per_inch| is irrelevant since MetaPost uses fixed units of
+PostScript points.
+
+The reason why some macros and internal variables\index{internal
+variables}\index{variables!internal} are not meaningful in MetaPost is
+that \MF\ primitive commands {\tt cull}, {\tt display}, {\tt
+openwindow}, {\tt numspecial} and {\tt totalweight} are not implemented
+in MetaPost. Also not implemented are a number of internal variables as
+well as the \tdescr{drawing option} {\tt withweight}. Here is a
+complete listing of the internal variables whose primitive meanings in
+\MF\ do not make sense in MetaPost:
$$\begin{verbatim}
autorounding fillin proofing tracingpens xoffset
chardx granularity smoothing turningcheck yoffset
@@ -5385,22 +6050,26 @@ but \MF\ copies the string into its ``generic font'' output file, while
MetaPost interprets the string as a sequence of PostScript commands that are
to be placed at the beginning of the next output file.
-All the other differences between \MF\ and MetaPost are features found only in
-MetaPost. These are listed in Table~\ref{mponly}. The only commands listed
-in this table that the preceding sections do not discuss are
+All the other differences between \MF\ and MetaPost are features found
+only in MetaPost. These are listed in Table~\ref{mponly}. The only
+commands listed in this table that the preceding sections do not discuss
+are
\verb|extra_beginfig|\index{extra_beginfig?\texttt{extra\_beginfig}}\label{Dxbfig},
-\verb|extra_endfig|\index{extra_endfig?\texttt{extra\_endfig}}\label{Dxefig}, and {\tt mpxbreak}.
-The first two are strings that contain extra commands to be processed
-by {\tt beginfig}\index{beginfig?\texttt{beginfig}} and {\tt endfig}\index{endfig?\texttt{endfig}}
-just as \verb|extra_beginchar| and \verb|extra_endchar| are processed by
-{\tt beginchar} and {\tt endchar}.
-(The file {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} uses these features).
-
-The other new feature listed in Table~\ref{mponly} not listed in the index
-is {\tt mpxbreak}\index{mpxbreak?\texttt{mpxbreak}}. This is used to separate blocks of
-translated \TeX\index{TeX?\TeX} or troff\index{troff} commands in
-{\tt mpx}\index{files!mpx?{\tt mpx}} files. It should be of no concern to
-users since {\tt mpx} files are generated automatically.
+\verb|extra_endfig|\index{extra_endfig?\texttt{extra\_endfig}}\label{Dxefig},
+and {\tt mpxbreak}. The first two are strings that contain extra
+commands to be processed by {\tt
+beginfig}\index{beginfig?\texttt{beginfig}} and {\tt
+endfig}\index{endfig?\texttt{endfig}} just as \verb|extra_beginchar| and
+\verb|extra_endchar| are processed by {\tt beginchar} and {\tt endchar}.
+(The file {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}} uses these
+features).
+
+The other new feature listed in Table~\ref{mponly} not listed in the
+index is {\tt mpxbreak}\index{mpxbreak?\texttt{mpxbreak}}. This is used
+to separate blocks of translated \TeX\index{TeX?\TeX} or
+troff\index{troff} commands in {\tt mpx}\index{files!mpx?{\tt mpx}}
+files. It should be of no concern to users since {\tt mpx} files are
+generated automatically.
\begin{table}[htp]
$$
@@ -5409,14 +6078,21 @@ $$
\multicolumn 1{|c|}
{MetaPost primitives not found in \MF} \\ \hline
$\begin{verbatim}
-bluepart infont redpart
-btex linecap setbounds
-clip linejoin tracinglostchars
-color llcorner truecorners
-dashed lrcorner ulcorner
-etex miterlimit urcorner
-fontsize mpxbreak verbatimtex
-greenpart prologues withcolor
+blackpart greenpart setbounds
+bluepart greypart tracinglostchars
+btex infont troffmode
+clip linecap truecorners
+cmykcolor linejoin ulcorner
+color llcorner urcorner
+colormodel lrcorner verbatimtex
+cyanpart magentapart withcmykcolor
+dashed miterlimit withcolor
+defaultcolormodel mpprocset withgreyscale
+etex mpxbreak withoutcolor
+filenametemplate prologues withpostscript
+fontmapfile redpart withprescript
+fontmapline restoreclipcolor withrgbcolor
+fontsize rgbcolor yellowpart
\end{verbatim}
$ \\ \hline
\multicolumn 1{|c|}
@@ -5425,15 +6101,15 @@ $\begin{verbatim}
ahangle cutbefore extra_beginfig
ahlength cuttings extra_endfig
background dashpattern green
-bbox defaultfont label
-bboxmargin defaultpen labeloffset
-beginfig defaultscale mitered
-beveled dotlabel red
-black dotlabels rounded
-blue drawarrow squared
-buildcycle drawdblarrow thelabel
-butt drawoptions white
-center endfig
+bbox defaultfont image
+bboxmargin defaultpen label
+beginfig defaultscale labeloffset
+beveled dotlabel mitered
+black dotlabels red
+blue drawarrow rounded
+buildcycle drawdblarrow squared
+butt drawoptions thelabel
+center endfig white
cutafter evenly
\end{verbatim}
$ \\ \hline
@@ -5457,6 +6133,7 @@ $$
\end{document}
% Copyright 1990 - 1995 by AT&T Bell Laboratories.
+% Updated 2006 by Taco Hoekwater, Karl Berry, and others.
% Permission to use, copy, modify, and distribute this software
% and its documentation for any purpose and without fee is hereby