%%% BEGIN pst-user.tex \def\Date{93/03/12} \def\Version{0.93a} %% LaTeX file pst-user.tex. Source for the PSTricks User's Guide. %% %% COPYRIGHT 1993, by Timothy Van Zandt, tvz@Princeton.EDU %% %% Copying of part or all of any file in the pstricks.tex package %% is allowed under the following conditions only: %% (1) You may freely distribute unchanged copies of the files. Please %% include the documentation when you do so. %% (2) You may modify a renamed copy of any file, but only for personal %% use or use within an organization. %% (3) You may copy fragments from the files, for personal use or for use %% in a macro package for distribution, as long as credit is given %% where credit is due. %% %% You are NOT ALLOWED to take money for the distribution or use of %% these files or modified versions or fragments thereof, except for %% a nominal charge for copying etc. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Under normal circumstances, you do not need to LaTeX this file because %% the User's Guide is distributed with the PSTricks package, already %% typeset and converted to PostScript, as the files pst-usr1.ps and %% pst-usr2.ps. If you do need/want to run it again, here is what to do: %% %% * You must have installed the PSTricks package. %% %% * You must run this with the New Font Selection Scheme, available from %% ftp.uni-stuttgart.de. %% Please don't direct questions about the NFSS to me. You can also %% get rid of the PostScript font stuff below and run with regular %% LaTeX, but don't expect the spacing to be right. %% %% * You must have the files %% pst-user.sty, defaults.pst, fancybox.sty, tvz-user.sty, %% tvz-hax.sty and npsfont.sty, %% which are distributed with PSTricks. %% %% * An index, pst-user.ind, is also distributed with PSTricks. You %% can use makeindex, without any special styles, to remake the index. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Include `a4' option for A4 paper, %% and/or `twoside' option for two-sided printing. %% It is not necessary to remake the index, if you make no other changes. \documentstyle{pst-user} \makeindex % Comment this out to suppress generation of .idx file. \begin{document} \begingroup \evensidemargin \paperwidth\relax \advance\evensidemargin -2in \advance\evensidemargin -\textwidth \divide\evensidemargin 2 \oddsidemargin\evensidemargin \begin{titlepage} \let\footnotesize\small \let\footnoterule\relax \setcounter{page}{0} \null \vfil \vskip 25pt \begin{center} {\LARGE\bf PSTricks}:\\[5pt] {\large\bf PostScript macros for Generic TeX.}\\ \end{center} \bigskip\bigskip \hbox to \hsize{% \hss \psset{unit=.4cm} \begin{pspicture}(0,-2)(31,12) \catcode`\<=12 \rput(1.5,0){% \psellipse[linewidth=1pt](8,7)(1,3) \psframe[linecolor=white,fillstyle=solid,fillcolor=white] (6.4,6.5)(8,7.5) \psline[linearc=.3,linewidth=1pt](8,8)(8,7.5)(4,7.5) \psbezier[linewidth=1pt](4,7.5)(3,7.5)(3,6.5)(3,5.5) \psline[linearc=.3,linewidth=1pt](8,6)(8,6.5)(5,6.5) \psbezier[linewidth=1pt](5,6.5)(4,6.5)(4,6.5)(4,5.5) \psline[linewidth=1pt](3,5.5)(4,5.5) \psline[linearc=.3,linewidth=1pt](5,7.5)(5,8)(6,8)(6,7.5) \psframe[linewidth=1pt](5.3,8)(5.7,8.7) \psframe[linewidth=1pt,framearc=1,fillstyle=solid, fillcolor=white](4,8.7)(7,9) \multirput(3.5,4.8)(0,-1){4}{% \psbezier[linewidth=.5pt](0,0)(.25,-.4)(-.25,-.4)(0,0)} \rput[t](5.5,0){Dripping Faucet}} \rput(20,5){% \pspolygon[linecolor=white,fillstyle=vlines, fillcolor=darkgray,hatchsep=.2](1,4.5)(1,4)(4,4)(4,4.5) \psline[linewidth=2pt](1,4)(4,4) \psline[linewidth=1.5pt](2.5,4)(2.5,3.5)(2.9,3.3)(2.1,2.9) (2.9,2.5)(2.1,2.1)(2.9,1.7)(2.1,1.3)(2.5,1.1)(2.5,0.6) \psframe[linecolor=black,linewidth=1.5pt,fillstyle=solid, fillcolor=lightgray](1.8,-1)(3.2,.6) \rput(2.5,-.2){$M$} \psline{<->}(3.7,-.9)(3.7,.5) \psframe[linecolor=black,linewidth=1.5pt,fillstyle=solid, fillcolor=lightgray](1.8,-3.5)(3.2,-1.9) \rput(2.5,-2.7){$m$} \psline{->}(5,1)(5,-1) \rput[l](5.5,0){$g$} \psline{->}(3.7,-2)(3.7,-3.4) \rput[t](2.5,-4){Mathematical Model for} \rput[t](2.5,-5){a Dripping Faucet} \rput(-6,-2){% \psset{linewidth=2pt} \psline(0,.5)(2,.5) \psline(0,-.5)(2,-.5) \psline(1.5,1)(2.5,0)(1.5,-1)}} \psframe[linewidth=2pt,framearc=.05,linecolor=gray](0,-2.5)(31,12) \uput[l]{90}(0,4.75){\tt{leecheng}} \end{pspicture}% \hss} \bigskip \bigskip \begin{center} {\LARGE\bf User's Guide}\par \vskip 3em {\large \lineskip .75em Timothy Van Zandt}\par \vskip 1.5em {\large \thefiledate\\[2pt]Version \fileversion}\par \end{center} \vfil \small Author's address:\\ Department of Economics, Princeton University,\\ Princeton, NJ 08544-1021, USA. Internet: {\tt tvz@Princeton.EDU} \end{titlepage} \endgroup \setcounter{footnote}{0} \tableofcontents \pagenumbering{arabic} \part*{Welcome to PSTricks} PSTricks is a collection of PostScript-based \TeX{} macros that is compatible with most \TeX\ macro packages, including Plain \TeX, \LaTeX, \AmS\TeX, and \AmS-\LaTeX. PSTricks gives you color, graphics, rotation, trees and overlays. PSTricks puts the icing (PostScript) on your cake (\TeX)! To install PSTricks, follow the instructions in the file "read-me.pst" that comes with the PSTricks package. Even if PSTricks has already been installed for you, give "read-me.pst" a look over. This {\em User's Guide} verges on being a reference manual, meaning that it is not designed to be read linearly. Here is a recommended strategy: Finish reading this brief overview of the features in PSTricks. Then thumb through the entire {\em User's Guide} to get your own overview. Return to Part \ref{P-essentials} (Essentials) and read it carefully. Refer to the remaining sections as the need arises. When you cannot figure out how to do something or when trouble arises, check out the appendices (Help). You just might be lucky enough to find a solution. There is also a \LaTeX\ file "samples.pst" of samples that is distributed with PSTricks. Look to this file for further inspiration. This documentation is written with \LaTeX. Some examples use \LaTeX\ specific constructs and some don't. However, there is nothing \LaTeX\ specific about any of the macros, nor is there anything that does not work with \LaTeX. This package has been tested with Plain \TeX, \LaTeX, \AmS-\LaTeX and \AmS\TeX, and should work with other \TeX\ macro packages as well. \File{pstricks} The main macro file is "pstricks.tex"/"pstricks.sty". Each of the PSTricks macro files comes with a ".tex" extension and a ".sty" extension; these are equivalent, but the ".sty" extension means that you can include the file name as a \LaTeX\ document style option. There are numerous supplementary macro files. A file, like the one above and the left, is used in this {\em User's Guide} to remind you that you must input a file before using the macros it contains. For most PSTricks macros, even if you misuse them, you will not get PostScript errors in the output. However, it is recommended that you resolve any \TeX\ errors before attempting to print your document. A few PSTricks macros pass on PostScript errors without warning. Use these with care, especially if you are using a networked printer, because PostScript errors can cause a printer to bomb. Such macros are pointed out in strong terms, using a warning like this one: \begin{Warning} Use macros that do not check for PostScript errors with care. PostScript errors can cause a printer to bomb! \end{Warning} Keep in mind the following typographical conventions in this User's Guide. \begin{itemize} \item All literal input characters, i.e., those that should appear verbatim in your input file, appear in upright "Helvetica" and "Helvetica-Bold" fonts. \item Meta arguments, for which you are supposed to substitute a value (e.g., ) appear in slanted and {\UsageFont\MetaFont Helvetica-BoldOblique} fonts. \item The main entry for a macro or parameter that states its syntax appears in a large bold font, {\em except for the optional arguments, which are in medium weight}. This is how you can recognize the optional arguments. \item References to PSTricks commands and parameters within paragraphs are set in {\UsageFont Helvetica-Bold}. \end{itemize} \part{The Essentials\label{P-essentials}} \section{Arguments and delimiters} Here is some nitty-gritty about arguments and delimiters that is really important to know. The PSTricks macros use the following delimiters: \begin{center} \begin{tabular}{rl} Curly braces & "{}" \\ Brackets (only for optional arguments) & "[]" \\ Parentheses and commas for coordinates & \c{} \\ "=" and "," for parameters & "=," \ldots\\ \end{tabular} \end{center} Spaces and commas are also used as delimiters within arguments, but in this case the argument is expanded before looking for the delimiters. Always use a period rather than a comma to denote the decimal point, so that PSTricks doesn't mistake the comma for a delimiter. The easiest mistake to make with the PSTricks macros is to mess up the delimiters. This may generate complaints from \TeX{} or PSTricks about bad arguments, or other unilluminating errors such as the following: \begin{description}\itemsep=0pt\parsep=0pt \item[] "! Use of \get@coor doesn't match its definition." \item[] "! Paragraph ended before \pst@addcoor was complete." \item[] "! Forbidden control sequence found while scanning use of \check@arrow." \item[] "! File ended while scanning use of \lput." \end{description} Delimiters are generally the first thing to check when you get errors with a PSTricks macro. Since PSTricks macros can have many arguments, it is useful to know that you can leave a space or new line between any arguments, except between arguments enclosed in curly braces. If you need to insert a new line between arguments enclosed in curly braces, put a comment character "%" at the end of the line. As a general rule, the first non-space character after a PSTricks macro should not be a "[" or "(". Otherwise, PSTricks might think that the "[" or "(" is actually part of the macro. You can always get around this by inserting a pair "{}" of braces somewhere between the macro and the "[" or "(". \Section{Color\label{S-color}} The grayscales \begin{quote} "black", "darkgray", "gray", "lightgray", and "white", \end{quote} and the colors \begin{quote} "red", "green", "blue", "cyan", "magenta", and "yellow" \end{quote} are predefined in PSTricks. This means that these names can be used with the graphics objects that are described in later sections. This also means that the command \n\gray\ (or \n\red, etc.) can be used much like "\rm" or "\tt", as in \begin{Ex} \gray\Large"{\gray This stuff should be gray.}" \end{Ex} The commands \n\gray, \n\red, etc. can be nested like the font commands as well. There are a few important ways in which the color commands differ from the font commands: \begin{enumerate} \item The color commands can be used in and out of math mode (there are no restrictions, other than proper \TeX\ grouping). \item The color commands affect whatever is in their scope (e.g., lines), not simply characters. \item The scope of the color commands does not extend across pages. \item The color commands are not as robust as font commands when used inside box macros. See page \pageref{colorboxproblems} for details. You can avoid most problems by explicitly grouping color commands (e.g., enclosing the scope in braces "{}") whenever these are in the argument of another command.\footnote{However, this is not necessary with the PSTricks LR-box commands, expect when \n\psverbboxtrue\ is in effect. See Section \ref{S-boxes}.} \end{enumerate} You can define or redefine additional colors and grayscales with the following commands. In each case, is a number between 0 and 1. Spaces are used as delimiters---don't add any extraneous spaces in the arguments. \begin{description} \mitem \newgray{color}{num} is the gray scale specification, to be set by PostScript's "setgray" operator. 0 is black and 1 is white. For example: \begin{LVerb} \newgray{darkgray}{.25} \end{LVerb} \mitem \newrgbcolor{color}{num1 num2 num3} is a {\em red-green-blue} specification, to be set by PostScript's "setrgbcolor" operator. For example, \begin{LVerb} \newrgbcolor{green}{0 1 0} \end{LVerb} \mitem \newhsbcolor{color}{num1 num2 num3} is an {\em hue-saturation-brightness} specification, to be set by PostScript's "sethsbcolor" operator. For example, \begin{LVerb} \newhsbcolor{mycolor}{.3 .7 .9} \end{LVerb} \mitem \newcmykcolor{color}{num1 num2 num3 num4} is a {\em cyan-magenta-yellow-black} specification, to be set by PostScript's "newcmykcolor" operator. For example, \begin{LVerb} \newcmykcolor{hercolor}{.5 1 0 .5} \end{LVerb} \end{description} For defining new colors, the {\em rbg} model is a sure thing. {\em hsb} is not recommended. {\em cmyk} is not supported by all Level 1 implementations of PostScript, although it is best for color printing. For more information on color models and color specifications, consult the {\em PostScript Language Reference Manual}, 2nd Edition (Red Book), and a color guide. \begin{drivers} The command \n\pstVerb\ must be defined.\end{drivers} \Section{Setting graphics parameters\label{S-par}} PSTricks uses a key-value system of graphics parameters to customize the macros that generate graphics (e.g., lines and circles), or graphics combined with text (e.g., framed boxes). You can change the default values of parameters with the command \n\psset, as in \begin{LVerb} \psset{fillcolor=yellow} \psset{linecolor=blue,framearc=.3,dash=3pt 6pt} \end{LVerb} The general syntax is: \Mac \psset{par1=value1`,par2=value2,\ldots'} As illustrated in the examples above, spaces are used as delimiters for some of the values. Additional spaces are allowed only following the comma that separates "=" pairs (which is thus a good place to start a new line if there are many parameter changes). E.g., the first example is acceptable, but the second is not: \begin{LVerb} \psset{fillcolor=yellow, linecolor=blue} \psset{fillcolor= yellow,linecolor =blue } \end{LVerb} The parameters are described throughout this {\em User's Guide}, as they are needed. Nearly every macro that makes use of graphics parameters allows you to include changes as an optional first argument, enclosed in square brackets. For example, \begin{LVerb} \psline[linecolor=green,linestyle=dotted](8,7) \end{LVerb} draws a dotted, green line. It is roughly equivalent to \begin{LVerb} {\psset{linecolor=green,linestyle=dotted}\psline(8,7)} \end{LVerb} For many parameters, PSTricks processes the value and stores it in a peculiar form, ready for PostScript consumption. For others, PSTricks stores the value in a form that you would expect. In the latter case, this {\em User's Guide\/} will mention the name of the command where the value is stored. This is so that you can use the value to set other parameters. E.g., \begin{LVerb} \psset{linecolor=\psfillcolor,doublesep=.5\pslinewidth} \end{LVerb} However, even for these parameters, PSTricks may do some processing and error-checking, and you should always set them using \n\psset\ or as optional parameter changes, rather than redefining the command where the value is stored. \Section{Dimensions, coordinates and angles\label{S-coor}} Whenever an argument of a PSTricks macro is a dimension, the unit is optional. The default unit is set by the \begin{Ex} \Par{unit=dim} (1cm) \end{Ex} parameter. For example, with the default value of "1cm", the following are equivalent: \begin{LVerb} \psset{linewidth=.5cm} \psset{linewidth=.5} \end{LVerb} By never explicitly giving units, you can scale graphics by changing the value of \p{unit}. You can use the default coordinate when setting non-PSTricks dimensions as well, using the commands \begin{Ex} \object \pssetlength{cmd}{dim} \object \psaddtolength{cmd}{dim} \end{Ex} where is a dimension register (in \LaTeX\ parlance, a ``length''), and is a length with optional unit. These are analogous to \LaTeX's "\setlength" and "\addtolength". Coordinate pairs have the form \c{}. The origin of the coordinate system is at \TeX's currentpoint. The command \n\SpecialCoor\ lets you use polar coordinates, in the form "(;)", where is the radius (a dimension) and is the angle (see below). You can still use Cartesian coordinates. For a complete description of \n\SpecialCoor, see Section \ref{S-SpecialCoor}. The \p{unit} parameter actually sets the following three parameters: \begin{Ex} \Par{xunit=dim} (1cm) \Par{yunit=dim} (1cm) \Par{runit=dim} (1cm) \end{Ex} These are the default units for x-coordinates, y-coordinates, and all other coordinates, respectively. By setting these independently, you can scale the x and y dimensions in Cartesian coordinate unevenly. After changing \p{yunit} to "1pt", the two \n\psline's below are equivalent: \begin{LVerb} \psset{yunit=1pt} \psline(0cm,20pt)(5cm,80pt) \psline(0,20)(5,80) \end{LVerb} The values of the \p{runit}, \p{xunit} and \p{yunit} parameters are stored in the dimension registers \n\psunit (also \n\psrunit), \n\psxunit\ and \n\psyunit. Angles, in polar coordinates and other arguments, should be a number giving the angle in degrees, by default. You can also change the units used for angles with the command \Mac \degrees`[num]' should be the number of units in a circle. For example, you might use \begin{LVerb} \degrees[100] \end{LVerb} to make a pie chart when you know the shares in percentages. \n\degrees\ without the argument is the same as \begin{LVerb} \degrees[360] \end{LVerb} The command \Mac \radians is short for \begin{Ex} "\degrees[6.28319]" \end{Ex} \n\SpecialCoor\ lets you specify angles in other ways as well. \Section{Basic graphics parameters} The width and color of lines is set by the parameters: \begin{Ex} \Par{linewidth=dim} \Par{linecolor=color} \end{Ex} The \p{linewidth} is stored in the dimension register \n\pslinewidth, and the \p{linecolor} is stored in the command \n\pslinecolor. The regions delimited by open and closed curves can be filled, as determined by the parameters: \begin{Ex} \p{fillstyle=