| 1 |
\listfiles |
| 2 |
\RequirePackage{ifpdf} |
| 3 |
\ifpdf |
| 4 |
\ifnum\pdftexversion<140 |
| 5 |
\else |
| 6 |
\pdfminorversion=5 |
| 7 |
\pdfobjcompresslevel=1% Use compressed object streams. |
| 8 |
\fi |
| 9 |
\RequirePackage{cmap} |
| 10 |
\fi |
| 11 |
\documentclass{article} % article is NOT the original style |
| 12 |
\usepackage[T1]{fontenc} |
| 13 |
\usepackage{lmodern} |
| 14 |
\usepackage{textcomp} |
| 15 |
\usepackage{mflogo} |
| 16 |
\usepackage{makeidx} |
| 17 |
\usepackage{fancyvrb} |
| 18 |
\usepackage{ctabbing} |
| 19 |
\RecustomVerbatimEnvironment{verbatim}{BVerbatim}{baseline=c} |
| 20 |
\usepackage{graphics} |
| 21 |
\usepackage[textwidth=6in,textheight=8.65in]{geometry} |
| 22 |
\usepackage{multicol} |
| 23 |
\usepackage{ltxtable} |
| 24 |
|
| 25 |
\newcommand\descr[1]{{\langle\hbox{\rm#1}\rangle}} |
| 26 |
\newcommand\invisgap{\nobreak\hskip0pt\relax} |
| 27 |
\newcommand\tdescr[1]{$\langle$\invisgap{\rm#1}\invisgap$\rangle$} |
| 28 |
\newcommand\Ignore[1]{} % For fooling delatex so spell will work |
| 29 |
|
| 30 |
\newcommand\mathcenter[1]{\vcenter{\hbox{#1}}} |
| 31 |
|
| 32 |
\makeindex |
| 33 |
|
| 34 |
\author{John D. Hobby} |
| 35 |
\title{Drawing Boxes with {MetaPost}} |
| 36 |
\date{} |
| 37 |
|
| 38 |
\newcommand\myabstract{% |
| 39 |
This paper describes a package for drawing boxes of different shapes. |
| 40 |
The \texttt{boxes} package has been implemented as an extension to the |
| 41 |
MetaPost graphics language and is a mandatory part of every MetaPost |
| 42 |
installation.} |
| 43 |
|
| 44 |
\newcommand\mykeywords{% |
| 45 |
typesetting; graphs; MetaPost} |
| 46 |
|
| 47 |
\usepackage[rgb,x11names]{xcolor}% Optimize for screen reading. |
| 48 |
\usepackage{hyperxmp} |
| 49 |
\usepackage{hyperref} |
| 50 |
\hypersetup{ |
| 51 |
pdftitle={Drawing Boxes with MetaPost}, |
| 52 |
pdfauthor={John D. Hobby and the MetaPost development team}, |
| 53 |
pdfkeywords={typesetting, boxes, MetaPost, TeX} |
| 54 |
} |
| 55 |
\hypersetup{ |
| 56 |
pdfstartview={XYZ null null null},% Zoom factor is determined by viewer. |
| 57 |
colorlinks, |
| 58 |
linkcolor=RoyalBlue3, |
| 59 |
urlcolor=Chocolate4, |
| 60 |
citecolor=SpringGreen3 |
| 61 |
} |
| 62 |
\usepackage[all]{hypcap} |
| 63 |
\ifpdf |
| 64 |
\pdfmapfile{=cm2lm.map}% replace CM by LM in figures |
| 65 |
\else |
| 66 |
\DeclareGraphicsExtensions{.mps} |
| 67 |
\DeclareGraphicsRule{mps}{eps}{*}{} |
| 68 |
\usepackage{breakurl} |
| 69 |
\fi |
| 70 |
|
| 71 |
|
| 72 |
\begin{document} |
| 73 |
\maketitle |
| 74 |
\begin{abstract} \myabstract \end{abstract} |
| 75 |
\ifx\keywords\undefined \else |
| 76 |
\begin{keywords} \mykeywords \end{keywords} |
| 77 |
\fi |
| 78 |
|
| 79 |
\setlength{\columnsep}{2.5em} |
| 80 |
\begin{multicols}{2} |
| 81 |
\tableofcontents |
| 82 |
\end{multicols} |
| 83 |
|
| 84 |
|
| 85 |
\section{Introduction} |
| 86 |
\label{intro} |
| 87 |
|
| 88 |
This document describes auxiliary macros not included in Plain MetaPost |
| 89 |
that make it convenient to do things that {\it pic} is good at |
| 90 |
\cite{ke:pic}. What follows is a description of how to use the macros |
| 91 |
contained in the file {\tt boxes.mp}\index{boxes.mp?\texttt{boxes.mp}}. |
| 92 |
This file is included in a special directory reserved for MetaPost |
| 93 |
macros and support software\footnote{The name of this directory is |
| 94 |
likely to be something like \texttt{/usr/lib/mp/lib}, but this is |
| 95 |
system dependent.} and can be accessed by giving the MetaPost command |
| 96 |
{\tt input boxes} before any figures that use the box making macros. |
| 97 |
The syntax for the {\tt input} command is \index{input?\texttt{input}} |
| 98 |
$$ {\tt input}\, \descr{file name} $$ |
| 99 |
where a final ``{\tt .mp}'' can be omitted from the file name. The {\tt |
| 100 |
input} command looks first in the current directory and then in the |
| 101 |
special macro directory. Users interested in writing macros may want to |
| 102 |
look at the {\tt boxes.mp} file in this directory. |
| 103 |
|
| 104 |
Since the advent of the \texttt{boxes} package several alternative |
| 105 |
packages for drawing boxes of all kinds have been developed by the |
| 106 |
MetaPost community. The most widely known ones are |
| 107 |
\texttt{MetaObj}\index{MetaObj?\texttt{MetaObj}}, |
| 108 |
\texttt{MetaUML}\index{MetaUML?\texttt{MetaUML}}, |
| 109 |
\texttt{expressg}\index{expressg?\texttt{expressg}}, and |
| 110 |
\texttt{blockdraw\_mp}\index{blockdraw\_mp?\texttt{blockdraw\_mp}}. If |
| 111 |
you intend to create lots of structural drawings, flow charts, |
| 112 |
\emph{etc.}, those packages might be an interesting ressource, too. |
| 113 |
|
| 114 |
|
| 115 |
\section{Rectangular Boxes} |
| 116 |
\label{rectbox} |
| 117 |
|
| 118 |
\mbox{}% Start paragraph. |
| 119 |
\index{variables!box|(}% |
| 120 |
\index{box variables|see{variables, box}}% |
| 121 |
% |
| 122 |
The main idea of the box-making macros is that one should |
| 123 |
say\index{boxit?\texttt{boxit}}\label{Dboxit} |
| 124 |
$$ {\tt boxit.} \descr{suffix} |
| 125 |
\hbox{\tt(} \descr{picture expression} \hbox{\tt)} |
| 126 |
$$ |
| 127 |
where the \tdescr{suffix} does not start with a subscript.\footnote{Some early |
| 128 |
versions of the box making macros did not allow any subscripts in the |
| 129 |
{\tt boxit} suffix.} |
| 130 |
This creates pair variables \tdescr{suffix}{\tt.c}, |
| 131 |
\tdescr{suffix}{\tt.n}, \tdescr{suffix}{\tt.e}, \ldots\ that can then be |
| 132 |
used for positioning the picture before drawing it with a separate command such |
| 133 |
as\index{drawboxed?\texttt{drawboxed}}\label{Ddrbxed} |
| 134 |
$$ \hbox{\tt drawboxed(} \descr{suffix list} \hbox{\tt )} $$ |
| 135 |
The argument to {\tt drawboxed} should be a comma-separated list of box names, |
| 136 |
where a box name\index{box name} is a \tdescr{suffix} with which {\tt boxit} |
| 137 |
has been called. |
| 138 |
|
| 139 |
For the command {\tt boxit.bb(pic)}, the box name is {\tt bb} and the |
| 140 |
contents of the box is the picture {\tt pic}. In this case, {\tt bb.c} |
| 141 |
the position where the center of picture {\tt pic} is to be placed, and |
| 142 |
{\tt bb.sw}, {\tt bb.se}, {\tt bb.ne}, and {\tt bb.nw} are the corners |
| 143 |
of a rectangular path that will surround the resulting picture. |
| 144 |
Variables {\tt bb.dx} and {\tt bb.dy} give the spacing between the |
| 145 |
shifted version of {\tt pic} and the surrounding rectangle, and {\tt |
| 146 |
bb.off} is the amount by which {\tt pic} has to be shifted to achieve |
| 147 |
all this. |
| 148 |
|
| 149 |
When the {\tt boxit} macro is called with box name~$b$, it gives linear |
| 150 |
equations that force $b${\tt.sw}, $b${\tt.se}, $b${\tt.ne}, and |
| 151 |
$b${\tt.nw} to be the corners of a rectangle aligned on the $x$ and $y$ |
| 152 |
axes with the box contents centered inside as indicated by the gray |
| 153 |
rectangle in Figure~\ref{fig48}. The values of $b${\tt.dx}, |
| 154 |
$b${\tt.dy}, and $b${\tt.c} are left unspecified so that the user can |
| 155 |
give equations for positioning the boxes. If no such equations are |
| 156 |
given, macros such as {\tt drawboxed} can detect this and give default |
| 157 |
values. The default values for {\tt dx} and {\tt dy} variables are |
| 158 |
controlled by the internal variables\index{internal |
| 159 |
variables|see{variables, internal}}\index{variables!internal} {\tt |
| 160 |
defaultdx}\index{defaultdx?\texttt{defaultdx}}\label{Ddefaultdx} and |
| 161 |
{\tt defaultdy}\index{defaultdy?\texttt{defaultdy}}\label{Ddefaultdy}.% |
| 162 |
% |
| 163 |
\index{variables!box|)} |
| 164 |
|
| 165 |
\begin{figure}[htp] |
| 166 |
$$ \includegraphics{mpboxes-48.mps} $$ |
| 167 |
\caption[How a {\tt boxit} picture relates to the associated variables] |
| 168 |
{The relationship between the picture given to {\tt boxit} and the |
| 169 |
associated variables. The picture is indicated by a gray rectangle.} |
| 170 |
\label{fig48} |
| 171 |
\end{figure} |
| 172 |
|
| 173 |
If $b$ represents a box name, {\tt drawboxed($b$)} draws the rectangular |
| 174 |
boundary of box~$b$ and then the contents of the box. This bounding |
| 175 |
rectangle can be accessed separately as {\tt bpath~$b$}, or in |
| 176 |
general\index{bpath?\texttt{bpath}}\label{Dbpath} |
| 177 |
$$ {\tt bpath}\, \descr{box name} $$ |
| 178 |
It is useful in combination with operators like |
| 179 |
{\tt cutbefore}\index{cutbefore?\texttt{cutbefore}} and {\tt cutafter}\index{cutafter?\texttt{cutafter}} |
| 180 |
in order to control paths that enter the box. |
| 181 |
For example, if $a$ and $b$ are box names and $p$ is a path from $a${\tt.c} |
| 182 |
to $b${\tt.c},\index{drawarrow?\texttt{drawarrow}} |
| 183 |
$$ \hbox{\tt drawarrow $p$ cutbefore bpath $a$ cutafter bpath $b$} $$ |
| 184 |
draws an arrow from the edge of box $a$ to the edge of box $b$. |
| 185 |
|
| 186 |
Figure~\ref{fig49} shows a practical example including some arrows drawn |
| 187 |
with {\tt cutafter bpath} \tdescr{box name}. It is instructive to |
| 188 |
compare Figure~\ref{fig49} to the similar figure in the pic manual |
| 189 |
\cite{ke:pic}. The figure uses a |
| 190 |
macro\index{boxjoin?\texttt{boxjoin}}\label{Dbxjoin} |
| 191 |
$$ \hbox{\tt boxjoin(} \descr{equation text} \hbox{\tt )} $$ |
| 192 |
to control the relationship between consecutive boxes. Within the |
| 193 |
\tdescr{equation text}, {\tt a} and {\tt b} represent the box names given in |
| 194 |
consecutive calls to {\tt boxit} and the \tdescr{equation text} gives equations |
| 195 |
to control the relative sizes and positions of the boxes. |
| 196 |
|
| 197 |
\begin{figure}[htp] |
| 198 |
$$\hbox{$\begin{verbatim} |
| 199 |
input boxes |
| 200 |
beginfig(49); |
| 201 |
boxjoin(a.se=b.sw; a.ne=b.nw); |
| 202 |
boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex); |
| 203 |
boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex); |
| 204 |
boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex); |
| 205 |
boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex); |
| 206 |
drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w); |
| 207 |
interim defaultdy:=7bp; |
| 208 |
boxjoin(a.sw=b.nw; a.se=b.ne); |
| 209 |
boxit.ba(); boxit.bb(); boxit.bc(); |
| 210 |
boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf(); |
| 211 |
bd.dx=8bp; ba.ne=a.sw-(15bp,10bp); |
| 212 |
drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w); |
| 213 |
vardef ndblock suffix $ = |
| 214 |
boxjoin(a.sw=b.nw; a.se=b.ne); |
| 215 |
forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp); |
| 216 |
endfor; enddef; |
| 217 |
ndblock nda; ndblock ndb; ndblock ndc; |
| 218 |
nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0); |
| 219 |
xpart ndb3.se = xpart ndc1.ne = xpart di.c; |
| 220 |
ndc1.c - be.c = (whatever,0); |
| 221 |
drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3); |
| 222 |
drawarrow bb.c -- nda1.w; |
| 223 |
drawarrow be.c -- ndc1.w; |
| 224 |
drawarrow nda3.c -- ndb1.w; |
| 225 |
drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni; |
| 226 |
drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di; |
| 227 |
drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1; |
| 228 |
drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1; |
| 229 |
drawarrow ndb1.c{right}..nk.c cutafter bpath nk; |
| 230 |
drawarrow ndb2.c{right}..dk.c cutafter bpath dk; |
| 231 |
x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne; |
| 232 |
drawarrow subpath (0,.7) of (z.ptr..{left}ndc3.c) dashed evenly; |
| 233 |
label.rt(btex \strut ndblock etex, z.ptr); endfig; |
| 234 |
\end{verbatim} |
| 235 |
$} |
| 236 |
\atop \vcenter{\vskip8pt\hbox{\includegraphics{mpboxes-49.mps}}} |
| 237 |
$$ |
| 238 |
\caption{MetaPost code and the corresponding figure} |
| 239 |
\label{fig49} |
| 240 |
\end{figure} |
| 241 |
|
| 242 |
For example, the second line of input for the above figure contains |
| 243 |
$$ \hbox{\tt boxjoin(a.se=b.sw; a.ne=b.nw)} $$ |
| 244 |
This causes boxes to line up horizontally by giving additional equations that |
| 245 |
are invoked each time some box {\tt a} is followed by some other box~{\tt b}. |
| 246 |
These equations are first invoked on the next line when box~{\tt a} is followed |
| 247 |
by box~{\tt ni}. This yields |
| 248 |
$$ \hbox{\tt a.se=ni.sw; a.ne=ni.nw} $$ |
| 249 |
The next pair of boxes is box~{\tt ni} and box~{\tt di}. This time the |
| 250 |
implicitly generated equations are |
| 251 |
$$ \hbox{\tt ni.se=di.sw; ni.ne=di.nw} $$ |
| 252 |
This process continues until a new {\tt |
| 253 |
boxjoin}\index{boxjoin?\texttt{boxjoin}} is given. In this case the new |
| 254 |
declaration is |
| 255 |
$$ \hbox{\tt boxjoin(a.sw=b.nw; a.se=b.ne)} $$ |
| 256 |
which causes boxes to be stacked below each other. |
| 257 |
|
| 258 |
After calling {\tt boxit} for the first eight boxes {\tt a} through {\tt |
| 259 |
dk}, the box heights are constrained to match but the widths are still |
| 260 |
unknown. Thus the {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}} |
| 261 |
macro needs to assign default values to the \tdescr{box name}{\tt.dx} |
| 262 |
and \tdescr{box name}{\tt.dy} variables. First, {\tt di.dx} and {\tt |
| 263 |
di.dy} get default values so that all the boxes are forced to be large |
| 264 |
enough to contain the contents of box~{\tt di}. |
| 265 |
|
| 266 |
The macro that actually assigns default values to {\tt dx} and {\tt dy} |
| 267 |
variables is called {\tt |
| 268 |
fixsize}\index{fixsize?\texttt{fixsize}}\label{Dfixsiz}. It takes a |
| 269 |
list of box names and considers them one at a time, making sure that |
| 270 |
each box has a fixed size and shape. A macro called {\tt |
| 271 |
fixpos}\index{fixpos?\texttt{fixpos}}\label{Dfixpos} then takes this |
| 272 |
same list of box names and assigns default values to the \tdescr{box |
| 273 |
name}{\tt.off} variables as needed to fix the position of each box. By |
| 274 |
using {\tt fixsize} to fix the dimensions of each box before assigning |
| 275 |
default positions to any of them, the number of needing default |
| 276 |
positions can usually be cut to at most one. |
| 277 |
|
| 278 |
Since the bounding path for a box cannot be computed until the size, |
| 279 |
shape, and position of the box is determined, the {\tt |
| 280 |
bpath}\index{bpath?\texttt{bpath}} macro applies {\tt fixsize} and {\tt |
| 281 |
fixpos} to its argument. Other macros that do this |
| 282 |
include\index{pic?\texttt{pic}}\label{Dpic} |
| 283 |
$$ {\tt pic}\, \descr{box name} $$ |
| 284 |
where the \tdescr{box name} is a suffix, possibly in parentheses. This returns |
| 285 |
the contents of the named box as a picture positioned so that |
| 286 |
$$ {\tt draw\ pic} \descr{box name} $$ |
| 287 |
draws the box contents without the bounding rectangle. This operation |
| 288 |
can also be accomplished by the {\tt |
| 289 |
drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}\label{Ddrunbx} |
| 290 |
macro that takes a comma-separated list of box names. There is also a |
| 291 |
{\tt drawboxes}\index{drawboxes?\texttt{drawboxes}}\label{Ddrbxes} macro |
| 292 |
that draws just the bounding rectangles. |
| 293 |
|
| 294 |
Another way to draw empty rectangles is by just saying\label{Deboxit} |
| 295 |
$$ {\tt boxit} \descr{box name} \hbox{\tt ()} $$ |
| 296 |
with no picture argument as is done several times in Figure~\ref{fig49}. |
| 297 |
This is like calling {\tt boxit} with an empty picture. |
| 298 |
Alternatively the argument can be a string\label{Dsboxit} expression |
| 299 |
instead of a picture |
| 300 |
expression in which case the string is typeset in the default font. |
| 301 |
|
| 302 |
|
| 303 |
\section{Circular and Oval Boxes} |
| 304 |
\label{circbox} |
| 305 |
|
| 306 |
Circular and oval boxes are a lot like rectangular boxes except for the shape |
| 307 |
of the bounding path. Such boxes are set up by the |
| 308 |
{\tt circleit}\index{circleit?\texttt{circleit}}\label{Dcircit} macro: |
| 309 |
$$ {\tt circleit} \descr{box name} |
| 310 |
\hbox{\tt(} \descr{box contents} \hbox{\tt)} |
| 311 |
$$ |
| 312 |
where \tdescr{box name} is a suffix and \tdescr{box contents} is either a |
| 313 |
picture expression, a string expression, or \tdescr{empty}. |
| 314 |
|
| 315 |
\mbox{}% Start paragraph. |
| 316 |
\index{variables!box|(}% |
| 317 |
% |
| 318 |
The {\tt circleit} macro defines pair variables just as {\tt boxit} |
| 319 |
does, except that there are no corner points \tdescr{box name}{\tt.ne}, |
| 320 |
\tdescr{box name}{\tt.sw}, etc. A call to |
| 321 |
$$ \hbox{\tt circleit.a(}\ldots \hbox{\tt )} $$ |
| 322 |
gives relationships among points {\tt a.c}, {\tt a.s}, {\tt a.e}, {\tt |
| 323 |
a.n}, {\tt a.w} and distances {\tt a.dx} and {\tt a.dy}. Together with |
| 324 |
{\tt a.c} and {\tt a.off}, these variables describe how the picture is |
| 325 |
centered in an oval as can be seen from the Figure~\ref{fig50}.% |
| 326 |
% |
| 327 |
\index{variables!box|)} |
| 328 |
|
| 329 |
\begin{figure}[htp] |
| 330 |
$$ \includegraphics{mpboxes-50.mps} $$ |
| 331 |
\caption[How a {\tt circleit} picture relates to the associated variables] |
| 332 |
{The relationship between the picture given to {\tt circleit} and the |
| 333 |
associated variables. The picture is indicated by a gray rectangle.} |
| 334 |
\label{fig50} |
| 335 |
\end{figure} |
| 336 |
|
| 337 |
The {\tt drawboxed}\index{drawboxed?\texttt{drawboxed}}, {\tt |
| 338 |
drawunboxed}\index{drawunboxed?\texttt{drawunboxed}}, {\tt |
| 339 |
drawboxes}\index{drawboxes?\texttt{drawboxes}}, {\tt |
| 340 |
pic}\index{pic?\texttt{pic}}, and {\tt |
| 341 |
bpath}\index{bpath?\texttt{bpath}} macros work for {\tt circleit} boxes |
| 342 |
just as they do for {\tt boxit} boxes. By default, the boundary path |
| 343 |
for a {\tt circleit} box is a circle large enough to surround the box |
| 344 |
contents with a small safety margin controlled by the internal |
| 345 |
variable\index{variables!internal} {\tt |
| 346 |
circmargin}\label{Dcmargin}. Figure~\ref{fig51} gives a basic example |
| 347 |
of the use of {\tt bpath} with {\tt circleit} boxes. |
| 348 |
|
| 349 |
\begin{figure}[htbp] |
| 350 |
$$\begin{verbatim} |
| 351 |
vardef drawshadowed(text t) = |
| 352 |
fixsize(t); |
| 353 |
forsuffixes s=t: |
| 354 |
fill bpath.s shifted (1pt,-1pt); |
| 355 |
unfill bpath.s; |
| 356 |
drawboxed(s); |
| 357 |
endfor |
| 358 |
enddef; |
| 359 |
|
| 360 |
beginfig(51) |
| 361 |
circleit.a(btex Box 1 etex); |
| 362 |
circleit.b(btex Box 2 etex); |
| 363 |
b.n = a.s - (0,20pt); |
| 364 |
drawshadowed(a,b); |
| 365 |
drawarrow a.s -- b.n; |
| 366 |
endfig; |
| 367 |
\end{verbatim} |
| 368 |
\qquad \mathcenter{\includegraphics{mpboxes-51.mps}} $$ |
| 369 |
\caption[MetaPost code and the resulting figure.] {MetaPost code and |
| 370 |
the resulting figure. Note that the {\tt drawshadowed} macro |
| 371 |
used here is not part of the {\tt boxes.mp} macro package.} |
| 372 |
\label{fig51} |
| 373 |
\index{drawshadowed?\texttt{drawshadowed}} |
| 374 |
\end{figure} |
| 375 |
|
| 376 |
\mbox{}% Start paragraph. |
| 377 |
\index{variables!box|(}% |
| 378 |
% |
| 379 |
A full example of {\tt circleit} boxes appears in Figure~\ref{fig52}. |
| 380 |
The oval boundary paths around ``Start'' and ``Stop'' are due to the equations |
| 381 |
$$ \hbox{\tt aa.dx=aa.dy;} \quad {\rm and}\quad \hbox{\tt ee.dx=ee.dy} $$ |
| 382 |
after |
| 383 |
$$ \hbox{\verb|circleit.ee(btex\strut Stop etex)|} |
| 384 |
\quad{\rm and}\quad |
| 385 |
\hbox{\verb|circleit.ee(btex\strut Stop etex)|}. |
| 386 |
$$ |
| 387 |
The general rule is that {\tt bpath.}$c$ comes out circular if |
| 388 |
$c${\tt.dx}, $c${\tt.dy}, and $c\hbox{\tt.dx}-c\hbox{\tt.dy}$ are all |
| 389 |
unknown. Otherwise, the macros select an oval big enough to contain the |
| 390 |
given picture with the safety margin {\tt |
| 391 |
circmargin}\index{circmargin?\texttt{circmargin}}.% |
| 392 |
% |
| 393 |
\index{variables!box|)} |
| 394 |
|
| 395 |
\begin{figure}[htp] |
| 396 |
$$\hbox{$\begin{verbatim} |
| 397 |
vardef cuta(suffix a,b) expr p = |
| 398 |
drawarrow p cutbefore bpath.a cutafter bpath.b; |
| 399 |
point .5*length p of p |
| 400 |
enddef; |
| 401 |
|
| 402 |
vardef self@# expr p = |
| 403 |
cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; |
| 404 |
|
| 405 |
beginfig(52); |
| 406 |
verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex |
| 407 |
circleit.aa(btex\strut Start etex); aa.dx=aa.dy; |
| 408 |
circleit.bb(btex \stk B{(a|b)^*a} etex); |
| 409 |
circleit.cc(btex \stk C{b^*} etex); |
| 410 |
circleit.dd(btex \stk D{(a|b)^*ab} etex); |
| 411 |
circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; |
| 412 |
numeric hsep; |
| 413 |
bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); |
| 414 |
cc.c-bb.c = (0,.8hsep); |
| 415 |
xpart(ee.e - aa.w) = 3.8in; |
| 416 |
drawboxed(aa,bb,cc,dd,ee); |
| 417 |
label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); |
| 418 |
label.top(btex$b$etex, self.cc(0,30pt)); |
| 419 |
label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); |
| 420 |
label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); |
| 421 |
label.llft(btex$a$etex, self.bb(-20pt,-35pt)); |
| 422 |
label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); |
| 423 |
label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); |
| 424 |
label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); |
| 425 |
label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); |
| 426 |
label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c); |
| 427 |
endfig; |
| 428 |
\end{verbatim} |
| 429 |
$} |
| 430 |
\atop \vcenter{\vskip8pt\hbox{\includegraphics{mpboxes-52.mps}}} |
| 431 |
$$ |
| 432 |
\caption{MetaPost code and the corresponding figure} |
| 433 |
\label{fig52} |
| 434 |
\end{figure} |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
\appendix |
| 439 |
\section{Reference manual} |
| 440 |
\label{refman} |
| 441 |
|
| 442 |
Tables~\ref{pseudotab} to~\ref{ivartab} summarize macros, box variables |
| 443 |
and internal variables provided by the \texttt{boxes} package. |
| 444 |
|
| 445 |
\begin{table}[hp] |
| 446 |
\centering |
| 447 |
\caption{\strut Function-Like Macros} |
| 448 |
\label{pseudotab} |
| 449 |
\begin{tabular}[t]{|>{\ttfamily}l|l|l|r|>{\arraybackslash}p{2.5in}|} |
| 450 |
\hline |
| 451 |
\multicolumn1{|c}{Name}& \multicolumn1{|c}{Arguments}& |
| 452 |
\multicolumn1{|c}{Result}& \multicolumn1{|c}{Page}& |
| 453 |
\multicolumn1{|c|}{Explanation}\\ |
| 454 |
\hline |
| 455 |
\hline |
| 456 |
boxit\index{boxit?\texttt{boxit}}& suffix, picture& --& \pageref{Dboxit}& |
| 457 |
Define a box containing the picture\\\hline |
| 458 |
boxit\index{boxit?\texttt{boxit}}& suffix, string& --& \pageref{Dsboxit}& |
| 459 |
Define a box containing text\\\hline |
| 460 |
boxit\index{boxit?\texttt{boxit}}& suffix, \tdescr{empty}& --& \pageref{Deboxit}& |
| 461 |
Define an empty box\\\hline |
| 462 |
boxjoin\index{boxjoin?\texttt{boxjoin}}& equations& --& \pageref{Dbxjoin}& |
| 463 |
Give equations for connecting boxes\\\hline |
| 464 |
bpath\index{bpath?\texttt{bpath}}& suffix& path& \pageref{Dbpath}& |
| 465 |
A box's bounding circle or rectangle\\\hline |
| 466 |
circleit\index{circleit?\texttt{circleit}}& suffix, picture& --& \pageref{Dcircit}& |
| 467 |
Put picture in a circular box\\\hline |
| 468 |
circleit\index{circleit?\texttt{circleit}}& suffix, picture& --& \pageref{Dcircit}& |
| 469 |
Put a string in a circular box\\\hline |
| 470 |
circleit\index{circleit?\texttt{circleit}}& suffix, \tdescr{empty}& --& \pageref{Dcircit}& |
| 471 |
Define an empty circular box\\\hline |
| 472 |
drawboxed\index{drawboxed?\texttt{drawboxed}}& list of suffixes& --& \pageref{Ddrbxed}& |
| 473 |
Draw the named boxes and their contents\\\hline |
| 474 |
drawboxes\index{drawboxes?\texttt{drawboxes}}& list of suffixes& --& \pageref{Ddrbxes}& |
| 475 |
Draw the named boxes\\\hline |
| 476 |
drawunboxed\index{drawunboxed?\texttt{drawunboxed}}& list of suffixes& --& \pageref{Ddrunbx}& |
| 477 |
Draw contents of named boxes\\\hline |
| 478 |
fixpos\index{fixpos?\texttt{fixpos}}& list of suffixes& --& \pageref{Dfixpos}& |
| 479 |
Solve for the size and position of the named boxes\\\hline |
| 480 |
fixsize\index{fixsize?\texttt{fixsize}}& list of suffixes& --& \pageref{Dfixsiz}& |
| 481 |
Solve for size of named boxes\\\hline |
| 482 |
pic\index{pic?\texttt{pic}}& suffix& picture& \pageref{Dpic}& |
| 483 |
Box contents shifted into position\\\hline |
| 484 |
\end{tabular} |
| 485 |
\end{table} |
| 486 |
|
| 487 |
\begin{table}[hp] |
| 488 |
\centering |
| 489 |
\caption{\strut Box variables} |
| 490 |
\label{boxvartab} |
| 491 |
\index{variables!box} |
| 492 |
\begin{tabular}[t]{|>{\ttfamily $\descr{box name}$.}l|>{\arraybackslash}p{2in}|c|} |
| 493 |
\hline |
| 494 |
\multicolumn1{|c|}{Variable}& \multicolumn1{c|}{Explanation}& Validity\\ |
| 495 |
\hline |
| 496 |
\hline |
| 497 |
c ¢er point &\\ |
| 498 |
n &top center point &\\ |
| 499 |
s &bottom center point &\\ |
| 500 |
w ¢er left point &\\ |
| 501 |
e ¢er right point &\\ |
| 502 |
nw &top left corner &\texttt{boxit} only\\ |
| 503 |
ne &top right corner &\texttt{boxit} only\\ |
| 504 |
sw &bottom left corner &\texttt{boxit} only\\ |
| 505 |
se &bottom right corner &\texttt{boxit} only\\ |
| 506 |
dx &horizontal clearance &\\ |
| 507 |
dy &vertical clearance &\\ |
| 508 |
off &actual location of box contents &\\ |
| 509 |
\hline |
| 510 |
\end{tabular} |
| 511 |
\end{table} |
| 512 |
|
| 513 |
\begin{table}[hp] |
| 514 |
\centering |
| 515 |
\caption{\strut Internal variables with numeric values} |
| 516 |
\label{ivartab} |
| 517 |
\index{variables!internal} |
| 518 |
\begin{tabular}[t]{|>{\ttfamily}l|r|>{\arraybackslash}p{3.5in}|} |
| 519 |
\hline |
| 520 |
\multicolumn1{|c}{Name}& \multicolumn1{|c}{Page}& \multicolumn1{|c|}{Explanation}\\ |
| 521 |
\hline |
| 522 |
\hline |
| 523 |
circmargin\index{circmargin?\texttt{circmargin}}& \pageref{Dcmargin}& |
| 524 |
clearance around contents of a circular or oval box\\\hline |
| 525 |
defaultdx\index{defaultdx?\texttt{defaultdx}}& \pageref{Ddefaultdx}& |
| 526 |
usual horizontal space around box contents (default 3{\tt bp})\\\hline |
| 527 |
defaultdy\index{defaultdy?\texttt{defaultdy}}& \pageref{Ddefaultdy}& |
| 528 |
usual vertical space around box contents (default 3{\tt bp})\\\hline |
| 529 |
\end{tabular} |
| 530 |
\end{table} |
| 531 |
|
| 532 |
|
| 533 |
\bibliographystyle{plain} |
| 534 |
\bibliography{mpboxes} |
| 535 |
|
| 536 |
\printindex |
| 537 |
|
| 538 |
\end{document} |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
% Copyright 1990 - 1995 by AT&T Bell Laboratories. |
| 543 |
|
| 544 |
% Permission to use, copy, modify, and distribute this software |
| 545 |
% and its documentation for any purpose and without fee is hereby |
| 546 |
% granted, provided that the above copyright notice appear in all |
| 547 |
% copies and that both that the copyright notice and this |
| 548 |
% permission notice and warranty disclaimer appear in supporting |
| 549 |
% documentation, and that the names of AT&T Bell Laboratories or |
| 550 |
% any of its entities not be used in advertising or publicity |
| 551 |
% pertaining to distribution of the software without specific, |
| 552 |
% written prior permission. |
| 553 |
|
| 554 |
% AT&T disclaims all warranties with regard to this software, |
| 555 |
% including all implied warranties of merchantability and fitness. |
| 556 |
% In no event shall AT&T be liable for any special, indirect or |
| 557 |
% consequential damages or any damages whatsoever resulting from |
| 558 |
% loss of use, data or profits, whether in an action of contract, |
| 559 |
% negligence or other tortious action, arising out of or in |
| 560 |
% connection with the use or performance of this software. |
| 561 |
|
| 562 |
% In addition, John Hobby, the original author of MetaPost and this |
| 563 |
% manual, makes the following requests: |
| 564 |
% - I request that it remain clear that I am the author of |
| 565 |
% "A User's Manual for MetaPost" and "Drawing Graphs with MetaPost". |
| 566 |
% - I request to be consulted before significant changes are made. |
| 567 |
|
| 568 |
%%% Local Variables: |
| 569 |
%%% mode: latex |
| 570 |
%%% TeX-PDF-mode: t |
| 571 |
%%% TeX-master: t |
| 572 |
%%% End: |