diff options
Diffstat (limited to 'Master/texmf-dist')
18 files changed, 939 insertions, 598 deletions
diff --git a/Master/texmf-dist/doc/metapost/base/mpboxes.pdf b/Master/texmf-dist/doc/metapost/base/mpboxes.pdf Binary files differnew file mode 100644 index 00000000000..0cea91c035b --- /dev/null +++ b/Master/texmf-dist/doc/metapost/base/mpboxes.pdf diff --git a/Master/texmf-dist/doc/metapost/base/mpintro.pdf b/Master/texmf-dist/doc/metapost/base/mpintro.pdf Binary files differindex d2620bf687a..52ac497e6d5 100644 --- a/Master/texmf-dist/doc/metapost/base/mpintro.pdf +++ b/Master/texmf-dist/doc/metapost/base/mpintro.pdf diff --git a/Master/texmf-dist/doc/metapost/base/mpman.pdf b/Master/texmf-dist/doc/metapost/base/mpman.pdf Binary files differindex 73a22862ff6..ea2ffee5c76 100644 --- a/Master/texmf-dist/doc/metapost/base/mpman.pdf +++ b/Master/texmf-dist/doc/metapost/base/mpman.pdf diff --git a/Master/texmf-dist/doc/metapost/base/source/Makefile b/Master/texmf-dist/doc/metapost/base/source/Makefile index 6574ec99108..08a51e01c73 100644 --- a/Master/texmf-dist/doc/metapost/base/source/Makefile +++ b/Master/texmf-dist/doc/metapost/base/source/Makefile @@ -8,10 +8,18 @@ dvips = dvips bibtex = bibtex mpost = mpost -tex=tex -pdf: mpman.pdf mpintro.pdf mpgraph.pdf grdemo.pdf -ps: mpman.ps mpintro.ps mpgraph.ps +pdf: mpman.pdf mpintro.pdf mpgraph.pdf mpboxes.pdf grdemo.pdf +ps: mpman.ps mpintro.ps mpgraph.ps mpboxes.ps all: pdf +mpboxes.pdf: mpboxes.tex mpboxes.bib mpboxes.mp + $(mpost) mpboxes + $(pdflatex) mpboxes + $(bibtex) mpboxes + $(pdflatex) mpboxes + makeindex -s mpman.ist mpboxes + $(pdflatex) mpboxes + mpgraph.pdf: mpgraph.tex mpgraph.bib mpgraph.mp $(mpost) mpgraph $(pdflatex) mpgraph @@ -27,7 +35,7 @@ mpintro.pdf: mpintro.tex mpintro.bib examples.mp manfig.mp $(pdflatex) mpintro $(pdflatex) mpintro -mpman.pdf: mpman.tex mpman.bib mpman.ist manfig.mp +mpman.pdf: mpman.tex mpman-optab.tex mpman.bib mpman.ist manfig.mp $(mpost) manfig $(pdflatex) mpman $(bibtex) mpman @@ -53,7 +61,7 @@ mpintro.ps: mpintro.tex mpintro.bib examples.mp manfig.mp $(latex) mpintro $(dvips) mpintro -mpman.ps: mpman.tex mpman.bib mpman.ist manfig.mp +mpman.ps: mpman.tex mpman-optab.tex mpman.bib mpman.ist manfig.mp $(mpost) manfig $(latex) mpman $(bibtex) mpman diff --git a/Master/texmf-dist/doc/metapost/base/source/README b/Master/texmf-dist/doc/metapost/base/source/README index 1587e508a53..757b9b604f1 100644 --- a/Master/texmf-dist/doc/metapost/base/source/README +++ b/Master/texmf-dist/doc/metapost/base/source/README @@ -1,8 +1,9 @@ Public domain. This is the source for the documentation for MetaPost, consisting of -"A User's Manual for MetaPost", "Drawing Graphs with MetaPost" and -the introductory article "The MetaPost System", written by John D. Hobby. +"A User's Manual for MetaPost", "Drawing Boxes with MetaPost", +"Drawing Graphs with MetaPost" and the introductory article "The +MetaPost System", written by John D. Hobby. They were converted to more modern LaTeX by Dylan Thurston and are currently maintained by Troy Henderson and Stephan Hennig. The manual may be freely used and modified, but John Hobby makes these requests: @@ -42,6 +43,9 @@ lead.d manfig.mp matmul.d mp.1 +mpboxes.bib +mpboxes.mp +mpboxes.tex mpgraph.bib mpgraph.mp mpgraph.tex diff --git a/Master/texmf-dist/doc/metapost/base/source/TODO b/Master/texmf-dist/doc/metapost/base/source/TODO index fb904cfd338..c80faee287e 100644 --- a/Master/texmf-dist/doc/metapost/base/source/TODO +++ b/Master/texmf-dist/doc/metapost/base/source/TODO @@ -4,12 +4,12 @@ items. Where to put new items?
-----------------------
-Section 'For Release' contains items that we want to be finished
-before the next release. Even minor issues can and should be
-added here.
+Section 'Wanted For Release' contains items that we want to be
+finished before the next release. Even minor issues can and
+should be added here.
Items in section 'Mid Term Issues' have no dead-line, but should
-be small enough to be relatively quickly done.
+be self-contained enough to be done independent from other stuff.
Items in section 'Long Term Issues' are less actively worked on.
The reason they are less actively worked on is not lack of
@@ -21,16 +21,24 @@ How to pick items? You can indicate interest or active work on an item by putting your
initials in parenthese in front of that item and checking the
modified TODO file into the repository. That way, anybody who is
-subscribed to the metapost-commits list is notified. Additionally,
-it is wise to communicate that you're working on an issue (you
-didn't remember adding yourself) on the mp-implementors list or
-alternatively the metapost list.
+subscribed to the metapost-commits list is notified of your
+interest. Additionally, it is wise to communicate that you're
+working on an issue (you didn't remember adding yourself) on the
+mp-implementors list or alternatively the metapost list.
*****************************
-*** For Release ***
+*** Wanted For Release ***
*****************************
+mpman.tex
+* Revise introduction.
+* (SH) Revise figure fig0 (TeX-MetaPost-workflow).
+* Add a sub-section discussing colours in section 9.
+* (SH) Colour cars and change code example in section 9.9.
+* Discuss difference between "draw <pic> withpen" and
+ "label(<pic>, ...) withpen" (when label bug is fixed).
+* Rename examples.mp -> mpintro.mp and manfig.mp -> mpman.mp.
@@ -39,15 +47,9 @@ alternatively the metapost list. *** Mid Term Issues ***
*****************************
-* Add a sub-section discussing colours in section 9.
-* Add index entries to section piccomp.
-* Revise introduction.
-* Discuss difference between "draw <pic> withpen" and
- "label(<pic>, ...) withpen" (when label bug is fixed).
* Add decent title graphics.
* Review presentation of primitives and plain macros in appendix A.
* Build reference manual automatically from mp.web (as a separate manual?).
-* Separate description of boxes package from mpman.
* Make manual sources compatible with preview mode (Emacs).
* Re-enable (or remove) SVN keyword substitution (for complete repository).
diff --git a/Master/texmf-dist/doc/metapost/base/source/cm2lm.map b/Master/texmf-dist/doc/metapost/base/source/cm2lm.map index cc2ac280ecc..44228da8144 100644 --- a/Master/texmf-dist/doc/metapost/base/source/cm2lm.map +++ b/Master/texmf-dist/doc/metapost/base/source/cm2lm.map @@ -1,3 +1,4 @@ +%%% This map file replaces Computer Modern fonts by Latin Modern.
cmmi7 CMMI7 < lm-mathit.enc < lmmi7.pfb
cmmi10 CMMI10 < lm-mathit.enc < lmmi10.pfb
cmr7 CMR7 < lm-rm.enc < lmr7.pfb
diff --git a/Master/texmf-dist/doc/metapost/base/source/examples.mp b/Master/texmf-dist/doc/metapost/base/source/examples.mp index 12c1fc218ab..2f58ad0f9c4 100644 --- a/Master/texmf-dist/doc/metapost/base/source/examples.mp +++ b/Master/texmf-dist/doc/metapost/base/source/examples.mp @@ -85,7 +85,7 @@ def gray = withcolor .8white enddef; draw z0..z3 gray; linecap:=butt; draw z1..z4 gray; linecap:=squared; draw z2..z5 gray; -labels.top(0,1,2,3,4,5); +dotlabels.top(0,1,2,3,4,5); endfig; linecap:=rounded; @@ -100,7 +100,7 @@ def gray = withcolor .8white enddef; draw z0--z3--z6 gray; linejoin:=mitered; draw z1..z4--z7 gray; linejoin:=beveled; draw z2..z5--z8 gray; -labels.bot(0,1,2,3,4,5,6,7,8); +dotlabels.bot(0,1,2,3,4,5,6,7,8); endfig; linejoin:=rounded; diff --git a/Master/texmf-dist/doc/metapost/base/source/manfig.mp b/Master/texmf-dist/doc/metapost/base/source/manfig.mp index 4616f090621..f9665370b0d 100644 --- a/Master/texmf-dist/doc/metapost/base/source/manfig.mp +++ b/Master/texmf-dist/doc/metapost/base/source/manfig.mp @@ -779,136 +779,6 @@ endfor endfig; -input boxes - - -\beginfig(48); -fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white; -boxit(currentpicture); -dx = dy = .25in; -clearit; drawboxed(); -forsuffixes $=n,c: makelabel.top(str $, $); endfor -makelabel.bot("s",s); -forsuffixes $=ne,e,se: makelabel.rt(str $, $); endfor -forsuffixes $=nw,w,sw: makelabel.lft(str $, $); endfor -pickup pencircle scaled .3bp; -vardef larrow@#(expr a, da, s) = - drawdblarrow a..a+da; label@#(s,a+.5da); enddef; -larrow.rt(n, (0,-dy), "dy"); -larrow.rt(s, (0,dy), "dy"); -larrow.top(e, (-dx,0), "dx"); -larrow.top(w, (dx,0), "dx"); -endfig; - - -beginfig(49); -boxjoin(a.se=b.sw; a.ne=b.nw); -boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex); -boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex); -boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex); -boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex); -drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w); -interim defaultdy:=7bp; -boxjoin(a.sw=b.nw; a.se=b.ne); -boxit.ba(); boxit.bb(); boxit.bc(); -boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf(); -bd.dx=8bp; ba.ne=a.sw-(15bp,10bp); -drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w); -vardef ndblock suffix $ = - boxjoin(a.sw=b.nw; a.se=b.ne); - forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp); - endfor; enddef; -ndblock nda; ndblock ndb; ndblock ndc; -nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0); -xpart ndb3.se = xpart ndc1.ne = xpart di.c; -ndc1.c - be.c = (whatever,0); -drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3); -drawarrow bb.c -- nda1.w; -drawarrow be.c -- ndc1.w; -drawarrow nda3.c -- ndb1.w; -drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni; -drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di; -drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1; -drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1; -drawarrow ndb1.c{right}..nk.c cutafter bpath nk; -drawarrow ndb2.c{right}..dk.c cutafter bpath dk; -x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne; -drawarrow subpath (0,.7) of (z.ptr..{left}ndc3.c) dashed evenly; -label.rt(btex \strut ndblock etex, z.ptr); endfig; - - -\beginfig(50) -interim circmargin := .07in; -fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white; -circleit(currentpicture); -dx = dy; -clearit; drawboxed(); -forsuffixes $=n,c: makelabel.top(str $, $); endfor -makelabel.bot("s",s); -makelabel.rt("e", e); -makelabel.lft("w", w); -pickup pencircle scaled .3bp; -vardef larrow@#(expr a, da, s) = - drawdblarrow a..a+da; label@#(s,a+.5da); enddef; -larrow.rt(n, (0,-dy), "dy"); -larrow.rt(s, (0,dy), "dy"); -larrow.top(e, (-dx,0), "dx"); -larrow.top(w, (dx,0), "dx"); -endfig; - - - -vardef drawshadowed(text t) = - fixsize(t); - forsuffixes s=t: - fill bpath.s shifted (1pt,-1pt); - unfill bpath.s; - drawboxed(s); - endfor -enddef; - -beginfig(51) -circleit.a(btex Box 1 etex); -circleit.b(btex Box 2 etex); -b.n = a.s - (0,20pt); -drawshadowed(a,b); -drawarrow a.s -- b.n; -endfig; - - -vardef cuta(suffix a,b) expr p = - drawarrow p cutbefore bpath.a cutafter bpath.b; - point .5*length p of p -enddef; - -vardef self@# expr p = - cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; - -beginfig(52); -verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex -circleit.aa(btex\strut Start etex); aa.dx=aa.dy; -circleit.bb(btex \stk B{(a|b)^*a} etex); -circleit.cc(btex \stk C{b^*} etex); -circleit.dd(btex \stk D{(a|b)^*ab} etex); -circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; -numeric hsep; -bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); -cc.c-bb.c = (0,.8hsep); -xpart(ee.e - aa.w) = 3.8in; -drawboxed(aa,bb,cc,dd,ee); -label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); -label.top(btex$b$etex, self.cc(0,30pt)); -label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); -label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); -label.llft(btex$a$etex, self.bb(-20pt,-35pt)); -label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); -label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); -label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); -label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); -label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c); -endfig; - - beginfig(55) picture wheel, car; path body; diff --git a/Master/texmf-dist/doc/metapost/base/source/mpboxes.bib b/Master/texmf-dist/doc/metapost/base/source/mpboxes.bib new file mode 100644 index 00000000000..6adf4cd1c7a --- /dev/null +++ b/Master/texmf-dist/doc/metapost/base/source/mpboxes.bib @@ -0,0 +1,20 @@ +% BibTeX entries for MetaPost doc, by John Hobby. Public domain. + +@techreport{CSTR116, + author = "Kernighan, Brian W.", + title = "{PIC}---A Graphics Language for Typesetting", + type = "Computing Science Technical Report", + number = 116, + institution = "AT\&T Bell Laboratories", + address = "Murray Hill, New Jersey", + year = 1984 +} +@incollection{ke:pic, + author = "Kernighan, Brian W.", + title = "Pic---A Graphics Language for Typesetting", + booktitle = "Unix Research System Papers, Tenth Edition", + publisher = "AT\&T Bell Laboratories", + pages = "53--77", + year = 1990 +} +} diff --git a/Master/texmf-dist/doc/metapost/base/source/mpboxes.mp b/Master/texmf-dist/doc/metapost/base/source/mpboxes.mp new file mode 100644 index 00000000000..6e56ce0c211 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/base/source/mpboxes.mp @@ -0,0 +1,141 @@ +% Figures for MetaPost doc, by John Hobby. Public domain. + +input boxes + +filenametemplate "%j-%c.mps"; + +%%% This redefinition of dotlabel draws dots as a closed path +%%% which are rendered more smoothly in Adobe Reader. +vardef dotlabel@#(expr s,z) text t_ = + label@#(s,z) t_; + addto currentpicture + contour (makepath pencircle scaled dotlabeldiam) shifted z t_; +enddef; + + +beginfig(48); +fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white; +boxit(currentpicture); +dx = dy = .25in; +clearit; drawboxed(); +forsuffixes $=n,c: makelabel.top(str $, $); endfor +makelabel.bot("s",s); +forsuffixes $=ne,e,se: makelabel.rt(str $, $); endfor +forsuffixes $=nw,w,sw: makelabel.lft(str $, $); endfor +pickup pencircle scaled .3bp; +vardef larrow@#(expr a, da, s) = + drawdblarrow a..a+da; label@#(s,a+.5da); enddef; +larrow.rt(n, (0,-dy), "dy"); +larrow.rt(s, (0,dy), "dy"); +larrow.top(e, (-dx,0), "dx"); +larrow.top(w, (dx,0), "dx"); +endfig; + + +beginfig(49); +boxjoin(a.se=b.sw; a.ne=b.nw); +boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex); +boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex); +boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex); +boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex); +drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w); +interim defaultdy:=7bp; +boxjoin(a.sw=b.nw; a.se=b.ne); +boxit.ba(); boxit.bb(); boxit.bc(); +boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf(); +bd.dx=8bp; ba.ne=a.sw-(15bp,10bp); +drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w); +vardef ndblock suffix $ = + boxjoin(a.sw=b.nw; a.se=b.ne); + forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp); + endfor; enddef; +ndblock nda; ndblock ndb; ndblock ndc; +nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0); +xpart ndb3.se = xpart ndc1.ne = xpart di.c; +ndc1.c - be.c = (whatever,0); +drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3); +drawarrow bb.c -- nda1.w; +drawarrow be.c -- ndc1.w; +drawarrow nda3.c -- ndb1.w; +drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni; +drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di; +drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1; +drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1; +drawarrow ndb1.c{right}..nk.c cutafter bpath nk; +drawarrow ndb2.c{right}..dk.c cutafter bpath dk; +x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne; +drawarrow subpath (0,.7) of (z.ptr..{left}ndc3.c) dashed evenly; +label.rt(btex \strut ndblock etex, z.ptr); endfig; + + +\beginfig(50) +interim circmargin := .07in; +fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white; +circleit(currentpicture); +dx = dy; +clearit; drawboxed(); +forsuffixes $=n,c: makelabel.top(str $, $); endfor +makelabel.bot("s",s); +makelabel.rt("e", e); +makelabel.lft("w", w); +pickup pencircle scaled .3bp; +vardef larrow@#(expr a, da, s) = + drawdblarrow a..a+da; label@#(s,a+.5da); enddef; +larrow.rt(n, (0,-dy), "dy"); +larrow.rt(s, (0,dy), "dy"); +larrow.top(e, (-dx,0), "dx"); +larrow.top(w, (dx,0), "dx"); +endfig; + + +vardef drawshadowed(text t) = + fixsize(t); + forsuffixes s=t: + fill bpath.s shifted (1pt,-1pt); + unfill bpath.s; + drawboxed(s); + endfor +enddef; + +beginfig(51) +circleit.a(btex Box 1 etex); +circleit.b(btex Box 2 etex); +b.n = a.s - (0,20pt); +drawshadowed(a,b); +drawarrow a.s -- b.n; +endfig; + + +vardef cuta(suffix a,b) expr p = + drawarrow p cutbefore bpath.a cutafter bpath.b; + point .5*length p of p +enddef; + +vardef self@# expr p = + cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; + +beginfig(52); +verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex +circleit.aa(btex\strut Start etex); aa.dx=aa.dy; +circleit.bb(btex \stk B{(a|b)^*a} etex); +circleit.cc(btex \stk C{b^*} etex); +circleit.dd(btex \stk D{(a|b)^*ab} etex); +circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; +numeric hsep; +bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); +cc.c-bb.c = (0,.8hsep); +xpart(ee.e - aa.w) = 3.8in; +drawboxed(aa,bb,cc,dd,ee); +label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); +label.top(btex$b$etex, self.cc(0,30pt)); +label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); +label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); +label.llft(btex$a$etex, self.bb(-20pt,-35pt)); +label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); +label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); +label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); +label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); +label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c); +endfig; + +end diff --git a/Master/texmf-dist/doc/metapost/base/source/mpboxes.tex b/Master/texmf-dist/doc/metapost/base/source/mpboxes.tex new file mode 100644 index 00000000000..f520f74c4e3 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/base/source/mpboxes.tex @@ -0,0 +1,566 @@ +\listfiles +\RequirePackage{ifpdf} +\ifpdf +\ifnum\pdftexversion<140 +\else +\pdfminorversion=5 +\pdfobjcompresslevel=1% Use compressed object streams. +\fi +\RequirePackage{cmap} +\fi +\documentclass{article} % article is NOT the original style +\usepackage[T1]{fontenc} +\usepackage{lmodern} +\usepackage{textcomp} +\usepackage{mflogo} +\usepackage{makeidx} +\usepackage{fancyvrb} +\usepackage{ctabbing} +\RecustomVerbatimEnvironment{verbatim}{BVerbatim}{baseline=c} +\usepackage{graphics} +\usepackage[textwidth=6in,textheight=8.65in]{geometry} +\usepackage{multicol} +\usepackage{ltxtable} + +\newcommand\descr[1]{{\langle\hbox{\rm#1}\rangle}} +\newcommand\invisgap{\nobreak\hskip0pt\relax} +\newcommand\tdescr[1]{$\langle$\invisgap{\rm#1}\invisgap$\rangle$} +\newcommand\Ignore[1]{} % For fooling delatex so spell will work + +\newcommand\mathcenter[1]{\vcenter{\hbox{#1}}} + +\makeindex + +\author{John D. Hobby} +\title{Drawing Boxes with {MetaPost}} +\date{} + +\newcommand\myabstract{% + This paper describes a package for drawing boxes of different shapes. + The \texttt{boxes} package has been implemented as an extension to the + MetaPost graphics language and is a mandatory part of every MetaPost + installation.} + +\newcommand\mykeywords{% + typesetting; graphs; MetaPost} + +\usepackage[rgb,x11names]{xcolor}% Optimize for screen reading. +\usepackage{hyperxmp} +\usepackage{hyperref} +\hypersetup{ + pdftitle={Drawing Boxes with MetaPost}, + pdfauthor={John D. Hobby and the MetaPost development team}, + pdfkeywords={typesetting, boxes, MetaPost, TeX} +} +\hypersetup{ + pdfstartview={XYZ null null null},% Zoom factor is determined by viewer. + colorlinks, + linkcolor=RoyalBlue3, + urlcolor=Chocolate4, + citecolor=SpringGreen3 +} +\usepackage[all]{hypcap} +\ifpdf +\pdfmapfile{=cm2lm.map}% replace CM by LM in figures +\else +\DeclareGraphicsExtensions{.mps} +\DeclareGraphicsRule{mps}{eps}{*}{} +\usepackage{breakurl} +\fi + + +\begin{document} + \maketitle + \begin{abstract} \myabstract \end{abstract} + \ifx\keywords\undefined \else + \begin{keywords} \mykeywords \end{keywords} + \fi + +\setlength{\columnsep}{2.5em} +\begin{multicols}{2} +\tableofcontents +\end{multicols} + + +\section{Introduction} +\label{intro} + +This document 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 \texttt{/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 directory. Users interested in writing macros may want to +look at the {\tt boxes.mp} file in this directory. + +Since the advent of the \texttt{boxes} package several alternative +packages for drawing boxes of all kinds have been developed by the +MetaPost community. The most widely known ones are +\texttt{MetaObj}\index{MetaObj?\texttt{MetaObj}}, +\texttt{MetaUML}\index{MetaUML?\texttt{MetaUML}}, +\texttt{expressg}\index{expressg?\texttt{expressg}}, and +\texttt{blockdraw\_mp}\index{blockdraw\_mp?\texttt{blockdraw\_mp}}. If +you intend to create lots of structural drawings, flow charts, +\emph{etc.}, those packages might be an interesting ressource, too. + + +\section{Rectangular Boxes} +\label{rectbox} + +\mbox{}% Start paragraph. +\index{variables!box|(}% +\index{box variables|see{variables, box}}% +% +The main idea of the box-making macros is that one should +say\index{boxit?\texttt{boxit}}\label{Dboxit} +$$ {\tt boxit.} \descr{suffix} + \hbox{\tt(} \descr{picture expression} \hbox{\tt)} +$$ +where the \tdescr{suffix} does not start with a subscript.\footnote{Some early +versions of the box making macros did not allow any subscripts in the +{\tt boxit} suffix.} +This creates pair variables \tdescr{suffix}{\tt.c}, +\tdescr{suffix}{\tt.n}, \tdescr{suffix}{\tt.e}, \ldots\ that can then be +used for positioning the picture before drawing it with a separate command such +as\index{drawboxed?\texttt{drawboxed}}\label{Ddrbxed} +$$ \hbox{\tt drawboxed(} \descr{suffix list} \hbox{\tt )} $$ +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|see{variables, internal}}\index{variables!internal} {\tt +defaultdx}\index{defaultdx?\texttt{defaultdx}}\label{Ddefaultdx} and +{\tt defaultdy}\index{defaultdy?\texttt{defaultdy}}\label{Ddefaultdy}.% +% +\index{variables!box|)} + +\begin{figure}[htp] +$$ \includegraphics{mpboxes-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} +$$ {\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}} +in order to control paths that enter the box. +For example, if $a$ and $b$ are box names and $p$ is a path from $a${\tt.c} +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} +$$ \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 +consecutive calls to {\tt boxit} and the \tdescr{equation text} gives equations +to control the relative sizes and positions of the boxes. + +\begin{figure}[htp] +$$\hbox{$\begin{verbatim} +input boxes +beginfig(49); +boxjoin(a.se=b.sw; a.ne=b.nw); +boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex); +boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex); +boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex); +boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex); +drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w); +interim defaultdy:=7bp; +boxjoin(a.sw=b.nw; a.se=b.ne); +boxit.ba(); boxit.bb(); boxit.bc(); +boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf(); +bd.dx=8bp; ba.ne=a.sw-(15bp,10bp); +drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w); +vardef ndblock suffix $ = + boxjoin(a.sw=b.nw; a.se=b.ne); + forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp); + endfor; enddef; +ndblock nda; ndblock ndb; ndblock ndc; +nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0); +xpart ndb3.se = xpart ndc1.ne = xpart di.c; +ndc1.c - be.c = (whatever,0); +drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3); +drawarrow bb.c -- nda1.w; +drawarrow be.c -- ndc1.w; +drawarrow nda3.c -- ndb1.w; +drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni; +drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di; +drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1; +drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1; +drawarrow ndb1.c{right}..nk.c cutafter bpath nk; +drawarrow ndb2.c{right}..dk.c cutafter bpath dk; +x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne; +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{\includegraphics{mpboxes-49}}} +$$ +\caption{MetaPost code and the corresponding figure} +\label{fig49} +\end{figure} + +For example, the second line of input for the above figure contains +$$ \hbox{\tt boxjoin(a.se=b.sw; a.ne=b.nw)} $$ +This causes boxes to line up horizontally by giving additional equations that +are invoked each time some box {\tt a} is followed by some other box~{\tt b}. +These equations are first invoked on the next line when box~{\tt a} is followed +by box~{\tt ni}. This yields +$$ \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 +$$ \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 +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} +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. + +Another way to draw empty rectangles is by just saying\label{Deboxit} +$$ {\tt boxit} \descr{box name} \hbox{\tt ()} $$ +with no picture argument as is done several times in Figure~\ref{fig49}. +This is like calling {\tt boxit} with an empty picture. +Alternatively the argument can be a string\label{Dsboxit} expression +instead of a picture +expression in which case the string is typeset in the default font. + + +\section{Circular and Oval Boxes} +\label{circbox} + +Circular and oval boxes are a lot like rectangular boxes except for the shape +of the bounding path. Such boxes are set up by the +{\tt circleit}\index{circleit?\texttt{circleit}}\label{Dcircit} macro: +$$ {\tt circleit} \descr{box name} + \hbox{\tt(} \descr{box contents} \hbox{\tt)} +$$ +where \tdescr{box name} is a suffix and \tdescr{box contents} is either a +picture expression, a string expression, or \tdescr{empty}. + +\mbox{}% Start paragraph. +\index{variables!box|(}% +% +The {\tt circleit} macro defines pair variables 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}.% +% +\index{variables!box|)} + +\begin{figure}[htp] +$$ \includegraphics{mpboxes-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{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} +vardef drawshadowed(text t) = + fixsize(t); + forsuffixes s=t: + fill bpath.s shifted (1pt,-1pt); + unfill bpath.s; + drawboxed(s); + endfor +enddef; + +beginfig(51) +circleit.a(btex Box 1 etex); +circleit.b(btex Box 2 etex); +b.n = a.s - (0,20pt); +drawshadowed(a,b); +drawarrow a.s -- b.n; +endfig; +\end{verbatim} +\qquad \mathcenter{\includegraphics{mpboxes-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} + +\mbox{}% Start paragraph. +\index{variables!box|(}% +% +A full example of {\tt circleit} boxes appears in Figure~\ref{fig52}. +The oval boundary paths around ``Start'' and ``Stop'' are due to the equations +$$ \hbox{\tt aa.dx=aa.dy;} \quad {\rm and}\quad \hbox{\tt ee.dx=ee.dy} $$ +after +$$ \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}}.% +% +\index{variables!box|)} + +\begin{figure}[htp] +$$\hbox{$\begin{verbatim} +vardef cuta(suffix a,b) expr p = + drawarrow p cutbefore bpath.a cutafter bpath.b; + point .5*length p of p +enddef; + +vardef self@# expr p = + cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; + +beginfig(52); +verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex +circleit.aa(btex\strut Start etex); aa.dx=aa.dy; +circleit.bb(btex \stk B{(a|b)^*a} etex); +circleit.cc(btex \stk C{b^*} etex); +circleit.dd(btex \stk D{(a|b)^*ab} etex); +circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; +numeric hsep; +bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); +cc.c-bb.c = (0,.8hsep); +xpart(ee.e - aa.w) = 3.8in; +drawboxed(aa,bb,cc,dd,ee); +label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); +label.top(btex$b$etex, self.cc(0,30pt)); +label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); +label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); +label.llft(btex$a$etex, self.bb(-20pt,-35pt)); +label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); +label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); +label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); +label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); +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{\includegraphics{mpboxes-52}}} +$$ +\caption{MetaPost code and the corresponding figure} +\label{fig52} +\end{figure} + + + +\appendix +\section{Reference manual} +\label{refman} + +Tables~\ref{pseudotab} to~\ref{ivartab} summarize macros, box variables +and internal variables provided by the \texttt{boxes} package. + +\begin{table}[hp] +\centering +\caption{\strut Function-Like Macros} +\label{pseudotab} +\begin{tabular}[t]{|>{\ttfamily}l|l|l|r|>{\arraybackslash}p{2.5in}|} +\hline +\multicolumn1{|c}{Name}& \multicolumn1{|c}{Arguments}& + \multicolumn1{|c}{Result}& \multicolumn1{|c}{Page}& + \multicolumn1{|c|}{Explanation}\\ +\hline +\hline +boxit\index{boxit?\texttt{boxit}}& suffix, picture& --& \pageref{Dboxit}& + Define a box containing the picture\\\hline +boxit\index{boxit?\texttt{boxit}}& suffix, string& --& \pageref{Dsboxit}& + Define a box containing text\\\hline +boxit\index{boxit?\texttt{boxit}}& suffix, \tdescr{empty}& --& \pageref{Deboxit}& + Define an empty box\\\hline +boxjoin\index{boxjoin?\texttt{boxjoin}}& equations& --& \pageref{Dbxjoin}& + Give equations for connecting boxes\\\hline +bpath\index{bpath?\texttt{bpath}}& suffix& path& \pageref{Dbpath}& + A box's bounding circle or rectangle\\\hline +circleit\index{circleit?\texttt{circleit}}& suffix, picture& --& \pageref{Dcircit}& + Put picture in a circular box\\\hline +circleit\index{circleit?\texttt{circleit}}& suffix, picture& --& \pageref{Dcircit}& + Put a string in a circular box\\\hline +circleit\index{circleit?\texttt{circleit}}& suffix, \tdescr{empty}& --& \pageref{Dcircit}& + Define an empty circular box\\\hline +drawboxed\index{drawboxed?\texttt{drawboxed}}& list of suffixes& --& \pageref{Ddrbxed}& + Draw the named boxes and their contents\\\hline +drawboxes\index{drawboxes?\texttt{drawboxes}}& list of suffixes& --& \pageref{Ddrbxes}& + Draw the named boxes\\\hline +drawunboxed\index{drawunboxed?\texttt{drawunboxed}}& list of suffixes& --& \pageref{Ddrunbx}& + Draw contents of named boxes\\\hline +fixpos\index{fixpos?\texttt{fixpos}}& list of suffixes& --& \pageref{Dfixpos}& + Solve for the size and position of the named boxes\\\hline +fixsize\index{fixsize?\texttt{fixsize}}& list of suffixes& --& \pageref{Dfixsiz}& + Solve for size of named boxes\\\hline +pic\index{pic?\texttt{pic}}& suffix& picture& \pageref{Dpic}& + Box contents shifted into position\\\hline +\end{tabular} +\end{table} + +\begin{table}[hp] +\centering +\caption{\strut Box variables} +\label{boxvartab} +\index{variables!box} +\begin{tabular}[t]{|>{\ttfamily $\descr{box name}$.}l|>{\arraybackslash}p{2in}|c|} +\hline +\multicolumn1{|c|}{Variable}& \multicolumn1{c|}{Explanation}& Validity\\ +\hline +\hline +c ¢er point &\\ +n &top center point &\\ +s &bottom center point &\\ +w ¢er left point &\\ +e ¢er right point &\\ +nw &top left corner &\texttt{boxit} only\\ +ne &top right corner &\texttt{boxit} only\\ +sw &bottom left corner &\texttt{boxit} only\\ +se &bottom right corner &\texttt{boxit} only\\ +dx &horizontal clearance &\\ +dy &vertical clearance &\\ +off &actual location of box contents &\\ +\hline +\end{tabular} +\end{table} + +\begin{table}[hp] +\centering +\caption{\strut Internal variables with numeric values} +\label{ivartab} +\index{variables!internal} +\begin{tabular}[t]{|>{\ttfamily}l|r|>{\arraybackslash}p{3.5in}|} +\hline +\multicolumn1{|c}{Name}& \multicolumn1{|c}{Page}& \multicolumn1{|c|}{Explanation}\\ +\hline +\hline +circmargin\index{circmargin?\texttt{circmargin}}& \pageref{Dcmargin}& + clearance around contents of a circular or oval box\\\hline +defaultdx\index{defaultdx?\texttt{defaultdx}}& \pageref{Ddefaultdx}& + usual horizontal space around box contents (default 3{\tt bp})\\\hline +defaultdy\index{defaultdy?\texttt{defaultdy}}& \pageref{Ddefaultdy}& + usual vertical space around box contents (default 3{\tt bp})\\\hline +\end{tabular} +\end{table} + + +\bibliographystyle{plain} +\bibliography{mpboxes} + +\printindex + +\end{document} + + + +% Copyright 1990 - 1995 by AT&T Bell Laboratories. + +% Permission to use, copy, modify, and distribute this software +% and its documentation for any purpose and without fee is hereby +% granted, provided that the above copyright notice appear in all +% copies and that both that the copyright notice and this +% permission notice and warranty disclaimer appear in supporting +% documentation, and that the names of AT&T Bell Laboratories or +% any of its entities not be used in advertising or publicity +% pertaining to distribution of the software without specific, +% written prior permission. + +% AT&T disclaims all warranties with regard to this software, +% including all implied warranties of merchantability and fitness. +% In no event shall AT&T be liable for any special, indirect or +% consequential damages or any damages whatsoever resulting from +% loss of use, data or profits, whether in an action of contract, +% negligence or other tortious action, arising out of or in +% connection with the use or performance of this software. + +% In addition, John Hobby, the original author of MetaPost and this +% manual, makes the following requests: +% - I request that it remain clear that I am the author of +% "A User's Manual for MetaPost" and "Drawing Graphs with MetaPost". +% - I request to be consulted before significant changes are made. diff --git a/Master/texmf-dist/doc/metapost/base/source/mpintro.tex b/Master/texmf-dist/doc/metapost/base/source/mpintro.tex index c7857463588..559456af209 100644 --- a/Master/texmf-dist/doc/metapost/base/source/mpintro.tex +++ b/Master/texmf-dist/doc/metapost/base/source/mpintro.tex @@ -1,4 +1,4 @@ -% $Id: mpintro.tex 340 2008-02-29 15:46:17Z taco $ +% $Id: mpintro.tex 501 2008-04-27 17:38:51Z stephanhennig $ % MetaPost doc, by John Hobby. \documentclass{article} \usepackage{graphicx} @@ -454,7 +454,7 @@ def gray = withcolor .8white enddef; draw z0..z3 gray; linecap:=butt; draw z1..z4 gray; linecap:=squared; draw z2..z5 gray; -labels.top(0,1,2,3,4,5); +dotlabels.top(0,1,2,3,4,5); endfig; linecap:=rounded; %stopverbatim \qquad @@ -475,7 +475,7 @@ def gray = withcolor .8white enddef; draw z0--z3--z6 gray; linejoin:=mitered; draw z1..z4--z7 gray; linejoin:=beveled; draw z2..z5--z8 gray; -labels.bot(0,1,2,3,4,5,6,7,8); +dotlabels.bot(0,1,2,3,4,5,6,7,8); endfig; linejoin:=rounded; %stopverbatim \qquad diff --git a/Master/texmf-dist/doc/metapost/base/source/mpman-optab.tex b/Master/texmf-dist/doc/metapost/base/source/mpman-optab.tex index 2ec0d48e417..9d562798ac5 100644 --- a/Master/texmf-dist/doc/metapost/base/source/mpman-optab.tex +++ b/Master/texmf-dist/doc/metapost/base/source/mpman-optab.tex @@ -48,8 +48,11 @@ bounded\index{bounded?\texttt{bounded}}& --& any& boolean& \pageref{Dbounded char\index{char?\texttt{char}}& --& numeric& string& \pageref{Dchar}& Character with a given ASCII code\\\hline
clipped\index{clipped?\texttt{clipped}}& --& any& boolean& \pageref{Dclipped}& Is argument a clipped picture?\\\hline
cmykcolor\index{cmykcolor?\texttt{cmykcolor}}& --& any& boolean& \pageref{Dccolrop}& Is the expression of type cmykcolor?\\\hline
-colormodel\index{colormodel?\texttt{colormodel}}& --& image object& numeric& \pageref{Dcolormodel}& What is the color model of the image object?\\\hline
color\index{color?\texttt{color}}& --& any& boolean& \pageref{Dcolrop}& Is the expression of type color?\\\hline
+colormodel\index{colormodel?\texttt{colormodel}}& --& image object& numeric& \pageref{Dcolormodel}& What is the color model of the image object?\\\hline
+\pl colorpart\index{colorpart?\texttt{colorpart}}& --& image object&
+(cmyk)color\par numeric\par boolean& \pageref{Dcolorpart}& What is the
+color of the image object?\\\hline
cosd\index{cosd?\texttt{cosd}}& --& numeric& numeric& \pageref{Dcosd}& Cosine of angle in degrees\\\hline
\pl cutafter\index{cutafter?\texttt{cutafter}}& path& path& path& \pageref{Dcuta}& Left argument with part after the intersection dropped\\\hline
\pl cutbefore\index{cutbefore?\texttt{cutbefore}}& path& path& path& \pageref{Dcutb}& Left argument with part before the intersection dropped\\\hline
diff --git a/Master/texmf-dist/doc/metapost/base/source/mpman.bib b/Master/texmf-dist/doc/metapost/base/source/mpman.bib index da97f53f3f0..9ce6574fc9e 100644 --- a/Master/texmf-dist/doc/metapost/base/source/mpman.bib +++ b/Master/texmf-dist/doc/metapost/base/source/mpman.bib @@ -2,23 +2,6 @@ @string{dcg = "Discrete and Computational Geometry"} -@techreport{CSTR116, - author = "Kernighan, Brian W.", - title = "{PIC}---A Graphics Language for Typesetting", - type = "Computing Science Technical Report", - number = 116, - institution = "AT\&T Bell Laboratories", - address = "Murray Hill, New Jersey", - year = 1984 -} -@incollection{ke:pic, - author = "Kernighan, Brian W.", - title = "Pic---A Graphics Language for Typesetting", - booktitle = "Unix Research System Papers, Tenth Edition", - publisher = "AT\&T Bell Laboratories", - pages = "53--77", - year = 1990 -} @book{kn:a, author = "D. E. Knuth", note = "Volume A of {\it Computers and Typesetting}", diff --git a/Master/texmf-dist/doc/metapost/base/source/mpman.tex b/Master/texmf-dist/doc/metapost/base/source/mpman.tex index c62e95f1a05..a7ddc926588 100644 --- a/Master/texmf-dist/doc/metapost/base/source/mpman.tex +++ b/Master/texmf-dist/doc/metapost/base/source/mpman.tex @@ -1,4 +1,4 @@ -% $Id: mpman.tex 458 2008-04-03 21:56:20Z stephanhennig $ +% $Id: mpman.tex 513 2008-04-29 12:03:53Z stephanhennig $ % MetaPost manual, by John Hobby. License at end. \listfiles \RequirePackage{ifpdf} @@ -12,7 +12,8 @@ \fi \documentclass{article} % article is NOT the original style \usepackage[nofancy]{svninfo}% Access VCS information. -\svnInfo $Id: mpman.tex 458 2008-04-03 21:56:20Z stephanhennig $ +\svnInfo $Id: mpman.tex 513 2008-04-29 12:03:53Z stephanhennig $ +\newcommand*{\mpversion}{1.004} \usepackage[T1]{fontenc} \usepackage{lmodern} @@ -41,7 +42,6 @@ \newcommand\tdescr[1]{$\langle$\invisgap#1\invisgap$\rangle$} \newcommand\pl{\dag} -\newcommand\bx{$*$} \newcommand\mathcenter[1]{\vcenter{\hbox{#1}}} @@ -110,7 +110,7 @@ \vskip3bp \centerline{and the MetaPost development team} \vskip20.8bp% actually 31.8bp (-11bp) - \centerline{\large documented version: 1.003} + \centerline{\large documented version: \mpversion} \vskip3bp \centerline{\svnToday} \vfil @@ -184,8 +184,8 @@ fi \end{verbatim} $$ prints -$$\begin{verbatim} -mp = 1.003 +$$\begin{verbatim}[commandchars=\\\{\}] +mp = \mpversion \end{verbatim} $$ The {\tt scantokens} command is described on p.~\pageref{Dscantokens} @@ -208,6 +208,10 @@ 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}. +MetaPost documentation is completed by ``Drawing Boxes with MetaPost'' +and ``Drawing Graphs with MetaPost''---the manuals of the \texttt{boxes} +and \texttt{graph} packages originally developed by John~D. Hobby. + 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 @@ -558,16 +562,20 @@ sequences are possible, see table~\ref{tab:fntmpl} for details. \def\d{$\langle$0-9$\rangle$} \begin{table} -\begin{center}\begin{tabular}{>{\ttfamily}ll} +\centering +\begin{tabular}{|>{\ttfamily}l|l|} +\hline +\multicolumn1{|c|}{Escape sequence} & \multicolumn1{c|}{Meaning}\\\hline \%\% & A percent sign \\ -\%\,j & The current jobname\\ +\%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} +\%\d M & The minute\\ +\hline +\end{tabular} \caption{Allowed escape sequences for \ttt{filenametemplate}} \label{tab:fntmpl} \end{table} @@ -2049,7 +2057,7 @@ 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 +\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 \\ @@ -2210,8 +2218,8 @@ 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\\ +\begin{tabular}{ll} +Actual input & Remapped meaning\\\hline {\tt withcolor} $\descr{rgbcolor} c$ & withrgbcolor\index{withrgbcolor?\texttt{withrgbcolor}}\label{Dwithrgbcolor} $c$\\ {\tt withcolor} $\descr{cmykcolor} c$ & withcmykcolor\index{withcmykcolor?\texttt{withcmykcolor}}\label{Dwithcmykcolor} $c$\\ {\tt withcolor} $\descr{numeric} c$ & withgreyscale\index{withgreyscale?\texttt{withgreyscale}}\label{Dwithgreyscale} $c$\\ @@ -2244,15 +2252,22 @@ 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|} +variable \ttindex{defaultcolormodel}. Table~\ref{dfltcmod} lists the +valid values. +\begin{table} +\centering +\begin{tabular}{|c|l|} +\hline +Value & Color model\\\hline 1 & no model\\ 3 & greyscale\\ 5 & rgb (default)\\ 7 & cmyk\\ +\hline \end{tabular} -$$ +\caption{Supported color models.} +\label{dfltcmod} +\end{table} Figure~\ref{fig21} illustrates several applications of the fill command @@ -3461,6 +3476,10 @@ values. \subsection{Inspecting the Components of a Picture} \label{piccomp} +\mbox{}% Start paragraph here. +\index{setbounds?\texttt{setbounds}|(}% +\index{for within?\texttt{for within}|(}% +% MetaPost pictures are composed of stroked lines, filled outlines, pieces of typeset text, clipping paths\index{clip?\texttt{clip}}, and {\tt setbounds}\index{setbounds?\texttt{setbounds}} paths. (A {\tt setbounds} @@ -3478,8 +3497,19 @@ applies to. Thus if a single clipping or {\tt setbounds} path applies to everything in the \tdescr{picture expression}, the whole picture could be thought of as one big component. In order to make the contents of such a picture accessible, the {\tt for}\ldots{\tt within} iteration ignores the enclosing -clipping or {\tt setbounds} path in this case. - +clipping or {\tt setbounds} path in this case. The number of components +that a {\tt for}\ldots {\tt within} iteration would find is returned by +$$ {\tt length}\ \descr{picture primary}\index{length?\texttt{length}}\label{DlengthPicture}$$ + +\index{for within?\texttt{for within}|)} + +\mbox{}% Start paragraph here. +\index{stroked?\texttt{stroked}|(}% +\index{filled?\texttt{filled}|(}% +\index{textual?\texttt{textual}|(}% +\index{clipped?\texttt{clipped}|(}% +\index{bounded?\texttt{bounded}|(}% +% Once the {\tt for}\ldots{\tt within} iteration has found a picture component, there are numerous operators for identifying it and extracting relevant information. The operator @@ -3495,6 +3525,11 @@ path or a {\tt setbounds} path. This is true if the first component is clipped or bounded or if the entire picture is enclosed in a clipping or {\tt setbounds} path. +\mbox{}% Start paragraph here. +\index{pathpart?\texttt{pathpart}|(}% +\index{penpart?\texttt{penpart}|(}% +\index{dashpart?\texttt{dashpart}|(}% +% There are also numerous part extraction operators that test the first component of a picture. If {\tt p} is a picture and {\tt stroked p} is true, {\tt pathpart p}\index{pathpart?\texttt{pathpart}}\label{Dpathpart} is the @@ -3516,25 +3551,47 @@ gives the font that was used, and {\tt xpart~p}\index{xpart?\texttt{xpart}}\inde {\tt ypart~p}, {\tt xxpart~p}, {\tt xypart~p}, {\tt yxpart~p}, {\tt yypart~p} tell how the text has been shifted, rotated, and scaled. -Additionally, for \ttt{stroked}, \ttt{filled} and \ttt{textual} -components the color can be inspected. The color model of a picture -component can be requested by the +\mbox{}% Start paragraph here. +\index{colorpart?\texttt{colorpart}|(}% +\index{colormodel?\texttt{colormodel}|(}% +\index{redpart?\texttt{redpart}|(}% +\index{greenpart?\texttt{greenpart}|(}% +\index{bluepart?\texttt{bluepart}|(}% +\index{cyanpart?\texttt{cyanpart}|(}% +\index{magentapart?\texttt{magentapart}|(}% +\index{yellowpart?\texttt{yellowpart}|(}% +\index{blackpart?\texttt{blackpart}|(}% +\index{greypart?\texttt{greypart}|(}% +% +Finally, for \ttt{stroked}, \ttt{filled} and \ttt{textual} components +the color can be examined by saying +$$ {\tt colorpart}\ +\descr{item}\index{colorpart?\texttt{colorpart}}\label{Dcolorpart} +$$ +This returns the color of a component in its respective color model. +The color model of a component can be identified by the \ttt{colormodel}\index{colormodel?\texttt{colormodel}}\label{Dcolormodel} -operator (see section~\ref{adv.gr}). Depending on the color model of -a picture component \ttt{p} the color is -$$ \hbox{\tt (redpart p, greenpart p, bluepart p)} $$% -\index{redpart?\texttt{redpart}}\index{greenpart?\texttt{greenpart}}\index{bluepart?\texttt{bluepart}} -for RGB colors or +operator (cf. Table~\ref{dfltcmod} on p.~\pageref{dfltcmod}). + +For more fine grained color operations there are operators to extract +single color components of an item. Depending on the color model the +color of a picture component \ttt{p} is $$ \hbox{\tt (cyanpart p, magentapart p, yellowpart p, blackpart p)} $$% \index{cyanpart?\texttt{cyanpart}}\index{magentapart?\texttt{magentapart}}\index{yellowpart?\texttt{yellowpart}}\index{blackpart?\texttt{blackpart}} -for CMYK colors or -$$ \hbox{\tt (greypart p)} $$% -\index{greypart?\texttt{greypart}} for grey scale colors. - -Applying a non-matching color part -operator to a picture component triggers an error and returns a color -part for the color \ttindex{black} in the requested color model. -That is, for the code +or +$$ \hbox{\tt (redpart p, greenpart p, bluepart p)} $$% +\index{redpart?\texttt{redpart}}\index{greenpart?\texttt{greenpart}}\index{bluepart?\texttt{bluepart}} +or +$$ \hbox{\tt greypart p} $$% +\index{greypart?\texttt{greypart}} +or +$$ \hbox{\tt false}. $$ + +Note, color part operators {\tt redpart}, {\tt cyanpart} etc. have to +match the color model of the picture component in question. Applying a +non-matching color part operator to a picture component triggers an +error and returns a \ttindex{black} color part in the requested color +model. That is, for the code $$\begin{verbatim} picture pic; pic := image(fill unitsquare scaled 1cm withcolor (0.3, 0.6, 0.9);); @@ -3555,23 +3612,54 @@ $$\begin{verbatim} \end{verbatim} $$ since in grey scale color model black is {\tt 0} and in CMYK color model -black is {\tt (0, 0, 0, 1)}. For the matching RGB color model the true +black is {\tt (0,0,0,1)}. For the matching RGB color model the true color component is returned. When {\tt clipped p} or {\tt bounded p} is true, {\tt pathpart p} gives the clipping or {\tt setbounds} path and the other part extraction operators are not meaningful. Such non-meaningful part extractions do not generate -errors---they return null values instead: +errors. Instead, they return null values or black color (components): the trivial path {\tt (0,0)} for {\tt pathpart}, {\tt nullpen}\index{nullpen?\texttt{nullpen}}\label{Dnlpen} for {\tt penpart}, an empty picture for {\tt dashpart}, -zero for {\tt redpart}, {\tt greenpart}, {\tt bluepart}, -and the null string for {\tt textpart} or {\tt fontpart}. - -One final operator for extracting information from a picture is -$$ {\tt length}\ \descr{picture primary} $$\index{length?\texttt{length}}\label{DlengthPicture}% -This returns the number of components that a {\tt for}\ldots {\tt within} -iteration would find. +the null string for {\tt textpart} or {\tt fontpart}, +zero for {\tt colormodel}, +{\tt greypart}, +{\tt redpart}, {\tt greenpart}, {\tt bluepart}, +{\tt cyanpart}, {\tt magentapart}, {\tt yellowpart}, +one for {\tt blackpart}, and +black in the current default color model for {\tt colorpart}. + +To summarize the discussion of mismatching part operators: +\begin{enumerate} +\item Asking for non-meaningful parts of an item---such as the {\tt + redpart} of a clipping path, the {\tt textpart} of a stroked item, + or the {\tt pathpart} of a textual item---is silently accepted and + returns a null value or a black color (component). +\item Applying a color part operator of the wrong color model to a + coloured item returns a black color component. Additionally, this + triggers an error. +\end{enumerate} + +\index{setbounds?\texttt{setbounds}|)} +\index{stroked?\texttt{stroked}|)} +\index{filled?\texttt{filled}|)} +\index{textual?\texttt{textual}|)} +\index{clipped?\texttt{clipped}|)} +\index{bounded?\texttt{bounded}|)} +\index{pathpart?\texttt{pathpart}|)} +\index{penpart?\texttt{penpart}|)} +\index{dashpart?\texttt{dashpart}|)} +\index{colormodel?\texttt{colormodel}|)} +\index{colorpart?\texttt{colorpart}|)} +\index{redpart?\texttt{redpart}|)} +\index{greenpart?\texttt{greenpart}|)} +\index{bluepart?\texttt{bluepart}|)} +\index{cyanpart?\texttt{cyanpart}|)} +\index{magentapart?\texttt{magentapart}|)} +\index{yellowpart?\texttt{yellowpart}|)} +\index{blackpart?\texttt{blackpart}|)} +\index{greypart?\texttt{greypart}|)} \section{Macros} @@ -4473,331 +4561,6 @@ $\tt \descr{suffix list} \rightarrow \descr{suffix} \end{figure} -\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}} -$$ {\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 -directory. Users interested in writing macros may want to look at the -{\tt boxes.mp} file in this directory. - -\subsection{Rectangular Boxes} - -The main idea of the box-making macros is that one should -say\index{boxit?\texttt{boxit}}\label{Dboxit} -$$ {\tt boxit.} \descr{suffix} - \hbox{\tt(} \descr{picture expression} \hbox{\tt)} -$$ -where the \tdescr{suffix} does not start with a subscript.\footnote{Some early -versions of the box making macros did not allow any subscripts in the -{\tt boxit} suffix.} -This creates pair variables \tdescr{suffix}{\tt.c}, -\tdescr{suffix}{\tt.n}, \tdescr{suffix}{\tt.e}, \ldots\ that can then be -used for positioning the picture before drawing it with a separate command such -as\index{drawboxed?\texttt{drawboxed}}\label{Ddrbxed} -$$ \hbox{\tt drawboxed(} \descr{suffix list} \hbox{\tt )} $$ -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 -{\tt defaultdy}\index{defaultdy?\texttt{defaultdy}}\label{Ddefaultdy}. - -\begin{figure}[htp] -$$ \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} -$$ {\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}} -in order to control paths that enter the box. -For example, if $a$ and $b$ are box names and $p$ is a path from $a${\tt.c} -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} -$$ \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 -consecutive calls to {\tt boxit} and the \tdescr{equation text} gives equations -to control the relative sizes and positions of the boxes. - -\begin{figure}[htp] -$$\hbox{$\begin{verbatim} -input boxes -beginfig(49); -boxjoin(a.se=b.sw; a.ne=b.nw); -boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex); -boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex); -boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex); -boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex); -drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w); -interim defaultdy:=7bp; -boxjoin(a.sw=b.nw; a.se=b.ne); -boxit.ba(); boxit.bb(); boxit.bc(); -boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf(); -bd.dx=8bp; ba.ne=a.sw-(15bp,10bp); -drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w); -vardef ndblock suffix $ = - boxjoin(a.sw=b.nw; a.se=b.ne); - forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp); - endfor; enddef; -ndblock nda; ndblock ndb; ndblock ndc; -nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0); -xpart ndb3.se = xpart ndc1.ne = xpart di.c; -ndc1.c - be.c = (whatever,0); -drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3); -drawarrow bb.c -- nda1.w; -drawarrow be.c -- ndc1.w; -drawarrow nda3.c -- ndb1.w; -drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni; -drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di; -drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1; -drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1; -drawarrow ndb1.c{right}..nk.c cutafter bpath nk; -drawarrow ndb2.c{right}..dk.c cutafter bpath dk; -x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne; -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{\includegraphics{manfig-49}}} -$$ -\caption{MetaPost code and the corresponding figure} -\label{fig49} -\end{figure} - -For example, the second line of input for the above figure contains -$$ \hbox{\tt boxjoin(a.se=b.sw; a.ne=b.nw)} $$ -This causes boxes to line up horizontally by giving additional equations that -are invoked each time some box {\tt a} is followed by some other box~{\tt b}. -These equations are first invoked on the next line when box~{\tt a} is followed -by box~{\tt ni}. This yields -$$ \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 -$$ \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 -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} -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. - -Another way to draw empty rectangles is by just saying\label{Deboxit} -$$ {\tt boxit} \descr{box name} \hbox{\tt ()} $$ -with no picture argument as is done several times in Figure~\ref{fig49}. -This is like calling {\tt boxit} with an empty picture. -Alternatively the argument can be a string\label{Dsboxit} expression -instead of a picture -expression in which case the string is typeset in the default font. - - -\subsection{Circular and Oval Boxes} - -Circular and oval boxes are a lot like rectangular boxes except for the shape -of the bounding path. Such boxes are set up by the -{\tt circleit}\index{circleit?\texttt{circleit}}\label{Dcircit} macro: -$$ {\tt circleit} \descr{box name} - \hbox{\tt(} \descr{box contents} \hbox{\tt)} -$$ -where \tdescr{box name} is a suffix and \tdescr{box contents} is either a -picture expression, a string expression, or \tdescr{empty}. - -The {\tt circleit} macro defines pair variables 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}. - -\begin{figure}[htp] -$$ \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. - -\begin{figure}[htbp] -$$\begin{verbatim} -vardef drawshadowed(text t) = - fixsize(t); - forsuffixes s=t: - fill bpath.s shifted (1pt,-1pt); - unfill bpath.s; - drawboxed(s); - endfor -enddef; - -beginfig(51) -circleit.a(btex Box 1 etex); -circleit.b(btex Box 2 etex); -b.n = a.s - (0,20pt); -drawshadowed(a,b); -drawarrow a.s -- b.n; -endfig; -\end{verbatim} -\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} - -A full example of {\tt circleit} boxes appears in Figure~\ref{fig52}. -The oval boundary paths around ``Start'' and ``Stop'' are due to the equations -$$ \hbox{\tt aa.dx=aa.dy;} \quad {\rm and}\quad \hbox{\tt ee.dx=ee.dy} $$ -after -$$ \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}}. - - -\begin{figure}[htp] -$$\hbox{$\begin{verbatim} -vardef cuta(suffix a,b) expr p = - drawarrow p cutbefore bpath.a cutafter bpath.b; - point .5*length p of p -enddef; - -vardef self@# expr p = - cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; - -beginfig(52); -verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex -circleit.aa(btex\strut Start etex); aa.dx=aa.dy; -circleit.bb(btex \stk B{(a|b)^*a} etex); -circleit.cc(btex \stk C{b^*} etex); -circleit.dd(btex \stk D{(a|b)^*ab} etex); -circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; -numeric hsep; -bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); -cc.c-bb.c = (0,.8hsep); -xpart(ee.e - aa.w) = 3.8in; -drawboxed(aa,bb,cc,dd,ee); -label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); -label.top(btex$b$etex, self.cc(0,30pt)); -label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); -label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); -label.llft(btex$a$etex, self.bb(-20pt,-35pt)); -label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); -label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); -label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); -label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); -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{\includegraphics{manfig-52}}} -$$ -\caption{MetaPost code and the corresponding figure} -\label{fig52} -\index{self?\texttt{self}} -\end{figure} - - \section{Reading and Writing Files} File access was one of the new language features introduced in version~0.60 of the MetaPost language. A new operator @@ -5155,20 +4918,9 @@ treatment of included \TeX\ material. \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}} -$$ \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 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. +Plain MetaPost. Features from the Plain\index{Plain macros} macro +package are marked by \pl\ symbols. The distinction between primitives +and plain macros can be ignored by the casual user. 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 @@ -5237,16 +4989,10 @@ $$\begin{tabular}{|l|r|l|} extra space allowed by {\tt bbox} (default 2{\tt bp})\\\hline \tt charcode& \pageref{Dcharcode}& the number of the current figure\\\hline -\bx\tt circmargin& \pageref{Dcmargin}& - 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}& - usual vertical space around box contents (default 3{\tt bp})\\\hline \pl\tt defaultpen& \pageref{Ddefaultpen}& numeric index used by {\tt pickup} to select default pen\\\hline \pl\tt defaultscale& \pageref{Ddfscale}& @@ -5545,24 +5291,8 @@ $$\begin{tabular}{|l|l|l|r|l|} \multicolumn1{|c|}{Explanation}\\ \hline \hline -\bx\tt \verb|boxit|& suffix, picture& --& \pageref{Dboxit}& - Define a box containing the picture\\\hline -\bx\tt \verb|boxit|& suffix, string& --& \pageref{Dsboxit}& - Define a box containing text\\\hline -\bx\tt \verb|boxit|& suffix, \tdescr{empty}& --& \pageref{Deboxit}& - Define an empty box\\\hline -\bx\tt \verb|boxjoin|& equations& --& \pageref{Dbxjoin}& - Give equations for connecting boxes\\\hline -\bx\tt \verb|bpath|& suffix& path& \pageref{Dbpath}& - A box's bounding circle or rectangle\\\hline \pl\tt \verb|buildcycle|& list of paths& path& \pageref{buildcy}& Build a cyclic path\\\hline -\bx\tt \verb|circleit|& suffix, picture& --& \pageref{Dcircit}& - Put picture in a circular box\\\hline -\bx\tt \verb|circleit|& suffix, picture& --& \pageref{Dcircit}& - Put a string in a circular box\\\hline -\bx\tt \verb|circleit|& suffix, \tdescr{empty}& --& \pageref{Dcircit}& - Define an empty circular box\\\hline \pl\tt \verb|dashpattern|& on/off distances& picture& \pageref{Ddshpat}& Create a pattern for dashed lines\\\hline \pl\tt \verb|decr|& numeric variable& numeric& \pageref{Dincr}& @@ -5573,24 +5303,10 @@ $$\begin{tabular}{|l|l|l|r|l|} Mark point and place text nearby\\\hline \pl\tt \verb|dotlabels|& suffix, point numbers& --& \pageref{Ddotlbs}& Mark {\tt z} points with their numbers\\\hline -\bx\tt \verb|drawboxed|& list of suffixes& --& \pageref{Ddrbxed}& - Draw the named boxes and their\\ -& & & & - 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}& - Draw contents of named boxes\\\hline -\bx\tt \verb|fixpos|& list of suffixes& --& \pageref{Dfixpos}& - Solve for the size and position of the\\ -& & & & - named boxes\\\hline -\bx\tt \verb|fixsize|& list of suffixes& --& \pageref{Dfixsiz}& - Solve for size of named boxes\\\hline \pl\tt \verb|image|& string& picture& \pageref{Dimage}& Return picture from text\\\hline \pl\tt \verb|incr|& numeric variable& numeric& \pageref{Dincr}& @@ -5609,8 +5325,6 @@ $$\begin{tabular}{|l|l|l|r|l|} Find the minimum\\\hline \pl\tt \verb|min|& list of strings& string& --& Find the lexicographically first string\\\hline -\bx\tt \verb|pic|& suffix& picture& \pageref{Dpic}& - Box contents shifted into position\\\hline \pl\tt \verb|thelabel|& suffix, picture, pair& picture& \pageref{Dthelab}& Picture shifted as if to label a point\\\hline \pl\tt \verb|thelabel|& suffix, string, pair& picture& \pageref{Dthelab}& @@ -6196,6 +5910,7 @@ blue\\ buildcycle\\ butt\\ center\\ +colorpart\\ cutafter\\ cutbefore\\ cuttings\\ diff --git a/Master/texmf-dist/metapost/base/graph.mp b/Master/texmf-dist/metapost/base/graph.mp index 5f8286e1e86..d7c61ecd961 100644 --- a/Master/texmf-dist/metapost/base/graph.mp +++ b/Master/texmf-dist/metapost/base/graph.mp @@ -146,10 +146,18 @@ pair Gboff_; Gboff_=epsilon*(3,3); % allowance to avoid numerical trouble def Gwithpc_(expr q) = - withpen penpart q withcolor (redpart q, greenpart q, bluepart q) + withpen penpart q withcolor + if colormodel q=1: + false + elseif colormodel q=3: + (greypart q) + elseif colormodel q=5: + (redpart q, greenpart q, bluepart q) + elseif colormodel q=7: + (cyanpart q, magentapart q, yellowpart q, blackpart q) + fi enddef; - % Add picture component q to picture @# and change part p to tp, where p is % something from q that needs coordinate transformation. The type of p is pair % or path. diff --git a/Master/texmf-dist/metapost/base/plain.mp b/Master/texmf-dist/metapost/base/plain.mp index 52774f6fc67..d1a6212f303 100644 --- a/Master/texmf-dist/metapost/base/plain.mp +++ b/Master/texmf-dist/metapost/base/plain.mp @@ -5,7 +5,7 @@ % It contains all the features of plain METAFONT except those specific to % font-making. (See The METAFONTbook by D.E. Knuth). % There are also a number of macros for labeling figures, etc. -string base_name, base_version; base_name="plain"; base_version="0.99"; +string base_name, base_version; base_name="plain"; base_version="1.004"; message "Preloading the plain mem file, version "&base_version; @@ -114,6 +114,26 @@ green = (0,1,0); blue = (0,0,1); background = white; % The user can reset this +% color part selection for within +def colorpart primary t = + if colormodel t=7: + (cyanpart t, magentapart t, yellowpart t, blackpart t) + elseif colormodel t=5: + (redpart t, greenpart t, bluepart t) + elseif colormodel t=3: + (greypart t) + elseif colormodel t=1: + false + else: + %%% For clipping and bounding paths, etc. + if defaultcolormodel=7: (0,0,0,1) + elseif defaultcolormodel=5: black + elseif defaultcolormodel=3: 0 + else: false + fi + fi +enddef; + % picture constants picture blankpicture,evenly,withdots; blankpicture=nullpicture; % `display blankpicture...' |