summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/mfpic/mfpguide.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/mfpic/mfpguide.tex')
-rw-r--r--Master/texmf-dist/doc/generic/mfpic/mfpguide.tex865
1 files changed, 442 insertions, 423 deletions
diff --git a/Master/texmf-dist/doc/generic/mfpic/mfpguide.tex b/Master/texmf-dist/doc/generic/mfpic/mfpguide.tex
index ea0eaf04d88..1a12dbfc49b 100644
--- a/Master/texmf-dist/doc/generic/mfpic/mfpguide.tex
+++ b/Master/texmf-dist/doc/generic/mfpic/mfpguide.tex
@@ -1,18 +1,10 @@
%%% File: mfpguide.tex
-%%% A part of mfpic 0.7a beta 2004/04/16
+%%% A part of mfpic 0.9 2006/05/26
%%%
% Tutorial on mfpic
\documentclass[letterpaper]{article}
-\usepackage{pslatex}
-
-\usepackage{mfpdoc}
-\usepackage{verbatim}
-
-\makeatletter
-\def\verbatim@processline{\hspace{20pt}\the\verbatim@line\par}
-\@addtoreset{figure}{section}
-\makeatother
+\usepackage[chapters]{mfpdoc}
\renewcommand{\thefigure}{\thesection.\arabic{figure}}
@@ -20,15 +12,20 @@
{\figure[htb] \centering \refstepcounter{figure} \label{#1}}
{\par\medskip Figure \thefigure. \endfigure}
-\usepackage[dvipdfm]{graphics}
+\ifpdf
+ \usepackage[pdftex,final]{graphics}
+\else
+ \usepackage[dvips,final]{graphics}
+\fi
\usepackage[metapost]{mfpic}
\opengraphsfile{guide}
+\dotsize1pt
\ifpdf
-\usepackage[pdftex,colorlinks,pdfpagemode=none,pdfstartview=FitH,%
-plainpages=false,hypertexnames=true]{hyperref}
-\pdfstringdefDisableCommands{\def\cs#1{\otherbackslash#1}%
- \def\opt#1{#1}\def\prog#1{#1}}
+\expandafter\usepackage\expandafter
+ [\mfpHyOpts]{hyperref}
+\expandafter\pdfstringdefDisableCommands\expandafter
+ {\mfpHyDisable}
\fi
\def\theHfigure{\thefigure}
@@ -42,7 +39,7 @@ plainpages=false,hypertexnames=true]{hyperref}
\maketitle
\tableofcontents
-\section{Introduction}\label{sec:intro}
+\chapter{Introduction}\label{sec:intro}
As this document aims only to instruct the reader in the building of
figures with \mfp{}, we will not be too concerned with the intricacies
@@ -58,16 +55,17 @@ We will start right out with the ``Hello, world'' of \mfp{}. Construct a
\LaTeX{} document by typing the following in a text editor and saving it
as \file{first.tex}.
\begin{verbatim}
- \documentclass{article}
- \usepackage[metapost]{mfpic}
- \opengraphsfile{myfigs}
- \begin{document}
- My first figure:
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \ellipse{(0,0),1,.5}
- \end{mfpic}
- \closegraphsfile
- \end{document}
+% first.tex
+\documentclass{article}
+ \usepackage[metapost]{mfpic}
+ \opengraphsfile{myfigs}
+\begin{document}
+ My first figure:
+ \begin{mfpic}[72]{-1}{1}{-1}{1}
+ \ellipse{(0,0),1,.5}
+ \end{mfpic}
+ \closegraphsfile
+\end{document}
\end{verbatim}
Run the command
\begin{ex}
@@ -116,20 +114,21 @@ of \pdfLaTeX). This file should be created only after running
If you get an error message from \LaTeX{}, carefully check your typing.
Also check whether an older version of \mfp{} might have been used
instead of the current version. If you get an error message from \MP{}
-do the same, especially within the \env{mfpic} environment. If you get a
-message from \MP{} that ``Grafbase'' believes your \mfp{} installation
-may be broken, check the log files (\file{first.log} and
-\file{myfigs.log}) to find out the locations of these input files:
+do the same, especially checking the typing within the \env{mfpic}
+environment. If you get a message from \MP{} that ``Grafbase'' believes
+your \mfp{} installation may be broken, check the log files
+(\file{first.log} and \file{myfigs.log}) to find out the locations of
+these input files:
\begin{ex}
\file{mfpic.tex} and \file{grafbase.mp}
\end{ex}
and make sure that both these files are from the most recently installed
\mfp{} package. If you are only evaluating \mfp{} without committing to
-upgrading it, just make sure all the files mentioned in the previous
+installing it, just make sure all the files mentioned in the previous
paragraphs are in the current directory.
If \pdfLaTeX{} complains it can't write on the file \file{first.pdf},
-unload first.pdf from your pdf viewer and try again.
+unload \file{first.pdf} from your pdf viewer and try again.
If the figures look a little choppy in Acrobat Reader, turn on ``smooth
line art'' in the edit preferences dialogue.
@@ -140,9 +139,9 @@ obtain the ellipse of figure~\ref{fig1}. Each time you change an
change the file \file{myfigs.mp} produced and you should repeat the
sequence:
\begin{verbatim}
- pdflatex first
- mpost myfigs
- pdflatex first
+pdflatex first
+mpost myfigs
+pdflatex first
\end{verbatim}
to be sure of seeing the changes.
@@ -151,18 +150,18 @@ is positioned quite a bit above the base line of the text. This is
because \mfp{} reserves the amount of space specified in the arguments
of the \env{mfpic} environment. These arguments are
\verb$[72]{-1}{1}{-1}{1}$, which means the each unit in the picture is
-72 times the value of \cs{mfpicunit}, that is, about one inch. the first
+72 times the value of \cs{mfpicunit}, that is, about one inch. The first
pair of mandatory arguments, \verb${-1}{1}$, indicate the
$x$-coordinates run from $-1$ to $1$. Since these differ by 2, they
indicate a width of two inches. The second pair similarly represents a
height of two inches. But the ellipse is centered at $(0,0)$, which is
one inch above the bottom (bottom is at $y = -1$), and its vertical
-radius is .5. So the lowest point on the ellipse should be .5 inches
+radius is .5. So the lowest point on the ellipse should be 0.5 inches
above the bottom of the space reserved. \Mfp{} provides a way to fit the
space reserved to the actual extent of `ink' in the picture. That is by
the option \opt{truebbox}:
\begin{verbatim}
- \usepackage[metapost,truebbox]{mfpic}
+\usepackage[metapost,truebbox]{mfpic}
\end{verbatim}
This would then produce something like figure~\ref{fig2}.
From now on, this option will be in effect in our examples.
@@ -180,16 +179,16 @@ still needed in order to establish the coordinate system that the
ordered pairs refer to (for example \texttt{(0,0)} in the \cs{ellipse}
arguments).
-\section{Positioning text}\label{sec:text}
+\chapter{Positioning text}\label{sec:text}
By now you are probably thinking: ``This so-called `Hello, world'
of \mfp{} doesn't say `Hello, world' anywhere!'' We correct that
with the following example:
\begin{verbatim}
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \ellipse{(0,0),1,.5}
- \tlabel[cc](0,0){Hello, world.}
- \end{mfpic}
+\begin{mfpic}[72]{-1}{1}{-1}{1}
+ \ellipse{(0,0),1,.5}
+ \tlabel[cc](0,0){Hello, world.}
+\end{mfpic}
\end{verbatim}
This should give you figure~\ref{fig3}.
\begin{mfpfig}{fig3}
@@ -214,10 +213,10 @@ communicate to both the text placement and the curve generation
procedures that they are to be centered at the point $(0,0)$. (We'll see
an easier way to do this later.)
\begin{verbatim}
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \tlabeljustify{cc}
- \tlabeloval(0,0){Hello, world.}
- \end{mfpic}
+\begin{mfpic}[72]{-1}{1}{-1}{1}
+ \tlabeljustify{cc}
+ \tlabeloval(0,0){Hello, world.}
+\end{mfpic}
\end{verbatim}
This produces figure~\ref{fig4}.
\begin{mfpfig}{fig4}
@@ -228,37 +227,40 @@ This produces figure~\ref{fig4}.
\end{mfpfig}
This would be better still if a little space is left around the text so
-the ellipse doesn't touch it. The \cs{tlabelsep} command can do that:
+the ellipse doesn't touch it. The \cs{tlpathsep} command can do that:
\begin{verbatim}
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \tlabeljustify{cc}
- \tlabelsep{3pt}
- \tlabeloval(0,0){Hello, world.}
- \end{mfpic}
+\begin{mfpic}[72]{-1}{1}{-1}{1}
+ \tlabeljustify{cc}
+ \tlpathsep{3pt}
+ \tlabeloval(0,0){Hello, world.}
+\end{mfpic}
\end{verbatim}
producing figure~\ref{fig5}.
\begin{mfpfig}{fig5}
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \tlabeljustify{cc}
- \tlabelsep{3pt}
- \tlabeloval(0,0){Hello, world.}
- \end{mfpic}
+\begin{mfpic}[72]{-1}{1}{-1}{1}
+ \tlabeljustify{cc}
+ \tlpathsep{3pt}
+ \tlabeloval(0,0){Hello, world.}
+\end{mfpic}
\end{mfpfig}
-Now it would be nice to make the text pop out a bit with some color.
-Adding \verb$\gfill[yellow]$ in front of either \verb$\ellipse$ or
-\verb$\tlabeloval$ will do that:
+It would be nice to make the text pop out a bit with some color%
+ \footnote{Colors are included in this document only to give
+ examples of their use in \prog{mfpic}. I do not necessarily
+ recommend any of them.}%
+. You can do that by adding \verb$\gfill[yellow]$ in front of either
+\verb$\ellipse$ or \verb$\tlabeloval$:
\begin{verbatim}
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \tlabelsep{3pt}
- \tlabeljustify{cc}
- \gfill[yellow]\tlabeloval(0,0){Hello, world.}
- \end{mfpic}
+\begin{mfpic}[72]{-1}{1}{-1}{1}
+ \tlpathsep{3pt}
+ \tlabeljustify{cc}
+ \gfill[yellow]\tlabeloval(0,0){Hello, world.}
+\end{mfpic}
\end{verbatim}
This will produce figure~\ref{fig6}.
\begin{mfpfig}{fig6}
\begin{mfpic}[72]{-1}{1}{-1}{1}
- \tlabelsep{3pt}
+ \tlpathsep{3pt}
\tlabeljustify{cc}
\gfill[yellow]\tlabeloval(0,0){Hello, world.}
\end{mfpic}
@@ -272,28 +274,28 @@ before the \verb$\gfill$. You can draw the curve in a color other than
black with an optional argument. We can also make the line thicker with
the command \verb$\penwd$:
\begin{verbatim}
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \penwd{1.5pt}
- \tlabelsep{3pt}
- \tlabeljustify{cc}
- \draw[blue]\gfill[yellow]\tlabeloval(0,0){Hello, world.}
- \end{mfpic}
+\begin{mfpic}[72]{-1}{1}{-1}{1}
+ \penwd{1.5pt}
+ \tlpathsep{3pt}
+ \tlabeljustify{cc}
+ \draw[blue]\gfill[yellow]\tlabeloval(0,0){Hello, world.}
+\end{mfpic}
\end{verbatim}
This will produce figure~\ref{fig7}.
\begin{mfpfig}{fig7}
\begin{mfpic}[72]{-1}{1}{-1}{1}
\penwd{1.5pt}
- \tlabelsep{3pt}
+ \tlpathsep{3pt}
\tlabeljustify{cc}
\draw[blue]\gfill[yellow]\tlabeloval(0,0){Hello, world.}
\end{mfpic}
\end{mfpfig}
This last version doesn't look too bad, but it seems that the oval ought
-to be a little fatter (slightly higher than it now is). By default,
+to be a little fatter (slightly higher than it is now). By default,
\verb$\tlabeloval$ will make the ratio of width to height the same as
that of the text, or rather of the text plus the additional space
-specified by \verb$\tlabelsep$. This can be changed with an optional
+specified by \verb$\tlpathsep$. This can be changed with an optional
argument, a number that multiplies the width-to-height ratio. Decreasing
this ratio will decrease the width (slightly) and increase the height.
Here we have also omitted the \cs{tlabeljustify} command and shown that
@@ -302,17 +304,17 @@ Here we have also omitted the \cs{tlabeljustify} command and shown that
include the first optional argument; if the default is intended, an
empty pair of brackets may be used.
\begin{verbatim}
- \begin{mfpic}[72]{-1}{1}{-1}{1}
- \penwd{1.5pt}
- \tlabelsep{3pt}
- \draw[blue]\gfill[yellow]\tlabeloval[.8][cc](0,0){Hello, world.}
- \end{mfpic}
+\begin{mfpic}[72]{-1}{1}{-1}{1}
+ \penwd{1.5pt}
+ \tlpathsep{3pt}
+ \draw[blue]\gfill[yellow]\tlabeloval[.8][cc](0,0){Hello, world.}
+\end{mfpic}
\end{verbatim}
This will produce figure~\ref{fig8}.
\begin{mfpfig}{fig8}
\begin{mfpic}[72]{-1}{1}{-1}{1}
\penwd{1.5pt}
- \tlabelsep{3pt}
+ \tlpathsep{3pt}
\draw[blue]\gfill[yellow]\tlabeloval[.8][cc](0,0){Hello, world.}
\end{mfpic}
\end{mfpfig}
@@ -327,22 +329,27 @@ only thing that can be used to surround text. See the manual
Here is a more common use of \verb$tlabel$ commands: labeling a graph
and axes. In the following example we have given \cs{tlabel} the option
\texttt{[bl]} to place the bottom left corner of the text at the given
-coordinates. However, we have used \verb$\tlabelsep{3pt}$ (which has the
-additional effect of moving text away from its nominal location) to
-prevent the text from colliding with the curve.
+coordinates. However, we have used \verb$\tlpointsep{3pt}$, which has
+the effect of shifting text away from its nominal location, to prevent the
+text from colliding with the curve.%
+ \footnote{One can also use \cs{tlabelsep}, which is equivalent to
+ \cs{tlpathsep} plus \cs{tlpointsep}.}
+The value set by \cs{tlpointsep} has an effect only if the point is on
+the edge of the text, so there would be no shifting with the
+\texttt{[cc]} placement used earlier.
\begin{verbatim}
- \begin{mfpic}[72]{0}{2.5}{0}{1}
- \tlabelsep{3pt}
- \polyline{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
- \tlabel[bl](.5,1){Max output}
- \dashed\polyline{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
- \tlabel[bl](1.5,.7){Max input}
- \end{mfpic}
+\begin{mfpic}[72]{0}{2.5}{0}{1}
+ \tlpointsep{3pt}
+ \polyline{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
+ \tlabel[bl](.5,1){Max output}
+ \dashed\polyline{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
+ \tlabel[bl](1.5,.7){Max input}
+\end{mfpic}
\end{verbatim}
This will produce figure~\ref{fig9}.
\begin{mfpfig}{fig9}
\begin{mfpic}[72]{0}{2.5}{0}{1}
- \tlabelsep{3pt}
+ \tlpointsep{3pt}
\polyline{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
\tlabel[bl](.5,1){Max output}
\dashed\polyline{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
@@ -355,24 +362,24 @@ Notice that \verb$\polyline$ alone produces a solid line while
by dressing up this figure with axes, some fat dots marking the
keypoints, and hash marks on the axes:
\begin{verbatim}
- \begin{mfpic}[72]{0}{2.5}{0}{1}
- \tlabelsep{3pt}
- \polyline{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
- \point[3pt]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
- \tlabel[bl](.5,1){Max output}
- \dashed\polyline{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
- \pointfillfalse
- \point[3pt]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
- \tlabel[bl](1.5,.7){Max input}
- \axes
- \xmarks{0,0.5,1,1.5,2}
- \axislabels x{{$50$} .5, {$100$} 1, {$150$} 1.5, {$200$} 2}
- \end{mfpic}
+\begin{mfpic}[72]{0}{2.5}{0}{1}
+ \tlpointsep{3pt}
+ \polyline{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
+ \point[3pt]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
+ \tlabel[bl](.5,1){Max output}
+ \dashed\polyline{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
+ \pointfillfalse
+ \point[3pt]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
+ \tlabel[bl](1.5,.7){Max input}
+ \axes
+ \xmarks{0,0.5,1,1.5,2}
+ \axislabels x{{$50$} .5, {$100$} 1, {$150$} 1.5, {$200$} 2}
+\end{mfpic}
\end{verbatim}
This will produce figure~\ref{fig10}.
\begin{mfpfig}{fig10}
\begin{mfpic}[72]{0}{2.5}{0}{1}
- \tlabelsep{3pt}
+ \tlpointsep{3pt}
\polyline{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
\point[3pt]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
\tlabel[bl](.5,1){Max output}
@@ -394,7 +401,7 @@ specified in the argument of the \env{mfpic} environment. The
axis, and a comma separated list of labels, each of which is specified
by some text to place (in braces) and the x-coordinate to place it at.
-\section{Drawing figures}
+\chapter{Drawing figures}
\Mfp{} has several predefined figures and commands to obtain essentially
any curve (provided one can obtain enough points on it with sufficient
@@ -408,12 +415,12 @@ They can be preceded by \verb$\dashed$ to make the lines dashed or
\verb$dotted$ to make them dotted. If the figure is a closed curve,
\verb$\gfill$ will fill them in.
\begin{verbatim}
- \begin{mfpic}[72]{0}{4}{0}{1}
- \rect{(0,0),(1,.75)}
- \circle{(1.5,.5),.45}
- \arc[s]{(3,0),(2,1),45}
- \ellipse[20]{(3.5, 0.5), 0.6, 0.4}
- \end{mfpic}
+\begin{mfpic}[72]{0}{4}{0}{1}
+ \rect{(0,0),(1,.75)}
+ \circle{(1.5,.5),.45}
+ \arc[s]{(3,0),(2,1),45}
+ \ellipse[20]{(3.5, 0.5), 0.6, 0.4}
+\end{mfpic}
\end{verbatim}
This produces figure~\ref{fig11}. The \verb$\arc$ command has several
forms. The optional argument picks the form to use. This one specifies
@@ -438,13 +445,13 @@ also draw smooth curves. Lets take the same points from our
\cs{polyline} example (figure~\ref{fig9}), but change \cs{polyline} to
\cs{curve}, omit the text, and add the points from figure~\ref{fig10}:
\begin{verbatim}
- \begin{mfpic}[72]{0}{2.5}{0}{1}
- \curve{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
- \point[3pt]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
- \dashed\curve{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
- \pointfillfalse
- \point[3pt]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
- \end{mfpic}
+\begin{mfpic}[72]{0}{2.5}{0}{1}
+ \curve{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
+ \point[3pt]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
+ \dashed\curve{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
+ \pointfillfalse
+ \point[3pt]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
+\end{mfpic}
\end{verbatim}
This should produce figure~\ref{fig12}.
\begin{mfpfig}{fig12}
@@ -465,18 +472,20 @@ the points are, and how sharp the turns at each point. High tension
makes the curve look a little more like a polyline. The default tension
is 1, a tension of about 5 makes the result look somewhat like a
polyline with very slightly rounded corners, very high tensions make the
-curve indistinguishable from a polyline. Another effect of increased
-tension is to reduce the little wobbles we can see in the first curve.
-Let's try a tension of 1.5, which can be specified as an optional
-argument to \cs{curve}:
+curve indistinguishable from a polyline. Tension must (almost) always be
+greater than $0.75$.
+
+Another effect of increased tension is to reduce the little wobbles we
+can see in the first curve. Let's try a tension of 1.5, which can be
+specified as an optional argument to \cs{curve}:
\begin{verbatim}
- \begin{mfpic}[72]{0}{2.5}{0}{1}
- \curve[1.5]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
- \point[3pt]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
- \dashed\curve[1.5]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
- \pointfillfalse
- \point[3pt]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
- \end{mfpic}
+\begin{mfpic}[72]{0}{2.5}{0}{1}
+ \curve[1.5]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
+ \point[3pt]{(0,.2),(.5,1),(1,.7),(1.5,0),(2,.3)}
+ \dashed\curve[1.5]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
+ \pointfillfalse
+ \point[3pt]{(0,.2),(.5,.6),(1,.3),(1.5,.7),(2,.1)}
+\end{mfpic}
\end{verbatim}
This give figure~\ref{fig13}.
\begin{mfpfig}{fig13}
@@ -494,17 +503,17 @@ connecting points or if we are trying to graph a function.
It \emph{cannot} enforce the requirement, which every function must
satisfy, that the curve should travel left-to-right. The command
\cs{fcncurve} does enforce this (assuming the points to be connected are
-listed in left-to-right order). This command also permits a tension
-argument. The dotted line in figure~\ref{fig14} is produced with
-\cs{curve}, the solid one with \cs{fcncurve}. One might want
-to increase the tension a bit here, too.
+listed in left-to-right order). This command also permits an optional
+tension argument. The dotted line in figure~\ref{fig14} is produced with
+\cs{curve}, the solid one with \cs{fcncurve}. One might conceivably want
+to decrease the tension a bit here.
\begin{verbatim}
- \begin{mfpic}[72]{0}{2.5}{0}{1}
- \dotted\curve{(0,.2),(.5,0),(.85,.5),(1,1),(1.5,0),(2,.3)}
- \fcncurve{(0,.2),(.5,0),(.85,.5),(1,1),(1.5,0),(2,.3)}
- \pointfillfalse
- \point[3pt]{(0,.2),(.5,0),(.85,.5),(1,1),(1.5,0),(2,.3)}
- \end{mfpic}
+\begin{mfpic}[72]{0}{2.5}{0}{1}
+ \dotted\curve{(0,.2),(.5,0),(.85,.5),(1,1),(1.5,0),(2,.3)}
+ \fcncurve{(0,.2),(.5,0),(.85,.5),(1,1),(1.5,0),(2,.3)}
+ \pointfillfalse
+ \point[3pt]{(0,.2),(.5,0),(.85,.5),(1,1),(1.5,0),(2,.3)}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig14}
\begin{mfpic}[72]{0}{2.5}{0}{1}
@@ -522,7 +531,7 @@ Other figures available include\leftmargini=2\leftmargini
\item[\cs{polygon}] Used just like \cs{polyline} except it connects the
last point to the first with a straight line.
\item[\cs{sector}] Makes a wedge with two straight lines and an arc. The
- arguments are almost the same as \cs{arc}\oarg{s}, but the order is
+ arguments are almost the same as \cs{arc}\oarg{p}, but the order is
different: center, radius and two angles.
\end{description}
@@ -541,7 +550,7 @@ without placing the text.
\end{description}
-\section{Functions}
+\chapter{Functions}
\CMP{} is able to calculate a number of functions natively, and still
more have been defined in \mfp{}. Also available are the usual
@@ -550,24 +559,24 @@ one unknown \gbc{x} and producing a numerical result can be graphed.
Here is an example of the graphs of $y = x^2$ and $y = \pm\sqrt{x}$.
Note that exponentials are denoted by \texttt{**} and it is important to
-note that it has the same precedence as multiplication (denoted by
-a single \texttt{*}). That is, in a formula like \mfc{3*3**2}, the
-operations are performed in order, left to right, producing $9^2 = 81$ and
-not $3\cdot 9 = 27$. Parentheses are needed if the latter is intended:
-\mfc{3*(3**2)}.
+note that it has the same precedence as multiplication (denoted by a
+single \texttt{*}). That is, in a formula like \mfc{3*3**2}, the
+operations are performed in order, left to right, producing $(3\cdot
+3)^2 = 81$ and not $3\cdot 3^2 = 27$. Parentheses are needed if the
+latter is intended: \mfc{3*(3**2)}.
\begin{verbatim}
- \setlength{\mfpicunit}{1cm}
- \begin{mfpic}{-2.5}{2.5}{-1.5}{4}
- \function{-2,2,.1}{x**2}
- \function{0,2,.1}{sqrt x}
- \function{0,2,.1}{-sqrt x}
- \axes
- \xmarks{-2,-1,1,2}
- \ymarks{-1,1,2,3}
- \tlabelsep{3pt}
- \axislabels x{{$-2$}-2,{$-1$}-1,{$1$}1,{$2$}2}
- \axislabels y{{$-1$}-1,{$1$}1,{$2$}2,{$3$}3}
- \end{mfpic}
+\setlength{\mfpicunit}{1cm}
+\begin{mfpic}{-2.5}{2.5}{-1.5}{4}
+ \function{-2,2,.1}{x**2}
+ \function{0,2,.1}{sqrt x}
+ \function{0,2,.1}{-sqrt x}
+ \axes
+ \xmarks{-2,-1,1,2}
+ \ymarks{-1,1,2,3}
+ \tlpointsep{3pt}
+ \axislabels x{{$-2$}-2,{$-1$}-1,{$1$}1,{$2$}2}
+ \axislabels y{{$-1$}-1,{$1$}1,{$2$}2,{$3$}3}
+\end{mfpic}
\end{verbatim}
This produces figure~\ref{fig15}.
\begin{mfpfig}{fig15}
@@ -579,7 +588,7 @@ This produces figure~\ref{fig15}.
\axes
\xmarks{-2,-1,1,2}
\ymarks{-1,1,2,3}
- \tlabelsep{3pt}
+ \tlpointsep{3pt}
\axislabels x{{$-2$}-2,{$-1$}-1,{$1$}1,{$2$}2}
\axislabels y{{$-1$}-1,{$1$}1,{$2$}2,{$3$}3}
\end{mfpic}
@@ -595,18 +604,18 @@ the graph is constructed by connecting the calculated points with
straight lines. Here is the same example with larger step size to
emphasize the difference (see figure~\ref{fig16})
\begin{verbatim}
- \setlength{\mfpicunit}{1cm}
- \begin{mfpic}{-2.5}{2.5}{-1.5}{4}
- \function[p]{-2,2,.5}{x**2}
- \function[p]{0,2,.5}{sqrt x}
- \function[p]{0,2,.5}{-sqrt x}
- \axes
- \xmarks{-2,-1,1,2}
- \ymarks{-1,1,2,3}
- \tlabelsep{3pt}
- \axislabels x{{$-2$}-2,{$-1$}-1,{$1$}1,{$2$}2}
- \axislabels y{{$-1$}-1,{$1$}1,{$2$}2,{$3$}3}
- \end{mfpic}
+\setlength{\mfpicunit}{1cm}
+\begin{mfpic}{-2.5}{2.5}{-1.5}{4}
+ \function[p]{-2,2,.5}{x**2}
+ \function[p]{0,2,.5}{sqrt x}
+ \function[p]{0,2,.5}{-sqrt x}
+ \axes
+ \xmarks{-2,-1,1,2}
+ \ymarks{-1,1,2,3}
+ \tlpointsep{3pt}
+ \axislabels x{{$-2$}-2,{$-1$}-1,{$1$}1,{$2$}2}
+ \axislabels y{{$-1$}-1,{$1$}1,{$2$}2,{$3$}3}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig16}
\setlength{\mfpicunit}{1cm}
@@ -617,7 +626,7 @@ emphasize the difference (see figure~\ref{fig16})
\axes
\xmarks{-2,-1,1,2}
\ymarks{-1,1,2,3}
- \tlabelsep{3pt}
+ \tlpointsep{3pt}
\axislabels x{{$-2$}-2,{$-1$}-1,{$1$}1,{$2$}2}
\axislabels y{{$-1$}-1,{$1$}1,{$2$}2,{$3$}3}
\end{mfpic}
@@ -653,16 +662,16 @@ any of the coordinates of points in drawing commands like \cs{polyline}
example (from now on the value of \cs{mfpicunit} is set to
\texttt{1cm}):\setlength{\mfpicunit}{1cm}
\begin{verbatim}
- \begin{mfpic}{-.5}{2.5}{-1.5}{1.5}
- \polyline{(2,-sqrt 2),(1,-1),(.5,- sqrt .5),(0,0),
- (.5,sqrt .5),(1,1),(2,sqrt 2)}
- \axes
- \xmarks{1,2}
- \ymarks{-1,1}
- \tlabelsep{3pt}
- \axislabels x{{$1$}1,{$2$}2}
- \axislabels y{{$-1$}-1,{$1$}1}
- \end{mfpic}
+\begin{mfpic}{-.5}{2.5}{-1.5}{1.5}
+ \polyline{(2,-sqrt 2),(1,-1),(.5,- sqrt .5),(0,0),
+ (.5,sqrt .5),(1,1),(2,sqrt 2)}
+ \axes
+ \xmarks{1,2}
+ \ymarks{-1,1}
+ \tlpointsep{3pt}
+ \axislabels x{{$1$}1,{$2$}2}
+ \axislabels y{{$-1$}-1,{$1$}1}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig17}
\begin{mfpic}{-.5}{2.5}{-1.5}{1.5}
@@ -671,7 +680,7 @@ example (from now on the value of \cs{mfpicunit} is set to
\axes
\xmarks{1,2}
\ymarks{-1,1}
- \tlabelsep{3pt}
+ \tlpointsep{3pt}
\axislabels x{{$1$}1,{$2$}2}
\axislabels y{{$-1$}-1,{$1$}1}
\end{mfpic}
@@ -696,10 +705,10 @@ it as the graph of the pair-valued function \mfc{dir(t)}. The expression
\mfc{dir(t)} gives the point whose distance from $(0,0)$ is $1$ in the
direction given by the angle \mfc{t}.
\begin{verbatim}
- \begin{mfpic}{-2}{4}{-2}{2}
- \parafcn{-2,2,.1}{(t**2,t)}
- \dotted\parafcn{45,315,5}{1.5*dir(t)}
- \end{mfpic}
+\begin{mfpic}{-2}{4}{-2}{2}
+ \parafcn{-2,2,.1}{(t**2,t)}
+ \dotted\parafcn{45,315,5}{1.5*dir(t)}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig22}
\begin{mfpic}{-2}{4}{-2}{2}
@@ -713,9 +722,9 @@ Here is an example of a graph of the polar coordinate function
$r=2\sin 3\theta$ (figure~\ref{fig23}). We use the degree version
\mfc{sind} in order to work with integers.
\begin{verbatim}
- \begin{mfpic}{-2}{2}{-2}{2}
- \plrfcn{0,180,5}{2*sind 3t}
- \end{mfpic}
+\begin{mfpic}{-2}{2}{-2}{2}
+ \plrfcn{0,180,5}{2*sind 3t}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig23}
\begin{mfpic}{-2}{2}{-2}{2}
@@ -724,7 +733,7 @@ $r=2\sin 3\theta$ (figure~\ref{fig23}). We use the degree version
\end{mfpfig}
-\section{Transforming figures}
+\chapter{Transforming figures}
\CMP{} is capable of any affine transformation (things like shifting,
rotating, scaling, reflecting and slanting) of any path. The figures
@@ -736,10 +745,10 @@ of `drawing' the path with \emph{prefix macros}. We've seen \cs{dashed},
\Mfp{} also provides for modifying the shape and position of the path
with other prefixes. Here's a simple example.
\begin{verbatim}
- \begin{mfpic}{-.5}{2.5}{-.5}{2.5}
- \rotatepath{(1,.5), 45}\rect{(0,0),(2,1)}
- \point{(1,.5)}
- \end{mfpic}
+\begin{mfpic}{-.5}{2.5}{-.5}{2.5}
+ \rotatepath{(1,.5), 45}\rect{(0,0),(2,1)}
+ \point{(1,.5)}
+\end{mfpic}
\end{verbatim}
The command \cs{rotatepath} obviously rotates the path that follows, but
it needs to know what the center of rotation will be, and how much to
@@ -757,15 +766,15 @@ Notice that we have no drawing prefix. A combination of
transformation-plus-figure is treated as a figure in its own right and
behaves the same. If we want the figure dashed, we could write
\begin{verbatim}
- \dashed\rotatepath{(1,.5),45}\rect{(0,0),(2,1)}
+\dashed\rotatepath{(1,.5),45}\rect{(0,0),(2,1)}
\end{verbatim}
It may not be obvious, but we can also write a drawing macro between
the rotation and the figure, producing figure~\ref{fig19}
\begin{verbatim}
- \begin{mfpic}{-.5}{2.5}{-.5}{2.5}
- \rotatepath{(1,.5), 45}\draw\rect{(0,0),(2,1)}
- \point{(1,.5)}
- \end{mfpic}
+\begin{mfpic}{-.5}{2.5}{-.5}{2.5}
+ \rotatepath{(1,.5), 45}\draw\rect{(0,0),(2,1)}
+ \point{(1,.5)}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig19}
\begin{mfpic}{-.5}{2.5}{-.5}{2.5}
@@ -784,67 +793,71 @@ rectangle is drawn.
Finally, try to guess what happens if we add another prefix at the
front:
\begin{verbatim}
- \begin{mfpic}{-.5}{2.5}{-.5}{2.5}
- \dotted\rotatepath{(1,.5), 45}
- \draw\rect{(0,0),(2,1)}
- \end{mfpic}
+\begin{mfpic}{-.5}{2.5}{-.5}{2.5}
+ \dotted\rotatepath{(1,.5), 45}
+ \draw\rect{(0,0),(2,1)}
+\end{mfpic}
\end{verbatim}
and if we add another rotation in front of that.
\begin{verbatim}
- \begin{mfpic}{-.5}{2.5}{-.5}{2.5}
- \rotatepath{(0,0),45}
- \dotted\rotatepath{(1,.5), 45}
- \draw\rect{(0,0),(2,1)}
- \end{mfpic}
+\begin{mfpic}{-.5}{2.5}{-.5}{2.5}
+ \rotatepath{(0,0),45}
+ \dotted\rotatepath{(1,.5), 45}
+ \draw\rect{(0,0),(2,1)}
+\end{mfpic}
\end{verbatim}
-Transformations availiable include \cs{scalepath},
-\cs{shiftpath}, \cs{xscalepath}, \cs{yscalepath}, \cs{slantpath}, and
-\cs{reflectpath}. See the manual for a description of what arguments are
-required for each. Here's a final example, producing figure~\ref{fig20}
+
+Available transformations include
+\begin{display}\raggedright
+ \cs{scalepath}, \cs{shiftpath}, \cs{xscalepath}, \cs{yscalepath},
+ \cs{slantpath}, and \cs{reflectpath}.
+\end{display}
+See the manual for a description of what arguments are required for
+each. Here's a final example, producing figure~\ref{fig20}
\begin{verbatim}
- \begin{mfpic}{-.5}{2.5}{-.5}{2.5}
- \shiftpath{(-1,1)}\draw[red]\slantpath{.5,1}\dotted
- \rotatepath{(0,0), 90}\dashed\rect{(0,0),(2,1)}
- \point{(0,0),(2,1)}
- \tlabelsep{2pt}
- \tlabel[tr](0,0){$(0,0)$}
- \tlabel[bl](2,1){$(2,1)$}
- \end{mfpic}
+\begin{mfpic}{-.5}{2.5}{-.5}{2.5}
+ \shiftpath{(-1,1)}\draw[red]\slantpath{.5,1}\dotted
+ \rotatepath{(0,0), 90}\dashed\rect{(0,0),(2,1)}
+ \point{(0,0),(2,1)}
+ \tlpointsep{2pt}
+ \tlabel[tr](0,0){$(0,0)$}
+ \tlabel[bl](2,1){$(2,1)$}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig20}
\begin{mfpic}{-.5}{2.5}{-.5}{2.5}
\shiftpath{(-1,1)}\draw[red]\slantpath{.5,1}\dotted
\rotatepath{(0,0), 90}\dashed\rect{(0,0),(2,1)}
\point{(0,0),(2,1)}
- \tlabelsep{2pt}
+ \tlpointsep{2pt}
\tlabel[tr](0,0){$(0,0)$}
\tlabel[bl](2,1){$(2,1)$}
\end{mfpic}
\end{mfpfig}
-\section{Rendering figures}
+\chapter{Rendering figures}
\emph{Rendering} is the act of making a description of a figure visible.
Examples are: drawing a solid curve, drawing a dashed curve, or filling
its interior, For \mfp{} figure macros the default, in the absence of
explicit commands, is to use \cs{draw}. That is,
\begin{verbatim}
- \rect{(0,0),(1,2)}
+\rect{(0,0),(1,2)}
\end{verbatim}
has the same result as
\begin{verbatim}
- \draw\rect{(0,0),(1,2)}
+\draw\rect{(0,0),(1,2)}
\end{verbatim}
The default rendering can be changed. Just say
\cs{setrender}\marg{\cs{dashed}}, and all figures afterward will be dashed
(see figure~\ref{fig21}).
\begin{verbatim}
- \begin{mfpic}{0}{2}{0}{1}
- \setrender{\dashed}
- \rect{(0,0),(1,1)}
- \circle{(1.5,.5),.5}
- \end{mfpic}
+\begin{mfpic}{0}{2}{0}{1}
+\setrender{\dashed}
+ \rect{(0,0),(1,1)}
+ \circle{(1.5,.5),.5}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig21}
\begin{mfpic}{0}{2}{0}{1}
@@ -873,15 +886,15 @@ produce closed paths, but \cs{polyline}, \cs{curve}, \cs{function},
The following example illustrates filling with a hatching pattern
(parallel lines) and an \emph{unfilling}. Clearing the interior of a
-path may not seem like rendering, it is treated in exactly the same way
+path may not seem like rendering, but it is treated in exactly the same way
(think of it as a negative rendering). We first hatch a rectangle, then
clear out a smaller rectangle with rounded corners to place our text
inside. The results are in figure~\ref{fig24}.
\begin{verbatim}
- \begin{mfpic}{0}{2}{0}{2}
- \draw[red]\lhatch[2pt][blue]\rect{(0,0),(2,2)}
- \gclear\tlabelrect[6pt][cc](1,1){Hatching!}
- \end{mfpic}
+\begin{mfpic}{0}{2}{0}{2}
+ \draw[red]\lhatch[2pt][blue]\rect{(0,0),(2,2)}
+ \gclear\tlabelrect[6pt][cc](1,1){Hatching!}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig24}
\begin{mfpic}{0}{2}{0}{2}
@@ -904,15 +917,15 @@ the second example the hatching goes over the dots (and a bit of the
dashes as well). If the \cs{gfill} were first, it would cover almost
everything else.
\begin{verbatim}
- \begin{mfpic}{0}{6}{0}{2}
- \penwd{2pt}
- \hatchwd{2pt}
- \drawcolor{blue}
- \hatchcolor{red}
- \fillcolor{green}
- \dashed\polkadot\rhatch[5pt]\gfill[yellow]\rect{(0,0),(2.8,1.8)}
- \rhatch[5pt]\dashed\polkadot\gfill[yellow]\rect{(3,0),(5.8,1.8)}
- \end{mfpic}
+\begin{mfpic}{0}{6}{0}{2}
+ \penwd{2pt}
+ \hatchwd{2pt}
+ \drawcolor{blue}
+ \hatchcolor{red}
+ \fillcolor{green}
+ \dashed\polkadot\rhatch[5pt]\gfill[yellow]\rect{(0,0),(2.8,1.8)}
+ \rhatch[5pt]\dashed\polkadot\gfill[yellow]\rect{(3,0),(5.8,1.8)}
+\end{mfpic}
\end{verbatim}
We've added a couple of other new features to this example. To emphasize
effects, we've increased the thickness of the drawing pen (\cs{penwd})
@@ -947,15 +960,15 @@ mandatory argument, the name of a dashing pattern. Named dashing
patterns may be created with the \cs{dashpattern} command, as shown by
the following example (see figure~\ref{fig27}):
\begin{verbatim}
- \begin{mfpic}{-3.5}{3.5}{-1}{1}
- \dashpattern{dotdash}{0pt,4pt,3pt,4pt}
- \gendashed{dotdash}\function{-pi,pi,.2}{sin 2x}
- \function{-pi,pi,.2}{cos 2x}
- \axes
- \end{mfpic}
+\begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
+ \dashpattern{dotdash}{0pt,4pt,3pt,4pt}
+ \gendashed{dotdash}\function{-pi,pi,.2}{sin 2x}
+ \function{-pi,pi,.2}{cos 2x}
+ \axes
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig27}
- \begin{mfpic}{-3.5}{3.5}{-1}{1}
+ \begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
\dashpattern{dotdash}{0pt,4pt,3pt,4pt}
\gendashed{dotdash}\function{-pi,pi,.2}{sin 2x}
\function{-pi,pi,.2}{cos 2x}
@@ -979,12 +992,12 @@ something other than tiny dots. The \cs{plot} command does that. It
takes one mandatory argument, the name of a symbol to use instead of a
dot. Here are the same two curves \cs{plot}-ed (figure~\ref{fig28}):
\begin{verbatim}
- \begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
- \setlength{\pointsize}{2.5pt}
- \plot{Triangle}\function{-pi,pi,.2}{sin 2x}
- \plot[2pt,6pt]{SolidCircle}\function{-pi,pi,.2}{cos 2x}
- \axes
- \end{mfpic}
+\begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
+ \setlength{\pointsize}{2.5pt}
+ \plot{Triangle}\function{-pi,pi,.2}{sin 2x}
+ \plot[2pt,6pt]{SolidCircle}\function{-pi,pi,.2}{cos 2x}
+ \axes
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig28}
\begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
@@ -1006,10 +1019,10 @@ case of \cs{function}, these are the points $(x_k, f(x_k))$ with $x_k$
stepping through all the $x$-values determined by the first argument of
\cs{function} (figure~\ref{fig29}).
\begin{verbatim}
- \begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
- \plotnodes[2.5pt]{Square}\function{-pi,pi,pi/16}{sin 2x}
- \axes
- \end{mfpic}
+\begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
+ \plotnodes[2.5pt]{Square}\function{-pi,pi,pi/16}{sin 2x}
+ \axes
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig29}
\begin{mfpic}{-3.5}{3.5}{-1.2}{1.2}
@@ -1021,7 +1034,7 @@ stepping through all the $x$-values determined by the first argument of
See the manual for the list of predefined symbols available to the
\cs{plot} and \cs{plotnodes} command.
-\section{More on text}
+\chapter{More on text}
The text positioning commands used so far in this guide are entirely
handled by \TeX{} or \LaTeX. This is why we have occasionally had to say
@@ -1037,20 +1050,20 @@ the first we try to use \LaTeX's \cs{rotatebox} command, and in the
second we turn on \MP{} handling of labels and use a rotation option to
the \cs{tlabel} command.
\begin{verbatim}
- \begin{mfpic}{0}{1}{0}{1}
- \point{(0,0)}
- \polyline{(0,0),(1,1)}
- \tlabel[Bl](0,0){\rotatebox{45}{\hspace{5pt}Test text}}
- \end{mfpic}\renewcommand\thefigure{\thesection.\arabic{figure}a}
+\begin{mfpic}{0}{1}{0}{1}
+ \point{(0,0)}
+ \polyline{(0,0),(1,1)}
+\tlabel[Bl](0,0){\rotatebox{45}{\hspace{5pt}Test text}}
+\end{mfpic}
\end{verbatim}
\begin{verbatim}
- \usemplabels
- \begin{mfpic}{0}{1}{0}{1}
- \point{(0,0)}
- \polyline{(0,0),(1,1)}
- \tlabelsep{5pt}
- \tlabel[Bl45](0,0){Test text}
- \end{mfpic}
+\usemplabels
+\begin{mfpic}{0}{1}{0}{1}
+ \point{(0,0)}
+ \polyline{(0,0),(1,1)}
+ \tlpointsep{5pt}
+ \tlabel[Bl45](0,0){Test text}
+\end{mfpic}
\end{verbatim}
\begin{figure}[!hb]
\centering
@@ -1069,7 +1082,7 @@ the \cs{tlabel} command.
\begin{mfpic}{0}{1}{0}{1}
\point{(0,0)}
\polyline{(0,0),(1,1)}
- \tlabelsep{5pt}
+ \tlpointsep{5pt}
\tlabel[Bl45](0,0){Test text}
\end{mfpic}\renewcommand\thefigure{\thesection.\arabic{figure}b}
\refstepcounter{figure}\label{fig30b}
@@ -1094,10 +1107,10 @@ $$
This is then placed by the \cs{tlabel} command with the lower left
corner of the \emph{outer} box at $(0,0)$. But \LaTeX's axis of rotation
was at the lower left corner of the inner box. In the second case, \MP{}
-placed the label. The command \cs{tlabelsep}\marg{5pt} and the parameter
+placed the label. The command \cs{tlpointsep}\marg{5pt} and the parameter
\oarg{Bl45} explicitly request that the label be placed with its left
-baseline 5 points from $(0,0)$ and rotated 45 degrees \emph{about that
-point}.
+baseline 5 points from $(0,0)$ and rotated 45 degrees \emph{about the
+point $(0,0)$}.
The \cs{usemplabels} command used above asks \MP{} to arrange for the
setting of labels. Adding the option \opt{mplabels} to the
@@ -1119,7 +1132,7 @@ them pass the final responsability for text placement to \MP{} if
\opt{mplabels} is in effect. See the manual for more details.
-\section{Arrows}
+\chapter{Arrows}
The command \cs{arrow} adds an arrowhead onto the \emph{end} of any path
that follows. For this to have predictable effects, you need to know
@@ -1136,59 +1149,63 @@ points are written.
Anyway, here are a few examples, illustrating the use of \cs{arrow}, and
some of its optional arguments.
\begin{verbatim}
- \begin{mfpic}{0}{4}{0}{4}
- \arrow[r -5]\circle{(1,1),.5}
- \arrow[b 4pt]\arrow\polyline{(3,2),(3,0)}
- \arrow[c red]\reverse\arrow\polyline{(0,3),(2,3)}
- \arrow[l 5pt]\rect{(4,2),(2,4)}
- \end{mfpic}
+\begin{mfpic}{0}{4}{0}{4}
+ \arrow[r-5]\circle{(1,1),.5}
+ \arrow[b4pt]\arrow\polyline{(3,2),(3,0)}
+ \arrow[cred]\reverse\arrow\polyline{(0,3),(2,3)}
+ \arrow[l 5pt]\rect{(4,2),(2,4)}
+\end{mfpic}
\end{verbatim}
See figure~\ref{fig31} for the results of this example. There are four
possible optional arguments, the first character inside the brackets
tells what option the rest of the argument applies to. The first example
above starts with `\texttt{r}', which stands for `rotate' and asks for
-the arrowhead to be rotated -5 degrees (5 degrees clockwise). The second
-starts with `\texttt{b}', which stands for `backset' and it moves the
-head back \texttt{4pt} from where it would otherwise be placed. In the
-example, this is used to put a double arrowhead on the line. In the
-third example we put an arrow at both ends by reversing the sense of the
-curve in between the two \cs{arrow} prefixes. We also used the letter
-`\texttt{c}' in the optional argument of one arrowhead. This stands for
-`color' and the requested color is `\texttt{red}'. Finally, the
-\texttt{l} option, standing for `length', changes the length of the
-arrowhead to \texttt{5pt} (from the default \texttt{3pt}). The space
-between the letter and the value in these arguments may be omitted.
+the arrowhead to be rotated 5 degrees (positive rotation means
+anticlockwise, negative means clockwise). This is frequently useful for
+arrows on curved paths, as the default direction (tangent to the path)
+often just looks wrong). The second example starts with `\texttt{b}',
+which stands for `backset' and it moves the head back \texttt{4pt} from
+where it would otherwise be placed. In the example, this is used to put
+a double arrowhead on the line. In the third example we put an arrow at
+both ends by reversing the sense of the curve in between the two
+\cs{arrow} prefixes. We also used the letter `\texttt{c}' in the
+optional argument of one arrowhead. This stands for `color' and the
+requested color is `\texttt{red}'. Finally, the \texttt{l} option
+(that's a lowercase `ell', not the number `one') changes the length of
+the arrowhead to 5 points (from the \verb$3pt$ default).%
+ \footnote{I have put a space between the \texttt{l} and the
+ \texttt{5pt} so it won't be mistaken for `$15$pt. Normally one
+ should avoid spaces in \mfp{} optional arguments, but this is one
+ case where it will cause no harm.}
\begin{mfpfig}{fig31}
\begin{mfpic}{0}{4}{0}{4}
- \arrow[r -5]\circle{(1,1),.5}
- \arrow[b 4pt]\arrow\polyline{(3,2),(3,0)}
- \arrow[c red]\reverse\arrow\polyline{(0,3),(2,3)}
+ \arrow[r5]\circle{(1,1),.5}
+ \arrow[b4pt]\arrow\polyline{(3,2),(3,0)}
+ \arrow[cred]\reverse\arrow\polyline{(0,3),(2,3)}
\arrow[l 5pt]\rect{(4,2),(2,4)}
\end{mfpic}
\end{mfpfig}
The options can be combined in one command:
\cs{arrow}\oarg{cblue}\oarg{b4pt}\oarg{r25}\oarg{l6pt} would produce a
-\texttt{6pt} long blue arrowhead rotated 25 degrees anticlockwise, set back
-\texttt{4pt}. The setting back is done in the direction determined
+\texttt{6pt} long blue arrowhead rotated 25 degrees anticlockwise, set
+back \texttt{4pt}. The setting back is done in the direction determined
\emph{after} rotation. The order of the options is not significant.
-The need to occasionally tweak the arrowhead with a small rotation will
-be apparent if you look closely at the circle example without any
-rotation.
-
The shape of the arrowhead can be changed with the \cs{headshape}
command. The following example draws the arrowhead first normally, and
-then after an instance of this command. We increase the length of head
-and the thickness of the pen to emphasize the effects.
+then after an instance of this command. We draw it a third time, exactly
+like the second time, except we use the *-form. We have increased the
+length of head and the thickness of the pen to emphasize the effects.
\begin{verbatim}
- \begin{mfpic}{0}{4}{0}{4}
- \setlength{\headlen}{20pt}
- \penwd{3pt}
- \arrow\polyline{(0,3),(4,3)}
- \headshape{.5}{2}{true}
- \arrow\polyline{(0,1),(4,1)}
- \end{mfpic}
+\begin{mfpic}{0}{4}{0}{4}
+ \setlength{\headlen}{20pt}
+ \penwd{3pt}
+ \arrow\polyline{(0,3),(4,3)}
+ \headshape{.5}{2}{true}
+ \arrow\polyline{(0,2),(4,2)}
+ \arrow*\polyline{(0,1),(4,1)}
+\end{mfpic}
\end{verbatim}
The results are pictured in figure~\ref{fig32}. The first argument to
\cs{headshape} sets the ratio of width to height for the head. We have
@@ -1196,19 +1213,23 @@ cut it in half here. The second argument sets the tension in the curves
that form the sides of the head. This reduces the curvature in the
sides. The third argument can be only \texttt{true} or \texttt{false}
and determines whether the head is a solid shape, or only the two
-`barbs'. The defaults correspond to \verb$\headshape{1}{1}{false}$
+`barbs'. The defaults correspond to \verb$\headshape{1}{1}{false}$. The
+filled form does not draw the outline so what we see is the pointy
+arrowhead on top of a thick line. The *-form tries to erase part of the
+line so that one sees an actual pointy arrow.
\begin{mfpfig}{fig32}
\begin{mfpic}{0}{4}{0}{4}
\setlength{\headlen}{20pt}
\penwd{3pt}
\arrow\polyline{(0,3),(4,3)}
\headshape{.5}{2}{true}
- \arrow\polyline{(0,1),(4,1)}
+ \arrow\polyline{(0,2),(4,2)}
+ \arrow*\polyline{(0,1),(4,1)}
\end{mfpic}
\end{mfpfig}
-\section{Color}
+\chapter{Color}
We saw the use of color in earlier sections, and now it's time to be
systematic about it. The several rendering commands have a color option;
@@ -1235,8 +1256,7 @@ and an optional argument to be described later.
figure macros used without any rendering prefix, as well as
\cs{axes} and related commands.
\item[\cs{fillcolor}] This sets the default color used by \cs{gfill}. It
- is also the color used by \cs{polkadot} (which has no color
- option).
+ is also used by \cs{polkadot} (which has no color option).
\item[\cs{hatchcolor}] This sets the default color used by any hatching
command.
\item[\cs{headcolor}] This sets the default color for arrowheads added
@@ -1260,36 +1280,36 @@ The optional argument is one of the \emph{color models}. See the manual
for details, but the syntax is just like that of the \prog{color}
package's \cs{color} command. For example,
\begin{verbatim}
- \pointcolor[rgb]{0,1,0}
+\pointcolor[rgb]{0,1,0}
\end{verbatim}
would use the color model \opt{rgb} with parameters 0, 1, and 0 (this is
green). After each of these commands a certain color name is assigned a
value. For example, a use of the \cs{pointcolor} command assigns a value
-to the color named \gbc{pointcolor}. This pattern is followed for all the
-color setting commands above (i.e., \cs{drawcolor} sets \gbc{drawcolor})
-except \cs{backgroundcolor}, which assigns its value to the color named
-\gbc{background}.
+to the color named \gbc{pointcolor}. Also \cs{drawcolor} sets
+\gbc{drawcolor} and this pattern is followed for all the color setting
+commands above except \cs{backgroundcolor}, which assigns its value to
+the color named \gbc{background}.
Color names for \mfp{} use can be defined using the \cs{mfpdefinecolor}
command. Here's an example (figure~\ref{fig33}). Note the use of the
color name \gbc{pointcolor} to make arrowheads and points have the same
color.
\begin{verbatim}
- \begin{mfpic}{0}{3.5}{0}{3.5}
- \tlabelcolor{red}
- \pointcolor{rgb(0,1,0)}% green
- \drawcolor[rgb]{0,0,1} % blue
- \fillcolor{Goldenrod} % from dvipsnam.mp
- \headcolor{pointcolor} % will be green after above
- \mfpdefinecolor{DarkerRed}{rgb}{.67,0,0}
- \hatchcolor{DarkerRed}
- \penwd{1pt}
- \gfill\circle{(1,1),.5}
- \point[3pt]{(1,.5),(1,1.5),(.5,1),(1.5,1)}
- \hatch\rect{(2.5,2.5),(3.5,3.5)}
- \arrow[l 5pt]\polyline{(1,1),(3,3)}
- \tlabel[cc](1,3){Examples \\of\\colors}
- \end{mfpic}
+\begin{mfpic}{0}{3.5}{0}{3.5}
+ \tlabelcolor{red}
+ \pointcolor{rgb(0,1,0)}% green
+ \drawcolor[rgb]{0,0,1} % blue
+ \fillcolor{Goldenrod} % from dvipsnam.mp
+ \headcolor{pointcolor} % will be green after above
+ \mfpdefinecolor{DarkerRed}{rgb}{.67,0,0}
+ \hatchcolor{DarkerRed}
+ \penwd{1pt}
+ \gfill\circle{(1,1),.5}
+ \point[3pt]{(1,.5),(1,1.5),(.5,1),(1.5,1)}
+ \hatch\rect{(2.5,2.5),(3.5,3.5)}
+ \arrow[l 5pt]\polyline{(1,1),(3,3)}
+ \tlabel[cc](1,3){Examples\\of\\colors}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig33}
\begin{mfpic}{0}{3.5}{0}{3.5}
@@ -1305,11 +1325,11 @@ color.
\point[3pt]{(1,.5),(1,1.5),(.5,1),(1.5,1)}
\hatch\rect{(2.5,2.5),(3.5,3.5)}
\arrow[l 5pt]\polyline{(1,1),(3,3)}
- \tlabel[cc](1,3){Examples \\of\\colors}
+ \tlabel[cc](1,3){Examples\\of\\colors}
\end{mfpic}
\end{mfpfig}
-\section{Closing paths}
+\chapter{Closing paths}
There are many different ways to modify a figure. We have already seen
\cs{arrow}, which appends an arrowhead, \cs{reverse} which reverses the
@@ -1324,41 +1344,40 @@ that can do the job, the simplest being \cs{lclosed}, which closes with
a straight line. Putting \cs{lclosed} in front of \cs{polyline}, for
example, produces the same result as \cs{polygon}. Another macro is
\cs{sclosed} which produces a smooth closure. Putting it in front of
-\cs{curve} gives the same result as \cs{cyclic}. There is one other
-useful macro, \cs{bclosed}, which also informs \MP{} to make a
-smooth closure. The difference between \cs{sclosed} and
-\cs{bclosed} is that the first modifies slightly the original path (in
-order to achieve the effect that
-\cs{sclosed}${}+{}$\cs{curve}${}={}$\cs{cyclic}), the second just asks
-\MP{} to do its best to connect the ends smoothly. Here's an example
-comparing the two smooth methods (figure~\ref{fig34}).
+\cs{curve} gives (almost) the same result as \cs{cyclic}. There is one
+other useful macro, \cs{bclosed}, which also informs \MP{} to make a
+smooth closure. The difference between \cs{sclosed} and \cs{bclosed} is
+that the first modifies slightly the original path (in order to achieve
+the effect that \cs{sclosed}${}+{}$\cs{curve}${}\approx{}$\cs{cyclic}),
+the second just asks \MP{} to do its best to connect the ends smoothly.
+Here's an example comparing the two smooth methods (figure~\ref{fig34}).
\begin{verbatim}
- \begin{mfpic}{0}{4}{0}{4}
- % an open curve:
- \curve{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
- % \sclosed a shifted copy:
- \draw\gfill[green]\sclosed\shiftpath{(2,0)}
- \curve{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
- % \bclosed another copy:
- \draw\gfill[yellow]\bclosed\shiftpath{(2,-2)}
- \curve{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
- % \cyclic with same points, shifted:
- \draw\gfill[red]\shiftpath{(0,-2)}
- \cyclic{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
- \tlabeljustify{bc}
- \nomplabels
- \tlabels{
- (1,2.4){\cs{curve}}
- (3,2.4){\cs{sclosed}}
- (1,0.4){\cs{cyclic}}
- (3,0.4){\cs{bclosed}}
- }
- % Some points to help illustrate
- \point{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
- \point{(2.49,3),(2.5,3.7),(3,4),(3.5,3.7),(3.51,3)}
- \point{(0.49,1),(.5,1.7),(1,2),(1.5,1.7),(1.51,1)}
- \point{(2.49,1),(2.5,1.7),(3,2),(3.5,1.7),(3.51,1)}
- \end{mfpic}
+\begin{mfpic}{0}{4}{0}{4}
+ % an open curve:
+ \curve{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
+ % \sclosed a shifted copy:
+ \draw\gfill[green]\sclosed\shiftpath{(2,0)}
+ \curve{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
+ % \bclosed another copy:
+ \draw\gfill[yellow]\bclosed\shiftpath{(2,-2)}
+ \curve{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
+ % \cyclic with same points, shifted:
+ \draw\gfill[red]\shiftpath{(0,-2)}
+ \cyclic{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
+ \tlabeljustify{bc}
+ \nomplabels
+ \tlabels{
+ (1,2.4){\cs{curve}}
+ (3,2.4){\cs{sclosed}}
+ (1,0.4){\cs{cyclic}}
+ (3,0.4){\cs{bclosed}}
+ }
+ % Some points to help illustrate
+ \point{(0.49,3),(.5,3.7),(1,4),(1.5,3.7),(1.51,3)}
+ \point{(2.49,3),(2.5,3.7),(3,4),(3.5,3.7),(3.51,3)}
+ \point{(0.49,1),(.5,1.7),(1,2),(1.5,1.7),(1.51,1)}
+ \point{(2.49,1),(2.5,1.7),(3,2),(3.5,1.7),(3.51,1)}
+\end{mfpic}
\end{verbatim}
\begin{mfpfig}{fig34}
\begin{mfpic}{0}{4}{0}{4}
@@ -1394,28 +1413,27 @@ provided we had used \verb$\mfpverbtex$ to write the appropriate
\LaTeX{} preamble to the \file{.mp} output. It would need to be some
subset of the preamble of this document.
-\appendix
-\section{Appendices}
+\chapter{Appendices}
In addition to \pdfLaTeX, \Mfp{} works with plain \pdfTeX, \LaTeX, and
plain \TeX{}. Instead of \MP{} as the figure processor, \MF{} can also
be used. Let's start with the difference between using \mfp{} in a
plain~\TeX{} document and using it in a \LaTeX{} document.
-\subsection{\Mfp{} in plain \TeX}
+\section{\Mfp{} in plain \TeX}
Here is a sample plain \pdfTeX{} document with results the same as our
first ``Hello, world'' example. Let's call this file \file{plfirst}
\begin{verbatim}
- \input mfpic
- \usemetapost
- \opengraphsfile{myfigs}
- My first figure:
- \mfpic[72]{-1}{1}{-1}{1}
- \ellipse{(0,0),1,.5}
- \endmfpic
- \closegraphsfile
- \end
+\input mfpic
+ \usemetapost
+\opengraphsfile{myfigs}
+ My first figure:
+ \mfpic[72]{-1}{1}{-1}{1}
+ \ellipse{(0,0),1,.5}
+ \endmfpic
+ \closegraphsfile
+\end
\end{verbatim}
The main difference is the lack of \LaTeX{} commands. The crucial
difference is in the first two lines. There we simply
@@ -1434,41 +1452,41 @@ Also, plain \TeX{} doesn't have environments, so instead of
The external processing is essentially the same:
\begin{verbatim}
- pdftex plfirst
- mpost myfigs
- pdftex plfirst
+pdftex plfirst
+mpost myfigs
+pdftex plfirst
\end{verbatim}
should produce \texttt{plfirst.pdf} with the same picture of an ellipse.
-\subsection{\Mfp{} without PDF}
+\section{\Mfp{} without PDF}
If we wish to use nonPDF versions of \LaTeX{} or plain \TeX, the only
difference is in the processing steps. To process \file{first.tex} with
\LaTeX, run the command
-\begin{ex}
- \texttt{latex first}
-\end{ex}
+\begin{verbatim}
+latex first
+\end{verbatim}
followed by
-\begin{ex}
- \texttt{mpost myfigs}
-\end{ex}
+\begin{verbatim}
+mpost myfigs
+\end{verbatim}
followed by latex again.
-\begin{ex}
- \texttt{latex first}
-\end{ex}
+\begin{verbatim}
+latex first
+\end{verbatim}
Then run the dvi processor of your choice. It should be one that can
successfully handle eps figures (or at least the simple eps produced by
\MP). Certainly \prog{dvips} can do it:
-\begin{ex}
- \texttt{dvips first}
-\end{ex}
+\begin{verbatim}
+dvips first
+\end{verbatim}
will produce \file{first.ps}. The file{.ps} file can be viewed with
\prog{gsview} or printed, or converted to PDF with some distillation
-program like \prog{ps2pdf}. Also \prog{dvipdfm} (if recent, and properly
+program like \prog{ps2pdf}. Also \prog{dvipdfm} (if properly
configured) can be used convert the \file{.dvi} file to PDF.
-\subsection{\Mfp{} without \MP}
+\section{\Mfp{} without \MP}
\Mfp{} can produce figures using \MF{} instead of \MP. What it does is
work with \MF{} to produce a made-to-order font, where each picture is a
@@ -1495,7 +1513,7 @@ colors actually produced will be black and white (and occasionally a
pattern of pixels that simulate gray). The processing steps are
different. After
\begin{ex}
- \texttt{latex first} \quad(or \texttt{tex plfirst})
+\texttt{latex first} \quad(or \texttt{tex plfirst})
\end{ex}
run \MF:
\begin{ex}
@@ -1507,7 +1525,7 @@ might have a different number on your system) is called a \emph{generic
font} (GF) file and contains the bitmap descriptions. If the file
produced is \texttt{myfigs.2602gf}, and the \file{.tfm} is not produced,
that indicates a configuration problem with your system that we'll get
-to later. If this did work, one needs to convert the \file{gf} file to a
+to later. If this did work, one needs to convert the GF file to a
PK font file, the standard format for bitmap fonts in the \TeX{} world.
This may be done with
\begin{ex}
@@ -1528,7 +1546,7 @@ You'll have to check what your system has and what its usage might be,
and what it might do with the PK file produced.
After the above, one again runs `\texttt{latex first}' (or `\texttt{tex
-plfirst}'), and then the {.dvi} can be viewed or processed with dvips.
+plfirst}'), and then the \file{.dvi} can be viewed or processed with dvips.
The two files \file{myfigs.log} and \file{myfigs.600gf} can be deleted;
only \file{myfigs.tfm} and \file{myfigs.600pk} are needed. If the viewed
image shows the pictures at a far different size than you expect, this can
@@ -1543,15 +1561,18 @@ should \emph{always} follow the \MF{} step with the \prog{gftopk} step.
You might even want to write a batch script or makefile to ensure that
this happens.
-Another problem, more an annoyance, that can occur comes from the
+Another problem (more an annoyance) that can occur comes from the
behavior of most dvi viewers: most will reload a \file{.dvi} file if
-they detect that it has changed (or if asked to), but will usually
-\emph{not} reload any fonts even if they have changed. So if one is
-going through a edit-compile-view cycle involving \mfp{} figures, one
-usually has to close the viewer and open it again before one can see
-changes that were made in the figures after starting the viewer.
+they detect that it has changed (or if asked to), but none that I know
+of will reload any fonts even if they have changed. So if one is going
+through a edit-compile-view cycle involving \mfp{} figures, one usually
+has to close the viewer and open it again before one can see changes
+that were made in the figures after starting the viewer. It is also
+possible that PK fonts are cached and shared by other programs, so you
+may need to close other programs to ensure the cache is cleared and the
+new figures loaded.
-\subsection{\MF{} configuration problems}
+\section{\MF{} configuration problems}
To diagnose these problems it important to know something about
\emph{printer modes}. \CMF{} produces bitmap images of characters. This
@@ -1597,10 +1618,8 @@ be changed. This can be done with an ordinary text editor, or your
If you say ``\texttt{mf myfigs}'' on an \mfp{} file \file{myfigs.mf}, \mfp's
internal code will detect that no mode was defined on the command line.
It will then check if \mfc{localfont} is defined and if so, use that for
-the printer mode. Finally, if that fails, it will select \mfc{ljfour}.
-If even that is unknown, \MF{} will go into \emph{proof mode} and set
-\mfc{pixels_per_inch} equal to approximately 2602 (and it will
-\emph{not} produce a \file{.tfm} file).
+the printer mode. If that fails, it will try to select \mfc{ljfour}.
+If even that is unknown, \mfp{} will define its own generic 600 DPI mode.
\Mfp{} doesn't need to know all the parameters associated to a printer
mode, only the value of \mfc{pixels_per_inch}. If you get a GF file that
@@ -1609,6 +1628,6 @@ for the line in \file{modes.mf} that sets \mfc{localfont} to be
corrected. At the very least it should equate \mfc{localfont} to a name
defined in \file{modes.mf} and associated to a printer with the same DPI
as yours. After changing \file{modes.mf}, you need to run whatever
-programs your \TeX{} systems requires to remake the \MF{} format.
+programs your \TeX{} system requires to remake the \MF{} format.
\end{document}