| 1 |
\documentclass[a4paper,twocolumn]{article} |
| 2 |
\usepackage{osf-txfonts,ctable,mkpic,moreverb} |
| 3 |
\usepackage[a4paper,margin=25mm]{geometry} |
| 4 |
|
| 5 |
\def\Mfpic{\textsl{mfpic}} |
| 6 |
\def\Mkpic{\textsl{mkpic}} |
| 7 |
\def\Perl{\textsl{Perl}} |
| 8 |
\newcommand{\makefigure}[1]{ |
| 9 |
\vspace{2ex} |
| 10 |
\begin{figure}[htb] |
| 11 |
\begin{center} |
| 12 |
\mbox{\quad\csname Fig#1\endcsname} |
| 13 |
\caption{#1} |
| 14 |
\label{fig:#1} |
| 15 |
\end{center} |
| 16 |
\end{figure} |
| 17 |
} |
| 18 |
\pagestyle{myheadings} |
| 19 |
\markright{Mkpic: how Perl can help \TeX} |
| 20 |
|
| 21 |
\begin{document} |
| 22 |
|
| 23 |
\title{Mkpic: how Perl can help \TeX} |
| 24 |
|
| 25 |
\author{Wybo Dekker\\[email protected]} |
| 26 |
\maketitle |
| 27 |
\begin{abstract} |
| 28 |
Perl may be an easy interface to \TeX{} when it comes to repetitive |
| 29 |
tasks, like writing letters, creating reports from databases, and |
| 30 |
many more. This article shows how Perl can be used to generate many |
| 31 |
similar pictures \emph{via} the \Mfpic\ style |
| 32 |
\\[2ex] |
| 33 |
\noindent Keywords: \textit{perl, mfpic, mkpic} |
| 34 |
\end{abstract} |
| 35 |
|
| 36 |
\section{Introduction} |
| 37 |
I recently had to produce about 40 pictures for insertion into |
| 38 |
a book on elementary mathematics. I decided that the \Mfpic\ would |
| 39 |
suite most of my needs. But writing \Mfpic\ commands is not easy. |
| 40 |
Figure~\ref{fig:parabola}, for example, can be constructed using the |
| 41 |
following \Mfpic\ commands: |
| 42 |
|
| 43 |
\footnotesize |
| 44 |
\begin{verbatim} |
| 45 |
1 \mftitle{parabola} |
| 46 |
\setlength{\mfpicunit}{1mm} |
| 47 |
\begin{mfpic}[16][5.45]{0}{4}{-6}{5} |
| 48 |
\axes |
| 49 |
5 \hatchwd{2} |
| 50 |
\tlabel[bc](0,5.54){$y$} |
| 51 |
\tlabel[cl](4.21,0){$x$} |
| 52 |
\tlabel[tc](2,-0.18){\strut 2} |
| 53 |
\tlabel[bc](3,0.18){\strut 3} |
| 54 |
10 \tlabel[cr](-0.07,-5){\strut -5} |
| 55 |
\tlabel[cr](-0.07,0){\strut 0} |
| 56 |
\tlabel[cr](-0.07,4){\strut 4} |
| 57 |
\rhatch\lclosed\connect |
| 58 |
\lines{(0,0),(0,4)} |
| 59 |
15 \function{0,3,.05}{4-x*x} |
| 60 |
\lines{(3,-5),(3,0)} |
| 61 |
\endconnect |
| 62 |
\function{0,3.2,.05}{4-x*x} |
| 63 |
\dotted\arrow\lines{(3,-5),(0,-5)} |
| 64 |
20 \dotted\arrow\lines{(3,-5),(3,0)} |
| 65 |
\tlabel[bc](3,4){\parbox[b]{60mm}{% |
| 66 |
\center $f(x)=4-x^2$}} |
| 67 |
\arrow\lines{(3,3.46),(1.7,1.1)} |
| 68 |
\tlabel[bc](2,5){\parbox[b]{60mm}{% |
| 69 |
25 \center Area $O_1$}} |
| 70 |
\arrow\lines{(2,4.46),(1,2)} |
| 71 |
\tlabel[bc](4,2){\parbox[b]{60mm}{% |
| 72 |
\center Area $O_2$}} |
| 73 |
\arrow\lines{(4,1.46),(2.8,-2)} |
| 74 |
30 \end{mfpic} |
| 75 |
\end{verbatim} |
| 76 |
\normalsize |
| 77 |
|
| 78 |
\makefigure{parabola} |
| 79 |
%\ctable[figure,label=fig:parabola,caption=parabola]{@{}c@{}}{}{\Figparabola} |
| 80 |
|
| 81 |
As you can see, this implies a lot of typing and one has to type many |
| 82 |
nested [], \{\}, and () pairs. Also, several floating point numbers, |
| 83 |
such as those in lines 6--12, depend on the scaling factors defined in |
| 84 |
line 3. They have to be calculated manually, and changing the scale will |
| 85 |
imply recalculation of those values. The scale itself is set in line 3: |
| 86 |
I wanted the picture to be 64 mm wide, so I had to calculate |
| 87 |
$64/(4-0)=16$ for the scaling factor in the x-direction. It would be |
| 88 |
much easier if one could type something like: |
| 89 |
|
| 90 |
\footnotesize |
| 91 |
\begin{verbatim} |
| 92 |
1 begin parabola 64 64 0 -6 4 5 $x$ $y$ |
| 93 |
xmark 2 |
| 94 |
Xmark 3 |
| 95 |
ymark -5 0 4 |
| 96 |
5 bhat |
| 97 |
lines 0 0 0 4 |
| 98 |
func 0 3 .05 4-x*x |
| 99 |
lines 3 -5 3 0 |
| 100 |
ehat |
| 101 |
10 func 0 3.2 .05 4-x*x |
| 102 |
xydrop 3 -5 |
| 103 |
arrow 3 4 1.7 1.1 $f(x)=4-x^2$ |
| 104 |
arrow 2 5 1 2 Area $O_1$ |
| 105 |
arrow 4 2 2.8 -2 Area $O_2$ |
| 106 |
15 end |
| 107 |
\end{verbatim} |
| 108 |
\normalsize |
| 109 |
|
| 110 |
Here we see no brackets, braces or parentheses anymore, width and |
| 111 |
height are set straightforwardly to 64 mm and the labels along the |
| 112 |
axes are redefined as xmarks and ymarks, for which nothing has to be |
| 113 |
given but the x- and y-values, respectively. The corresponding y- and |
| 114 |
x-values are supposed to be calculated automatically. |
| 115 |
|
| 116 |
Another construction that frequently occurs in my pictures is a label |
| 117 |
with an arrow starting from the center of its baseline, such as the |
| 118 |
one in lines 21--23 in the long listing. This is replaced in the short |
| 119 |
listing with line 12, where the starting position of the arrow is |
| 120 |
supposed to be calculated automatically. As a result, if I want to |
| 121 |
move the label, the arrow is moved with it automatically. |
| 122 |
|
| 123 |
All this is possible by using a \Perl\ interface that converts the |
| 124 |
short command file into an \Mfpic\ source file. |
| 125 |
|
| 126 |
\section{The Perl interface} |
| 127 |
|
| 128 |
In the \Perl{} script \Mkpic{}, the available commands are all defined |
| 129 |
in the subroutine \verb|parse_input|. My initial version defined only a |
| 130 |
few commands, and while using the script, new commands were inserted |
| 131 |
when they were needed. It's easy to insert your own new commands here, |
| 132 |
just look at what's already there and create new commands by analogy. |
| 133 |
The \verb|__DATA__| section of the script contains the picture needed |
| 134 |
for this documentation (and some more). |
| 135 |
|
| 136 |
The first was the \textsl{begin} command, of course, which has also the |
| 137 |
most complex definition, as it defines many scale-dependent variables |
| 138 |
and \TeX{} commands that might be useful for any command defined later. |
| 139 |
|
| 140 |
\subsection{How to use mkpic} |
| 141 |
First of all, read the manpage of the \Perl-script, generated from the |
| 142 |
script using pod2latex, which is shown in section~\ref{manpage}. |
| 143 |
|
| 144 |
The easiest way to use the script is to append your own commands to |
| 145 |
the \verb|__DATA__| section of the script, maybe after removing what's |
| 146 |
already there, and run it. This will produce a file mkpic.sty, which |
| 147 |
provides \LaTeX-commands named \verb|\Fig<name>|, where \verb|<name>| |
| 148 |
stands for every name you use in the \textsl{begin} command. Finally, |
| 149 |
you can use those \verb|\Fig<name>| commands in a \LaTeX{} document. |
| 150 |
|
| 151 |
\section{Some more examples} |
| 152 |
Here are a few more examples illustrating some features of the \Mkpic{} |
| 153 |
script: |
| 154 |
|
| 155 |
The following commands will produce figure~\ref{fig:droparrows}: |
| 156 |
|
| 157 |
\footnotesize |
| 158 |
\begin{verbatim} |
| 159 |
1 begin droparrows 64 64 0 3 12 8 $x$ $y$ |
| 160 |
xmark $a$ 2 $x_1$ 4 $x_2$ 8 $b$ 10 |
| 161 |
ydrop 2 4.414 |
| 162 |
ydrop 4 5 |
| 163 |
5 ydrop 8 5.828 |
| 164 |
ydrop 10 6.162 |
| 165 |
label cc 4 4 $f(x_1)$ |
| 166 |
label cc 8 4 $f(x_2)$ |
| 167 |
label cc 7 8 $f(x)$ increases on $[a,b]$ |
| 168 |
10 label cc 7 7.5 $x_1<x_2\Rightarrow f(x_1)<F(x_2)$ |
| 169 |
func 1 11 .1 x**(.5)+3 |
| 170 |
end |
| 171 |
\end{verbatim} |
| 172 |
\normalsize |
| 173 |
|
| 174 |
\makefigure{droparrows} |
| 175 |
|
| 176 |
These commands illustrate how valid \Mfpic{} commands can be |
| 177 |
interspersed between \Mkpic{} commands (see figure~\ref{fig:asymptotes}: |
| 178 |
|
| 179 |
\footnotesize |
| 180 |
\begin{verbatim} |
| 181 |
1 begin asymptotes 64 64 0 0 10 10 $x$ $y$ |
| 182 |
curve 1 1 2 3 4 5.7 7 8.1 9 9 |
| 183 |
\shift{(-.05,.05)} |
| 184 |
point 2 3 4 5.7 7 8.1 |
| 185 |
5 \shift{(-.05,.05)} |
| 186 |
func 1.4 2.6 .1 1.65*x-.3 |
| 187 |
func 3.2 4.8 .1 1.025*x+1.6 |
| 188 |
func 6.1 7.9 .1 .62*x+3.76 |
| 189 |
label cl 9.5 9 $f(x)$ |
| 190 |
10 label tl 5 5 $f^\prime(x)>0$ |
| 191 |
label tl 5 4 $f^\prime(x)$ decreasing |
| 192 |
end |
| 193 |
\end{verbatim} |
| 194 |
\normalsize |
| 195 |
|
| 196 |
\makefigure{asymptotes} |
| 197 |
|
| 198 |
Figure~\ref{fig:inflections} is produced by: |
| 199 |
|
| 200 |
\footnotesize |
| 201 |
\begin{verbatim} |
| 202 |
1 begin inflections 64 64 -.85 -1.5 1.5 5 $x$ $y$ |
| 203 |
func -.6 1.5 .05 6*(x**4)-8*(x**3)+1 |
| 204 |
lines -.2 1 .2 1 |
| 205 |
label cr -.25 1 horizontal |
| 206 |
5 arrow .5 2 0 1 inflection point |
| 207 |
arrow .8 1 .65 0 inflection point |
| 208 |
arrow 1 5 1.5 4.375 $f(x)=6x^4-8x^3+1$ |
| 209 |
Xmark 1 |
| 210 |
ymark \raisebox{-3.5mm}{0} 0 -1 |
| 211 |
10 xydrop 1 -1 |
| 212 |
end |
| 213 |
\end{verbatim} |
| 214 |
\normalsize |
| 215 |
|
| 216 |
\makefigure{inflections} |
| 217 |
|
| 218 |
And here is an elaborate quasi 3D picture. |
| 219 |
It shows how comments can be inserted. |
| 220 |
Standard axes are suppressed because they need special treatment (see figure~\ref{fig:paraboloid}): |
| 221 |
|
| 222 |
\footnotesize |
| 223 |
\begin{verbatim} |
| 224 |
1 begin paraboloid 64 64 -4 -4 4 4 - - |
| 225 |
\dashed |
| 226 |
lines -4 0 0 0 0 0 0 -4 # neg z and neg y |
| 227 |
\dashed |
| 228 |
5 lines 0 0 3 1.73 # neg x |
| 229 |
\arrow |
| 230 |
lines 0 0 0 4 # pos y |
| 231 |
\arrow[5] |
| 232 |
lines 0 0 4 0 # pos z |
| 233 |
10 \arrow[5] |
| 234 |
lines 0 0 -3 -1.73 # pos x |
| 235 |
\dotted |
| 236 |
lines -1 4 -1 0 -4 -1.73 # intersections y=-1 plane |
| 237 |
\dotted |
| 238 |
15 lines -1 -.577 -4 -.577 # intersection x=2 plane with xy-plane |
| 239 |
% extra helplines |
| 240 |
\dotted |
| 241 |
lines -2 .423 -2 -.577 0 0 0 1 -2 .423 |
| 242 |
Ymark 3 |
| 243 |
20 % end of extras |
| 244 |
\dotted |
| 245 |
lines 0 3 -1 3 -4 1.27 |
| 246 |
\dashed\sclosed |
| 247 |
curve -3 2.42 -1.5 2.711 -1 2.42 -2.5 2.134 |
| 248 |
25 label bc 0 \yhi $z$ |
| 249 |
label cl \xhi 0 $y$ |
| 250 |
label tr -3.1 -1.8 $x$ |
| 251 |
label cl -.85 -.577 2 |
| 252 |
label tc 0 5.5 $f(x,y)=x^2-4x+2y^2+4y+7$ |
| 253 |
30 xmark -1 |
| 254 |
Ymark 1 |
| 255 |
\shift{(-2,.42)} |
| 256 |
\dashed |
| 257 |
func 0 .5 .1 9*x*x |
| 258 |
35 func -.5 0 .1 7*x*x |
| 259 |
\dashed |
| 260 |
func -1 0 .1 2*x*x |
| 261 |
func 0 1 .1 2*x*x |
| 262 |
end |
| 263 |
\end{verbatim} |
| 264 |
\normalsize |
| 265 |
\vspace*{3ex} |
| 266 |
\makefigure{paraboloid} |
| 267 |
|
| 268 |
\setcounter{secnumdepth}{1} |
| 269 |
\onecolumn |
| 270 |
\newpage |
| 271 |
\section{The mkpic manpage\label{manpage}} |
| 272 |
\small |
| 273 |
|
| 274 |
\subsection{mkpic - interface for making pictures with mfpic} |
| 275 |
|
| 276 |
\subsection{Synopsis\label{SYNOPSIS}\index{SYNOPSIS}} |
| 277 |
|
| 278 |
mkpic [options] [picfile] |
| 279 |
|
| 280 |
options: |
| 281 |
|
| 282 |
\begin{verbatim} |
| 283 |
--clean remove all but input file and die |
| 284 |
--pdfsample create pdf file with sample images |
| 285 |
--font=<font command> set default font for labels |
| 286 |
--[no]box produce framed boxes |
| 287 |
--version report version number and die |
| 288 |
--help display help info and die |
| 289 |
--[no]debug display debugging information |
| 290 |
--log=<logfile> file for warning messages |
| 291 |
\end{verbatim} |
| 292 |
|
| 293 |
commands: |
| 294 |
|
| 295 |
\begin{verbatim} |
| 296 |
begin name xl yl xmin ymin xmax ymax xlabel ylabel |
| 297 |
end |
| 298 |
stop |
| 299 |
<var>=<value> |
| 300 |
# comment |
| 301 |
\end{verbatim} |
| 302 |
\begin{verbatim} |
| 303 |
arccst xcenter ycenter xstart ystart theta |
| 304 |
arcset xstart ystart xend yend theta |
| 305 |
arccrtt xcenter ycenter radius theta1 theta2 |
| 306 |
arc3 x1 y1 x2 y2 x3 y3 |
| 307 |
\end{verbatim} |
| 308 |
\begin{verbatim} |
| 309 |
xmark [label1] x1 [label2] x2 ... |
| 310 |
Xmark [label1] x1 [label2] x2 ... |
| 311 |
ymark [label1] y1 [label2] y2 ... |
| 312 |
Ymark [label1] y1 [label2] y2 ... |
| 313 |
\end{verbatim} |
| 314 |
\begin{verbatim} |
| 315 |
xdrop x y |
| 316 |
ydrop x y |
| 317 |
xydrop x y |
| 318 |
\end{verbatim} |
| 319 |
\begin{verbatim} |
| 320 |
arrow x1 y1 x2 y2 label |
| 321 |
label YX x y label |
| 322 |
xlabels YX x y dx label ... |
| 323 |
ylabels YX x y dy label ... |
| 324 |
\end{verbatim} |
| 325 |
\begin{verbatim} |
| 326 |
point x1 y1 x2 y2 ... |
| 327 |
dpoint x1 y1 dx1 dy1 ... |
| 328 |
lines x1 y1 x2 y2 ... |
| 329 |
dlines x1 y1 dx1 dy1 ... |
| 330 |
curve x1 y1 x2 y2 ... |
| 331 |
dcurve x1 y1 dx1 dy1 ... |
| 332 |
\end{verbatim} |
| 333 |
\begin{verbatim} |
| 334 |
rect x1 y1 x2 y2 |
| 335 |
drect x y dx dy |
| 336 |
dcrect x y dx dy |
| 337 |
crect x1 y1 x2 y2 |
| 338 |
arect xc yc width height theta |
| 339 |
bar x xdev height |
| 340 |
\end{verbatim} |
| 341 |
\begin{verbatim} |
| 342 |
func xmin xmax step expression-in-x |
| 343 |
\end{verbatim} |
| 344 |
\begin{verbatim} |
| 345 |
grid dx dy xgap ygap |
| 346 |
hatch |
| 347 |
bhat |
| 348 |
ehat |
| 349 |
\end{verbatim} |
| 350 |
\subsection{Description\label{DESCRIPTION}\index{DESCRIPTION}} |
| 351 |
|
| 352 |
\textbf{mkpic} provides an easy interface for making small pictures with |
| 353 |
mfpic. To this end you create an input file has to be created consisting |
| 354 |
of commands, one per line, with space separated parameters (or you modify the |
| 355 |
\texttt{\_\_DATA\_\_} section of the \textbf{mkpic} script, which is used if you run it |
| 356 |
without an input file). \textbf{mkpic} produces two files. Assuming an input |
| 357 |
file named \emph{picfile} defaulting to \emph{mkpic} these are: |
| 358 |
|
| 359 |
\begin{description} |
| 360 |
|
| 361 |
\item[{\emph{picfile.mac}}] |
| 362 |
|
| 363 |
a macro file which will contain \textbf{TeX} commands for every picture |
| 364 |
|
| 365 |
\item[{\emph{picfile.sty}}] |
| 366 |
|
| 367 |
a style file for latex, defining the same \textbf{TeX} commands for every picture. |
| 368 |
|
| 369 |
\end{description} |
| 370 |
|
| 371 |
With the \textbf{--pdfsample} option, two other files are produced: |
| 372 |
|
| 373 |
\begin{description} |
| 374 |
|
| 375 |
\item[{\emph{picfile.pdf}}] |
| 376 |
|
| 377 |
a PDF file containing all pictures. |
| 378 |
This lets you easily check the results of your designs. |
| 379 |
|
| 380 |
\item[{\emph{picfile.tex}}] |
| 381 |
|
| 382 |
the \textbf{TeX} source used for creating this PDF file. |
| 383 |
|
| 384 |
\end{description} |
| 385 |
|
| 386 |
In \textbf{LaTeX}, you have to include \texttt{$\backslash$usepackage\{picfile\}} and to include |
| 387 |
commands like \texttt{$\backslash$Fig$<$name$>$} in your source, where \texttt{name} is the |
| 388 |
name you gave one of your pictures in an \textbf{mkpic} \texttt{begin} command. |
| 389 |
|
| 390 |
In \textbf{TeX} and \textbf{ConTeXt}, you have to \texttt{$\backslash$input} \emph{picfile.mac} and to |
| 391 |
include commands like \texttt{$\backslash$Fig$<$name$>$} in your source, where \texttt{name} is |
| 392 |
the name you gave one of your pictures in an \textbf{mkpic} \texttt{begin} command. |
| 393 |
|
| 394 |
In \textbf{TeX}, you must use the \texttt{$\backslash$bye} command (\textbf{not} \texttt{$\backslash$end} to finish your \textbf{TeX} source |
| 395 |
|
| 396 |
See the RUNNING section for how to run \textbf{mkpic} and \textbf{TeX}/\textbf{LaTeX}/\textbf{ConTeXt}. |
| 397 |
|
| 398 |
\subsection{COMMANDS\label{COMMANDS}\index{COMMANDS}} |
| 399 |
|
| 400 |
The source is set up so that it is easy to add your own commands, |
| 401 |
|
| 402 |
Currently the following commands have been implemented: |
| 403 |
|
| 404 |
\begin{description} |
| 405 |
|
| 406 |
\item[{\textbf{begin end}}] |
| 407 |
|
| 408 |
Every picture begins with the \textbf{begin} command and ends with the \textbf{end} |
| 409 |
command. The \textbf{begin} command defines a name for the picture and |
| 410 |
defines a tex command with that name, prefixed with 'Fig'. The |
| 411 |
resulting command is written to a \emph{.mac} file. Thus the command |
| 412 |
|
| 413 |
\begin{verbatim} |
| 414 |
begin aa ... |
| 415 |
\end{verbatim} |
| 416 |
|
| 417 |
starts writing \texttt{$\backslash$def$\backslash$Figaa\{...} to the \emph{.mac} file, and the |
| 418 |
picture can be reproduced in a \textbf{TeX} document by importing the \emph{.mac} file |
| 419 |
and using the \texttt{$\backslash$Figaa} command. |
| 420 |
|
| 421 |
xl and yl are the lengths of the x- and y-axes. xlabel and ylabel are |
| 422 |
the label that are placed at the ends of those axes. Use a space to |
| 423 |
suppress labeling, or "-" to suppress drawing the axes at all. |
| 424 |
|
| 425 |
\item[{\textbf{stop}}] |
| 426 |
|
| 427 |
stops further reading of the input. Useful if you have many pictures, |
| 428 |
but want to see only the first few for testing purposes. |
| 429 |
|
| 430 |
\item[{\textbf{var=value}}] |
| 431 |
|
| 432 |
sets the variable var to value. This variable, or an expression containing it, |
| 433 |
can be used instead of any numerical parameter. Variable names may contain |
| 434 |
lower and uppercase letters, digits or underscores, with the restriction that |
| 435 |
they must start with a letter and may not end in an underscore. |
| 436 |
|
| 437 |
\item[{\#}] |
| 438 |
|
| 439 |
denotes a comment |
| 440 |
|
| 441 |
\item[{\textbf{xmark ymark Xmark Ymark}}] |
| 442 |
|
| 443 |
These commands place one or more labels along the x- or y-axes, either |
| 444 |
below (\textbf{xmark} and \textbf{ymark}) of above (\textbf{Xmark} and \textbf{Ymark}) the axis. |
| 445 |
|
| 446 |
For the \textbf{[xXyY]mark} commands a parameter containing any character |
| 447 |
other than [-.0-9] is interpreted as the label (this implies that you |
| 448 |
cannot use expressions here!) to be placed and its position is expected |
| 449 |
in the next parameter. If a parameter is just a number, it is placed at |
| 450 |
that x-position. If you want a number to be interpreted as a label, put |
| 451 |
it in braces: \textit{\{1950\}}. |
| 452 |
|
| 453 |
\item[{\textbf{arccst}}] |
| 454 |
|
| 455 |
(Mnemonic: \textbf{c}enter \textbf{s}tart \textbf{t}heta.) |
| 456 |
Draws an arc with its center in \textit{xcenter,ycenter}, starting in \textit{xstart,ystart} |
| 457 |
and with an arc length of \textit{theta} degrees. |
| 458 |
|
| 459 |
\item[{\textbf{arcset}}] |
| 460 |
|
| 461 |
(Mnemonic: \textbf{s}tart \textbf{e}nd \textbf{t}heta.) |
| 462 |
Draws an arc starting in \textit{xstart,ystart}end ending in \textit{xend,yend} |
| 463 |
and with an arc length of \textit{theta} degrees. |
| 464 |
|
| 465 |
\item[{\textbf{arccrtt}}] |
| 466 |
|
| 467 |
(Mnemonic: \textbf{c}enter \textbf{r}adius \textbf{t}heta1 \textbf{t}heta2.) |
| 468 |
Draws an arc with its center in \textit{xcenter,ycenter}, a radius \textit{radius} |
| 469 |
starting at \textit{theta1} degrees ænd ending at \textit{theta2} degrees. |
| 470 |
|
| 471 |
\item[{\textbf{arc3}}] |
| 472 |
|
| 473 |
(Mnemonic: \textbf{3} points.) |
| 474 |
Draws an arc starting at \textit{(x1,y1), through (x2,y2) and ending in (x3,y3)}. |
| 475 |
|
| 476 |
\item[{\textbf{xdrop ydrop xydrop}}] |
| 477 |
|
| 478 |
These commands draw dotted arrows perpendicularly to the x-axis, the |
| 479 |
y-axis and both axes, respectively, ending on the axes with the |
| 480 |
arrow head. |
| 481 |
|
| 482 |
\item[{\textbf{arrow}}] |
| 483 |
|
| 484 |
draws an arrow from \textit{(x1,y1)} to \textit{(x2,y2)} labeled on its tail with |
| 485 |
\textit{label} |
| 486 |
|
| 487 |
\item[{\textbf{label}}] |
| 488 |
|
| 489 |
draws a label at \textit{(x,y)}. \textit{YX} tells how it will be adjusted: for |
| 490 |
Y=t,b,c \textit{(x,y)} will be, in the y-direction, on top, bottom or center |
| 491 |
of the label respectively, for X=l,r,c it will be, in the x-direction, |
| 492 |
left, right or center adjusted on \textit{(x,y)}. Thus |
| 493 |
|
| 494 |
\begin{verbatim} |
| 495 |
label tl 0 0 Hello World! |
| 496 |
\end{verbatim} |
| 497 |
|
| 498 |
will draw the string "Hello World" with its lower left corner at (0,0) |
| 499 |
|
| 500 |
\item[{\textbf{xlabels}}] |
| 501 |
|
| 502 |
draws many labels, starting at \textit{(x,y)}, and incrementing \textit{x} with \textit{dx} |
| 503 |
after every label. \textit{YX}: see \textbf{label}. Labels may not contain spaces; |
| 504 |
if you need spaces, use \texttt{\~{}} instead. |
| 505 |
|
| 506 |
\item[{\textbf{ylabels}}] |
| 507 |
|
| 508 |
Same as \textbf{xlabels}, but incrementing \textit{y} with \textit{dy} instead. |
| 509 |
|
| 510 |
\item[{\textbf{point}}] |
| 511 |
|
| 512 |
draws points (dots) at \textit{(x1,y1)}, \textit{(x2,y2)} et cetera. |
| 513 |
|
| 514 |
\item[{\textbf{dpoint}}] |
| 515 |
|
| 516 |
draws points (dots) starting at \textit{(x1,y1)} and then moving by |
| 517 |
\textit{(dx1,dy1)}, \textit{(dx2,dy2)} et cetera. |
| 518 |
|
| 519 |
\item[{\textbf{lines}}] |
| 520 |
|
| 521 |
draws line segments from \textit{(x1,y1)} to \textit{(x2,y2)}, \textit{(x3,y3)} et cetera. |
| 522 |
|
| 523 |
\item[{\textbf{dlines}}] |
| 524 |
|
| 525 |
draws line segments starting at \textit{(x1,y1)} and then moving by |
| 526 |
\textit{(dx1,dy1)}, \textit{(dx2,dy2)} et cetera. |
| 527 |
|
| 528 |
\item[{\textbf{curve}}] |
| 529 |
|
| 530 |
draws a bezier curve from \textit{(x1,y1)} to \textit{(x2,y2)}, \textit{(x3,y3)} et cetera. |
| 531 |
|
| 532 |
\item[{\textbf{dcurve}}] |
| 533 |
|
| 534 |
draws a bezier curve starting at \textit{(x1,y1)} and then moving by |
| 535 |
\textit{(dx1,dy1)}, \textit{(dx2,dy2)} et cetera. |
| 536 |
|
| 537 |
\item[{\textbf{rect}}] |
| 538 |
|
| 539 |
draws a rectangle with diagonal points at \textit{(x1,y1)} and \textit{(x2,y2)}. |
| 540 |
|
| 541 |
\item[{\textbf{drect}}] |
| 542 |
|
| 543 |
draws a rectangle with diagonal points at \textit{(x,y)} and \textit{(x+dx,y+dy)}. |
| 544 |
|
| 545 |
\item[{\textbf{crect}}] |
| 546 |
|
| 547 |
clears a rectangle with diagonal points at \textit{(x1,y1)} and \textit{(x2,y2)}. |
| 548 |
|
| 549 |
\item[{\textbf{dcrect}}] |
| 550 |
|
| 551 |
clears a rectangle with diagonal points at \textit{(x,y)} and \textit{(x+dx,y+dy)}. |
| 552 |
|
| 553 |
\item[{\textbf{arect}}] |
| 554 |
|
| 555 |
draws a rectangle with a widdh \textit{width} and æ height \textit{height}; |
| 556 |
the middle of the bottom is at \textit{(xc,yc)} and the centerline through |
| 557 |
\textit{(xc,yc)} makes an angle \textit{theta} with the x-axis. |
| 558 |
|
| 559 |
\item[{\textbf{bar}}] |
| 560 |
|
| 561 |
draws a equivalent with \textit{rect x-xdev 0 x+xdev height} |
| 562 |
|
| 563 |
\item[{\textbf{func}}] |
| 564 |
|
| 565 |
draws the function given by \textit{expression-in-x} between \textit{xmin} and |
| 566 |
\textit{xmax}, stepping with \textit{step} units in the x-direction. |
| 567 |
Note that the \textit{expression-in-x} will be evaluated by \textbf{metafont}, so |
| 568 |
you will have to use metafont syntax. |
| 569 |
|
| 570 |
\item[{\textbf{grid}}] |
| 571 |
|
| 572 |
draw dotted grid lines at distances dx and dy in the x- and y |
| 573 |
directions; the gaps between the dots are set to \textit{xgap} an \textit{ygap} |
| 574 |
respectively. For an esthetic appearance, be sure to use integer |
| 575 |
\textit{dx/xgap} ænd \textit{dy/ygap} ratios. |
| 576 |
|
| 577 |
\item[{\textbf{hatch}}] |
| 578 |
|
| 579 |
hatch the closed curve that follows. |
| 580 |
|
| 581 |
\item[{\textbf{bhat}}] |
| 582 |
|
| 583 |
starts a path that will eventually be closed, and then hatched. |
| 584 |
|
| 585 |
\item[{\textbf{ehat}}] |
| 586 |
|
| 587 |
ends a path started with \textbf{bhat}, closes it and then hatches it. |
| 588 |
|
| 589 |
\item[{\textbf{anything else}}] |
| 590 |
|
| 591 |
will be inserted as is in the macro file, and therefore should be a |
| 592 |
valid \textit{mfpic} statement. You use this when you need such a statement |
| 593 |
only once, or a few times and therefore see no need to define a proper |
| 594 |
command for it. |
| 595 |
|
| 596 |
\end{description} |
| 597 |
\subsection{Running mkpic/TeX\label{RUNNING_mkpic_TeX}\index{RUNNING mkpic/TeX}} |
| 598 |
\subsubsection*{The difficult way\label{The_difficult_way}\index{The difficult way}} |
| 599 |
|
| 600 |
The effect of running \textbf{mkpic picfile} is the creation of |
| 601 |
\emph{picfile.mac}, which you can \texttt{$\backslash$input} into a \textbf{TeX} or \textbf{ConTeXt} source, |
| 602 |
and \emph{picfile.sty} which can be input into a \textbf{LaTeX} source using the |
| 603 |
\texttt{$\backslash$usepackage} command. |
| 604 |
|
| 605 |
After running \textbf{TeX} (or \textbf{LaTeX} or \textbf{ConTeXt}), you will find a file |
| 606 |
\emph{picfile.mf} and you will have to run \textbf{metafont} on it, which |
| 607 |
(assuming you configured \textbf{TeX} for 600 dpi) produces picfile.600gf. This |
| 608 |
file will have to be converted to a pk file with \textbf{gftopk}. Finally, you |
| 609 |
need to run \textbf{TeX} again. So the sequence is: |
| 610 |
|
| 611 |
\begin{description} |
| 612 |
|
| 613 |
\item[{\$}] |
| 614 |
|
| 615 |
mkpic picfile |
| 616 |
|
| 617 |
\item[{\$}] |
| 618 |
|
| 619 |
tex file.tex |
| 620 |
|
| 621 |
\item[{\$}] |
| 622 |
|
| 623 |
mf picfile |
| 624 |
|
| 625 |
\item[{\$}] |
| 626 |
|
| 627 |
gftopk picfile.600gf |
| 628 |
|
| 629 |
\item[{\$}] |
| 630 |
|
| 631 |
tex file |
| 632 |
|
| 633 |
\end{description} |
| 634 |
\subsubsection*{The easy way\label{The_easy_way}\index{The easy way}} |
| 635 |
|
| 636 |
You can also include this line into your \textbf{TeX} or \textbf{ConTeXt} source (before |
| 637 |
\texttt{$\backslash$input}ing picfile.mac) or into your \textbf{LaTeX} source (before |
| 638 |
\texttt{$\backslash$usepackage\{picfile\}}: |
| 639 |
|
| 640 |
\texttt{$\backslash$immediate$\backslash$write18\{mkpic picfile\}} |
| 641 |
|
| 642 |
and \textbf{TeX} (\textbf{LaTeX}, \textbf{ConTeXt}) will do everything for you, except that you |
| 643 |
will have to run \textbf{TeX} at least twice. You need, however, to 1) finish |
| 644 |
your texjob with \texttt{$\backslash$bye}, \textbf{not} \texttt{$\backslash$end}, and 2) enable the \texttt{$\backslash$write18} |
| 645 |
command by setting, in \emph{texmf.cnf}, the \texttt{shell\_escape} variable to |
| 646 |
true (\texttt{t}) (or ask your system administrator to do so). |
| 647 |
|
| 648 |
\subsection{Bug\label{BUG}\index{BUG}} |
| 649 |
Currently only up to 256 pictures can be generated. In the future this |
| 650 |
problem will probably be solved by introducing more than one font and |
| 651 |
generating tex-command names that have the font name in front. |
| 652 |
|
| 653 |
\subsection{Author\label{AUTHOR}\index{AUTHOR}} |
| 654 |
|
| 655 |
Wybo Dekker ([email protected]) |
| 656 |
|
| 657 |
\end{document} |