PST News10
PST News10
News - 2010
new macros and bugfixes for the basic package pstricks
2010
Package author(s):
Herbert Voß
Contents 2
Contents
I. pstricks – package 3
1. General 3
2. pstricks.sty 3
2.1. New optional argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
5. Numeric functions 16
6. Numeric functions 16
6.1. \pstFPadd, \pstFPsub, \pstFPmul, and \pstFPdiv . . . . . . . . . . . . . . . . . . . . 16
6.2. \pstFPMul and \pstFPDiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
9. pst-node.tex 24
10. pst-plot.tex 24
References 25
3
Part I.
pstricks – package
1. General
There exists a new document class pst-doc for writing PSTricks documentations, like this news
document. It depends on the KOMA-Script document class scrartcl. pst-doc defines a lot of
special macros to create a good index. Take one of the already existing package documentation and
look into the source file. Then it will be easy to understand, how all these macros have to be used.
When running pdflatex the title page is created with boxes and inserted with the macro \AddToShipoutPic
from the package eso-pic. It inserts the background title page image pst-doc-pdf to use directly
pdflatex. When running latex the title page is created with PSTricks macros.This allows to use
the Perl script pst2pdf or the package pst-pdf or auto-pst-pdf or any other program/package
which supports PostScript code in the document.
2. pstricks.sty
With the setting of the optional argument pdf the package auto-pst-pdf will be loaded by PSTricks.
This requires that you run pdflatex as
pdflatex --shell-escape <file> % TEX Live users
pdflatex --enable-write18 <file>% MiKTEX users
The package exports the pspicture environments into single images which are collected in a cre-
ated file <file>-pics.pdf and inserted automatically in the last pdflatex run.
3.1. Coordinates
With the setting \SpecialCoor the package allows different kinds of coordinates. The macro \uput
can now be used in a different way. The default behaviour for nodes with a relative point puts its
argument without rotation on the line AB . When using the prefix > before the node or the x-value
for cartesian coordinates, the behaviour is different. Now the angle between the line OB and the
horizontal line is taken into account and the placement of the argument of \uput is different to the
default behaviour.
5 \begin{pspicture}[showgrid](-0.25,-0.25)(6,5)
\pnodes(0,3){A}(3,1){B}
4 \psline[showpoints](A)(B)
\uput[-90](A){A}\uput[-90](B){B}
bar \psline[linestyle=dashed](A)(3,4)
3b
\psline[linestyle=dashed](A)(3,5)
A \psline[linestyle=dashed](A)(3,3)
2 foo
\psline[linestyle=dashed](6,2)
\psline[linestyle=dashed](B)(6,1)
1 b
\psarc{->}(0,3){2.5}{0}{(3,1)}
B \psarc{->}(3,1){2.5}{0}{(3,1)}
0 \uput*{1cm}[(B)](A){foo} \uput*{1cm}[(B)](>A){bar}
0 1 2 3 4 5 6 \end{pspicture}
3. pstricks.tex (0.2– 1999/07/01) 4
The new arguments are only valid for the macros \psellipse, \pscircle, \psarc. \psellipticarc,
\pscurve, \psplot, and \psparametricplot.
\psset{linewidth=2mm,linestyle=dashed}
\begin{pspicture}(4,-4)
\psline[linecolor=blue,dashcolor=red,linearc=0.5](0,0)(4,0)(4,-4)
\psline[linecolor=blue,dashcolor=cyan,linearc=0.5](0,0)(0,-4)(4,-4)
\end{pspicture}\quad
\begin{pspicture}(4,4)
\psframe[linecolor=blue,dashcolor=green,framearc=0.5](0,0)(4,4)
\end{pspicture}
\quad \psset{linecap=2,dash=5mm 5mm }
\begin{pspicture}(4,-4)
\psline[linecolor=black,dashcolor=black!40,linecap=0](0,0)(4,-4)
\psline[linecolor=blue,dashcolor=red,linearc=0.5](0,0)(4,0)(4,-4)
\psline[linecolor=blue,dashcolor=cyan,linearc=0.5](0,0)(0,-4)(4,-4)
\end{pspicture}
\psset{endLW=15pt}
\begin{pspicture}(-3.5,-2.5)(3.5,2.5)
\psellipse[linejoin=2,variableLW,startLW=1pt,
linecolor=green!40](0,0)(3,1)
\end{pspicture}
3. pstricks.tex (0.2– 1999/07/01) 5
\psset{endLW=15pt}
\begin{pspicture}(-2.5,-2.5)(2.5,2.5)
\pscircle[variableLW,startLW=1pt,
linecolor=blue!40]{2}
\end{pspicture}
\psset{endLW=15pt}
\begin{pspicture}(-2.5,-2.5)(2.5,2.5)
\psarc[variableLW,startLW=1pt,
linecolor=red!40](0,0){2}{10}{300}
\end{pspicture}
\psset{endLW=15pt}
\begin{pspicture}(-3.5,-2.5)(3.5,2.5)
\psellipticarc[variableLW,startLW=1pt,
linecolor=black!40](0,0)(3,1){90}{30}
\end{pspicture}
\begin{pspicture}(-2.5,-2.5)(2.5,2.5)
\pscurve[variableLW,startLW=1pt,endLW=20pt,
variableColor](-1,0.5)(-2,1)(2,2)(-1,-2)(2,-2)
\end{pspicture}
3. pstricks.tex (0.2– 1999/07/01) 6
\begin{pspicture}(-2.5,-2.5)(2.5,2.5)
\pscurve[variableLW,startLW=1pt,endLW=20pt]%
(-1,0.5)(-2,1)(2,2)(-1,-2)(2,-2)
\end{pspicture}
\begin{pspicture}(-5,-3)(5,3)
\psplot[variableLW,startLW=1pt,endLW=20pt,
linecolor=magenta!60,variableColor,
algebraic,plotpoints=3000,startWL=500,
endWL=700]{-5}{5}{2*sin(2*x)+cos(x)}
\end{pspicture}
3. pstricks.tex (0.2– 1999/07/01) 7
\psset{endLW=24pt}
\begin{pspicture}(-5,-5)(5,5)
\psparametricplot[variableLW,startLW=1pt,
endLW=60pt,linecolor=red,variableColor,
algebraic,plotpoints=3000,plotstyle=curve,
opacity=0.4,strokeopacity=0.4,
endWL=600]{-5}{5}{t*sin(t) | t*cos(t)}
\end{pspicture}
3. pstricks.tex (0.2– 1999/07/01) 8
To rotate an ellipse the already existing keyword rot can be used. This is easier than using the
\rput command and its optional argument for rotating.
\psset{unit=0.25}
\begin{pspicture}(-1,5)(20,18)
\psclip{\psellipse[linecolor=red,
rot=-12.606](5.821,10.04)(6.633,5.103)}
\psellipse[linecolor=blue,fillstyle=vlines,
rot=39.29](13.141,11.721)(6.8,5.4)
\endpsclip
\psellipse[linecolor=blue,rot=39.29](13.1,11.7)(6.8,5.4)
\end{pspicture}
\begin{pspicture}(-1,5)(20,18)
\psellipse[linecolor=blue,rot=-39.29,
fillstyle=vlines](13.1,11.7)(6.8,5.4)
\psclip{\psellipse[linecolor=red,rot=12.6,
fillstyle=vlines](5.8,10)(6.6,5.1)}
\psellipse*[linecolor=white,rot=-39.29](13.1,11.7)(6.8,5.4)
\endpsclip
\psellipse[linecolor=blue,rot=-39.29](13.1,11.7)(6.8,5.4)
\psellipse[linecolor=red,rot=12.6](5.8,10)(6.6,5.1)
\end{pspicture}
In a circle the angle is proportional to the bow: b = rα. In an elliptic arc this is no more the case,
which is the reason why angles are internally corrected by PSTricks, to get the same arc lengthts
for different radii:
\psset{unit=0.5cm}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)%
\psset{linewidth=0.4pt,linejoin=1}
\psline(5,0)(0,0)(5,-5)
\psellipticarc(0,0)(3,3){0}{315}
\end{pspicture}%
3. pstricks.tex (0.2– 1999/07/01) 9
\psset{unit=0.5cm}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)%
\psset{linewidth=0.4pt,linejoin=1}
\psline(5,0)(0,0)(5,-5)
\psellipticarc(0,0)(1,3){0}{315}%
\psset{linecolor=red}
\psellipticarc(0,0)(3,1){22}{222}%
\psline(3;22)\psline(3;222)
\end{pspicture}%
\psset{unit=0.5cm}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)%
\psset{linewidth=0.4pt,linejoin=1}
\psline(5,0)(0,0)(5,-5)
\psellipticarc*(0,0)(1,3){0}{315}%
\psset{linecolor=red}
\psellipticarc*(0,0)(3,1){22}{222}%
\psline(3;22)\psline(3;222)
\end{pspicture}%
If you do not want the angle correction, then use the keyword setting correctAngle=false:
\psset{unit=0.5cm}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)%
\psset{linewidth=0.4pt,linejoin=1,
correctAngle=false}
\psline(5,0)(0,0)(5,-5)
\psellipticarc(0,0)(1,3){0}{315}%
\psset{linecolor=red}
\psellipticarc(0,0)(3,1){22}{222}%
\psline(3;22)\psline(3;222)
\end{pspicture}%
\psset{unit=0.5cm}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)%
\psset{linewidth=0.4pt,linejoin=1,
correctAngle=false}
\psline(5,0)(0,0)(5,-5)
\psellipticarc*(0,0)(1,3){0}{315}%
\psset{linecolor=red}
\psellipticarc*(0,0)(3,1){22}{222}%
\psline(3;22)\psline(3;222)
\end{pspicture}%
3. pstricks.tex (0.2– 1999/07/01) 10
The option algebraic moved from the other packages into the main package pstricks to get rid of
the dependencies.
By default the function in \psplot has to be described in Reversed Polish Notation. The option
algebraic allows you to do this in the common algebraic notation. E.g.:
RPN algebraic
x ln ln(x)
x cos 2.71 x neg 10 div exp mul cos(x)*2.71^(-x/10)
1 x div cos 4 mul 4*cos(1/x)
t cos t sin cos(t)|sin(t)
Setting the option algebraic, allow the user to describe all expression to be written in the clas-
sical algebraic notation (infix notation). The four arithmetic operations are obviously defined +-*/,
and also the exponential operator ^. The natural priorities are used : 3 + 4 × 55 = 3 + (4 × (55 )), and
by default the computation is done from left to right. The following functions are defined :
sin, cos, tan, acos, asin in radians
log, ln
ceiling, floor, truncate, round
sqrt square root
abs absolute value
fact for the factorial
Sum for building sums
IfTE for an easy case structure
These options can be used with all plot macros.
Using the option algebraic implies that all angles have to be in radians!
For the \parametricplot the two parts must be divided by the | character:
\begin{pspicture}(-0.5,-0.5)(0.5,0.5)
\parametricplot[algebraic,linecolor=red]{-3.14}{3.14}{cos(t)|sin(t)}
\end{pspicture}
b b b b b b
b b b b
b b
b
b
b 0.5 b
b
b
b
b
b
b b
b b
b
b b
b b b
b
b
b b b
b b
b b
b b b
b b
b
b b
b b
b
b b
b
b b b
b
b
b b b
b
x
b b
−3π −2π b
b
b
−π b
b
π 2π b b
b
3π
b b
b b
b b
b
b b b
b b b
b b b
b
b b
b
b
b
−0.5
b
b b
b b
b
−1.0
\psset{lly=-0.5cm}
\psgraph[trigLabels,dx=\psPi,dy=0.5,Dy=0.5]{->}(0,0)(-10,-1)(10,1){\linewidth}{6cm}
\psset{algebraic,plotpoints=1000}
4. New linestyle symbol 11
\psplot[linecolor=yellow,linewidth=2pt]{-10}{10}{0.75*sin(x)*cos(x/2)}
\psplot[linecolor=red,showpoints=true,plotpoints=101]{-10}{10}{0.75*sin(x)*cos(x/2)}
\endpsgraph
y
8 b
b
b
7 b b
b
b b
b
6 b
b
b
b b b
b
b b
b b b
b b
5 b b
b
b
b
b b
b
b
b b b b b b b
b
b b
4 b b
b b b
b b
3 b b
2
1
0 x
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
\psset{lly=-0.5cm}
\psgraph(0,-5)(18,3){0.9\linewidth}{5cm}
\psset{algebraic,plotpoints=501}
\psplot[linecolor=yellow, linewidth=4\pslinewidth]{0.01}{18}{ln(x)}
\psplot[linecolor=red]{0.01}{18}{ln(x)}
\psplot[linecolor=yellow,linewidth=4\pslinewidth]{0}{18}{3*cos(x)*2.71^(-x/10)}
\psplot[linecolor=blue,showpoints=true,plotpoints=51]{0}{18}{3*cos(x)*2.71^(-x/10)}
\endpsgraph
Instead of drawing a continous line or curve for a series of coordinates, one can now out a symbol
in a given size, direction, and step. This works only for the line style symbol. It takes the symbol
defined by the optional argument symbol, which can have a single character or a octal number of
three digits. The font is specified by the key symbolFont, which can take as argument one of the
valid PostScriptfonts or the internal PSTricksDotFont. If the symbol is given by a single character
then the equivilant character in the given font is used. The difference between two symbols is set
by symbolStep and the symbol rotation by rotateSymbol. For the first symbol there is an additional
keyword startAngle. The default values for these new optional keywords are:
\psset[pst-base]{symbolStep=20pt}
\psset[pst-base]{symbolWidth=10pt}
\psset[pst-base]{symbolFont=Dingbats}
\psset[pst-base]{rotateSymbol=false}
\psset[pst-base]{startAngle=0}
4. New linestyle symbol 12
➢
➢➢➢➢➢➢➢➢➢➢➢
➢
➢
✡ ✡ ✡ ✡ ✡ ✡ ❁u
✴
➢
u
✴
➢
u ❁
✡u
➢
◆ ◆ ◆ ◆ ◆ ◆ ✴❁
➢
u ◆ ✴ ✡
❁◆
➢
u u u u u u u u ✴ ◆
➢
❁ ✡
➢
✴
➢
✴ ✴ ✴ ✴ ✴ ✴ ✴ ✴ ❁
✡
➢
❁
➢
➢
❁ ❁ ❁ ❁ ❁ ❁ ❁ ❁
\pspicture(-1,-1)(8,6)
\psline[linestyle=symbol](0,0)(5,0)(8,4)
\psline[linestyle=symbol,symbol=T](0,1)(5,1)(8,4)
\psline[linestyle=symbol,symbol=u,symbolFont=PSTricksDotFont](0,2)(5,2)(8,4)
\psline[linestyle=symbol,symbol=u,symbolStep=25pt,linecolor=red](0,3)(5,3)(8,2)
\psline[linestyle=symbol,symbol=A,symbolStep=25pt,
symbolWidth=20pt,linecolor=blue](0,4)(5,4)(8,1)
\psline[linestyle=symbol,symbol=342,rotateSymbol=true,symbolStep=12pt](0,5)(5,5)(8,0)
\endpspicture
➢ ➢ ➢ ➢ ➢ ➢➢
➢➢ ➢➢
➢
✡ ✡ ✡ ✡ ✡ ✡ ✡
➢
➢
u
➢
❁ ❁
➢
u
◆ ◆ ◆ ✡u
➢
◆ ◆ ◆ ❁❁
◆
✡
➢
u ◆❁
u ❁◆
➢
u u u u
u u ❁
u ✡
➢➢
❁
❁
❁ ❁ ❁ ✡
➢
❁ ❁ ❁ ❁ ❁
❁
➢➢
❁
❁ ❁
❁ ❁ ❁
❁ ❁ ❁
\pspicture(-1,-1)(8,6)
\pscurve[linestyle=symbol](0,0)(5,0)(8,4)
\pscurve[linestyle=symbol](0,1)(5,1)(8,4)
\pscurve[linestyle=symbol,symbol=u,symbolFont=PSTricksDotFont](0,2)(5,2)(8,4)
\pscurve[linestyle=symbol,symbol=u,symbolStep=25pt,linecolor=red](0,3)(5,3)(8,2)
\pscurve[linestyle=symbol,symbol=A,symbolStep=25pt,
symbolWidth=20pt,linecolor=blue](0,4)(5,4)(8,1)
\pscurve[linestyle=symbol,symbol=342,rotateSymbol=true,
startAngle=190,symbolStep=12pt](0,5)(5,5)(8,0)
\endpspicture
4. New linestyle symbol 13
➢ ➢ ➢➢➢
➢ ➢ ➢
u
➢
➢
u u u
✡ ✡ u ✡u ✡u ❁ ❁❁ ❁❁ ❁❁ ❁❁ u ❁❁u
➢ ➢ ➢➢
➢
➢
➢
✡ ❁ ❁✡
➢
u ❁ ❁ ✡ ❁
❁u
➢
◆ u ◆ ❁◆ ❁ ✡
➢
➢
✡u ❁ ❁ ◆ ◆ ◆ ◆ ✡ u u ❁❁
➢
➢
◆ ❁
➢
◆
u ✡
u ✡❁◆❁
➢
❁
➢
u
➢
❁◆ ❁ u
➢
u ❁
✡ ❁ ✡
➢
u ➢ u ◆
➢➢ ➢➢
◆ u u ❁
❁❁ u u ➢✡
◆➢ ❁ ❁ ◆
❁ ➢✡
◆ ◆ ❁ ◆ ❁ ◆ ❁◆ ✡
❁ ➢ ❁ ✡
❁
❁ ❁ ❁ ❁ ➢ ➢ ✡ ✡
➢ ❁➢❁
❁
✡ ✡➢
❁ ➢➢ ➢ ➢
❁ ❁ ➢➢
❁ ❁ ❁
\pspicture(-1,-1)(8,6)
\psccurve[linestyle=symbol](0,0)(5,0)(8,4)
\psccurve[linestyle=symbol](0,1)(5,1)(8,4)
\psccurve[linestyle=symbol,symbol=u,symbolFont=PSTricksDotFont](0,2)(5,2)(8,4)
\psccurve[linestyle=symbol,symbol=u,symbolStep=25pt,linecolor=red](0,3)(5,3)(8,2)
\psccurve[linestyle=symbol,symbol=A,symbolStep=25pt,
symbolWidth=20pt,linecolor=blue](0,4)(5,4)(8,1)
\psccurve[linestyle=symbol,symbol=342,rotateSymbol=true,
startAngle=190,symbolStep=12pt](0,5)(5,5)(8,0)
\endpspicture
✂
✂
✂ ✂✂
✂ ✂ ✂ ✂✂
✂
✂
✂✂
✂✂
\pspicture(-1,-1)(5,4)
\pscurve[rotateSymbol=true,linestyle=symbol,
rot=180,startAngle=100,symbol=",
symbolWidth=20pt](0,0)(1,4)(3,0)(5,2)
\endpspicture
4. New linestyle symbol 14
u
u
u
u
u
u
u u
u u
u u
u u
\pspicture(-1,-1)(6,4)
\psbezier[rotateSymbol=true,linestyle=symbol,symbol=u,
symbolFont=PSTricksDotFont,rot=-90,startAngle=0](0,0)(0,4)(6,4)(6,0)
\endpspicture
u
u
u
u
u
u
u
u
u
u
u
u
u
\psset{unit=0.5cm}
\pspicture(-1,-4)(6,4)
\pscbezier[rotateSymbol=true,linestyle=symbol,symbol=u,
symbolFont=PSTricksDotFont](0,4)(4,4)(4,-4)(0,-4)
\pscbezier[linestyle=dashed](0,4)(4,4)(4,-4)(0,-4)
\endpspicture
u u u u
u u
u
u
u
u
u
u
u
\pspicture(-1,-1)(6,4)
\psbezier[rotateSymbol=true,linestyle=symbol,symbol=u,
symbolFont=PSTricksDotFont](0,0)(0,4)(6,4)(6,0)
\endpspicture
4. New linestyle symbol 15
u u u u u u u u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
\pspicture(-1,-1)(6,4)
\pspolygon[rotateSymbol=true,linestyle=symbol,symbol=u,
symbolFont=PSTricksDotFont](0,0)(0,4)(6,4)(6,0)(1,3)
\endpspicture
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u u
u
u
u
u u
u
u u u u
u u
u u
u u
u u
u
u
u u
u
u
u u u
u
u u u
u
u
u u
u
u
u u
u
u
u
u u
u
uu
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
u
\pspicture(-3,-1)(6,6)
\psccurve[linestyle=symbol,symbol=u, rot=-90,rotateSymbol,
symbolFont=PSTricksDotFont, symbolWidth=5pt, symbolStep=10pt
](-3,-1)(0,0)(0,4)(6,4)(6,0)(0,4)(-1,5)
\endpspicture
5. Numeric functions 16
k k k k
k k
k k
k k
k k
k k
k k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k
k k
k k
k k k
\pspicture(-1,-1)(6,6)
\pscurve[linestyle=dashed,linecolor=black!30](0,0)(0,4)(6,4)(6,0)(0,4)
\pscurve[rotateSymbol=true,linestyle=symbol,symbol=k,
symbolFont=PSTricksDotFont, symbolWidth=5pt, symbolStep=10pt,linecolor=blue
](0,0)(0,4)(6,4)(6,0)(0,4)
\endpspicture
5. Numeric functions
All macros have a @ in their name, because they are only for internal use, but it is no problem to
use them like other macros. One can define another name without a @:
\makeatletter
\let\pstdivide\pst@divide
\makeatother
6. Numeric functions
By default PSTricks loads the file pst-fp which is derived from the fp package. It supports the
following macros:
The zeros can be stripped with the macro \pstFPstripZeros. Expect always rounding errors, TEX
was not made for calculations . . . The value is converted into a length and then reconverted to a
number by stripping the unit. Which also strips the zeros.
\pstFPmul\Result{-3.405}{0.02345}
\pstFPstripZeros{\Result}{\Result}\Result\quad
\pstFPdiv\Result{-3.405}{0.02345}
-0.07985 -145.20256 \pstFPstripZeros{\Result}{\Result}\Result\\
\pstFPmul\Result{0.02345}{-3.405}
-0.07985 -0.00688
\pstFPstripZeros{\Result}{\Result}\Result\quad
\pstFPdiv\Result{0.02345}{-3.405}
\pstFPstripZeros{\Result}{\Result}\Result
\makeatletter
\pstFPMul\Result{-34.05}{0.02345} \Result\quad
\pstFPDiv\Result{-3.405}{0.02345} \Result\\
-0 -145 \pstFPMul\Result{23.45}{-3.405} \Result\quad
-79 -6 \pstFPDiv\Result{0.2345}{-0.03405} \Result\\
7726 7 \pstFPMul\Result{234.123}{33} \Result\quad
\pstFPDiv\Result{234.123}{33} \Result
\makeatother
7.1. pstricks.pro
It contains now most of the stuff from pstricks-add and the new routines for plotting lines/curves
with symbols.
7. The PostScript header files 18
7.2. pst-algparser.pro
\Sum(<index name>,<start>,<step>,<end>,<function> )
X
+∞
(−1)n x2n
Let’s plot the first development of cosine with polynomials: .
n=0
n!
−7 −6 −5 −4 −3 −2 −1 1 2 3 4 5 6 7
−1
7.3. The variable step algorithm together with the PostScript function IfTE
Nesting of several IfTE is possible and seen in the following examples. A classic example is a
piece-wise linear function.
y
5
4
3
2
1
x
−7 −6 −5 −4 −3 −2 −1 1 2 3 4 5 6 7
−1
−2
When you program a piece-wise defined function you must take care that a plotting point must
be put at each point where the description changes. Use showpoints=true to see what’s going on
when there is a problem. You are on the safe side when you choose a big number for plotpoints.
7. The PostScript header files 20
7
6
5
4
3
2
1
x
−8 −7 −6 −5 −4 −3 −2 −1 1 2 3 4 5 6 7
−1
−2
−3
−4
−5
−6
−7
−8
\psset{unit=0.75}
\begin{pspicture}(-8,-8)(8,8)
\psaxes{->}(0,0)(-8,-8)(8,8)[x,-90][y,0]
\psset{plotpoints=1000,linewidth=1pt}
\psplot[algebraic=true, linecolor=yellow]{-8}{8}{rand/(2^31-1)+x}
\psplot[algebraic=true]{-8}{8}{ceiling(x)}
\psplot[algebraic=true, linecolor=red]{-8}{8}{floor(x)}
\psplot[algebraic=true, linecolor=blue]{-8}{8}{round(x)}
\psplot[algebraic=true, linecolor=green]{-8}{8}{truncate(x)}
\psplot[algebraic=true, linecolor=cyan]{-8}{8}{div(mul(4,x),7)}
\psplot[algebraic=true, linecolor=gray]{-8}{8}{abs(x)+abs(x-3)-abs(5-5*x/7)}
\psplot[algebraic=true, linecolor=gray]{-8}{8}{abs(3*cos(x)+1)}
\psplot[algebraic=true, linecolor=magenta]{-8}{8}{floor(8*cos(x))}
\end{pspicture}
7. The PostScript header files 21
1 b b b b
b b b bb b b
b b
b b bb b b
b b b b b b
b b b b
bb b b
bb b b b
bb bb b b
b b b
b b
bb b b b b
bb b
b b b b b
b b b b
b b b
b b b b b b
b b
b b b b b
b b b b b
b b
b b b
0 b b b b b b bb bb b b
b b b
b b b
b b b b
bb b
b b b
b b b b
b b
b
bb b b b b
b b
b b b b
b b b b
b b b b b
b b
b b b b b
b b b bb
b b b b
b b
b b b
b bb b
b b b b b b
-1 b b
b
b b b bb bb b
b
b b
bb b b b
b
b
b b b b b
0 1 2 b 3 b 4 5b b
6 b
7
b b
b b b b
b b b
b
b b b
b
b b
b b b
\psset{unit=2, algebraic=true, VarStep=true, showpoints=true, b
VarStepEpsilon=.001}
b
b
b
b b b
\def\getColor#1{\ifcase#1 Tan\or RedOrange\or magenta\or yellow\or green\or b
b Orange\or blue
b
\or b
b b b
b
b b
DarkOrchid\or BrickRed\or Rhodamine\or
b OliveGreen\or b
b b
Goldenrod\or Mahogany\or
b b
b
OrangeRed\or CarnationPink\or RoyalPurple\or Lavender\fi} b
b
\begin{pspicture}[showgrid=true](0,-1.2)(7,1.5) b
b
b
b b b b
b
\psclip{\psframe[linestyle=none](0,-1.1)(7,1.1)}
b
b
\multido{\in=0+1}{16}{% b
b
b b
\psplot[algebraic=true, linecolor=\getColor{\in}]{0.1}{7} b
b
b
{Derive(\in,Sum(i,0,1,7,(-1)^i*x^(2*i)/Fact(2
b
b
*i)))}} b b b b b
b
\endpsclip
b
b
\end{pspicture}
b b
b
b b b b
b b
b
b
b b
Only for the arrowtype o, oo, *, and ** it is possible to set the arrowlinewidth with the optional b b
b
b
b b
b
keyword arrowLW. When scaling an arrow by the keyword arrowscale the width of the borderline
is also scaled. With the optional argument arrowLW the line width can be set separately and is not b
b b
b b
b
b
b
b
\begin{pspicture}(4,6) b b
b b
b
\psline[arrowscale=3,arrows=*-o](0,5)(4,5)
b
b
\psline[arrowscale=3,arrows=*-o, b
b
arrowLW=0.5pt](0,3)(4,3)
b
\psline[arrowscale=3,arrows=*-o, b
b
arrowLW=0.3333\pslinewidth](0,1)(4,1) b
b b
\end{pspicture} b
b
b
b
b
b
b
b b
b
b
b
b
b
b b
b
b
b
b
b
b b
b
b
7. The PostScript header files 22
\begin{pspicture}(4,6)
\psline[arrowscale=3,arrows=**-oo](0,5)(4,5)
\psline[arrowscale=3,arrows=**-oo,
arrowLW=0.5pt](0,3)(4,3)
\psline[arrowscale=3,arrows=**-oo,
arrowLW=0.3333\pslinewidth](0,1)(4,1)
\end{pspicture}
8. \psforeach and \psForeach 23
With \psforeach the action is done inside a group and for \psForeach not. This maybe useful when
using the macro to create tabular cells, which are alread grouped itself.
5 b
\begin{pspicture}[showgrid=true](5,5)
3 b
\psforeach{\nA}{0, 1, 1.5, 3, 5}{%
\psdot[dotscale=3](\nA,\nA)}
2
\end{pspicture}
b
1 b
0b
0 1 2 3 4 5
y = 2x
2 4 6 8 10 12
4.0 16.0 64.0 256.0 1024.0 4096.0
%\usepackage{pst-func}
\makeatletter
\newcommand*\InitToks{\toks@={}}
\newcommand\AddToks[1]{\toks@=\expandafter{\the\toks@ #1}}
\newcommand*\PrintToks{\the\toks@}
\newcommand*{\makeTable}[4][5mm]{%
\begingroup
\InitToks%
\AddToks{\begin{tabular}{|*{#2}{>{\RaggedLeft}p{#1}|}@{}l@{}}\cline{1-#2}}
\psForeach{\iA}{#3}{\expandafter\AddToks\expandafter{\iA & }}
\AddToks{\\\cline{1-#2}}%
\psForeach{\iA}{#3}{\expandafter\AddToks\expandafter{\expandafter%
\psPrintValue\expandafter{\iA\space /x ED #4} & }}
\AddToks{\\\cline{1-#2}\end{tabular}}%
\PrintToks
\endgroup
}
\makeatother
\sffamily
\psset{decimals=2,valuewidth=7,xShift=-20}
$y=2^x$\\
\makeTable[1cm]{6}{2,4,6,8,10,12}{2 x exp}
The value List can also be given by the first two and the last value, e. g. 1,4,..,31, then
PSTrickscalculates all values with the distance given by the first two values.
24
0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
\psset{xunit=0.55cm,yunit=2cm}
\begin{pspicture}[showgrid](0,-5mm)(25,1)
\psforeach{\nA}{0, 3.14,..,25}{\psline(\nA,0)(\nA,1)}
\end{pspicture}
The internal counter for the steps is named psLoopIndex and can be used for own purposes.
5 b
3 \begin{pspicture}[showgrid=true](5,5)
\psforeach{\nA}{0, 1, 1.5, 2.25, 5}{%
2
b \psdot[dotscale=3](\the\psLoopIndex,\nA)}
\end{pspicture}
b
1 b
0b
0 1 2 3 4 5
Part II.
pst-node – package
9. pst-node.tex
The package pst-node now uses the advanced key handling from xkeyval. The reason why it moved
from the base into the contrib sections, where all packages uses xkeyval.
Part III.
pst-plot – package
10. pst-plot.tex
The package pst-plot now uses the advanced key handling from xkeyval. The reason why it moved
from the base into the contrib sections, where all packages uses xkeyval.
References 25
References
[1] Michel Goosens et al. The LATEX Graphics Companion. 2nd ed. Reading, Mass.: Addison-Wesley
Publishing Company, 2007.
[2] Laura E. Jackson and Herbert Voß. “Die Plot-Funktionen von pst-plot”. In: Die TEXnische
Komödie 2/02 (June 2002), pp. 27–34.
[3] Nikolai G. Kollock. PostScript richtig eingesetzt: vom Konzept zum praktischen Einsatz. Vater-
stetten: IWT, 1989.
[4] Herbert Voß. “Die mathematischen Funktionen von Postscript”. In: Die TEXnische Komödie
1/02 (Mar. 2002), pp. 40–47.
[5] Herbert Voß. PSTricks – Grafik für TEX und LATEX. 7th ed. Heidelberg and Berlin: DANTE –
Lehmanns Media, 2016.
[6] Herbert Voß. PSTricks – Graphics for LATEX. 1st ed. Cambridge/UK: UIT, 2011.
[7] Herbert Voß. PSTricks Support for pdf. 2002. URL: http : //PSTricks.tug.org/main.cgi?
file=pdf/pdfoutput.
[8] Herbert Voß. LATEX Quick Reference. 1st ed. Cambridge/UK: UIT, 2011.
[9] Herbert Voß. LATEX Referenz. 3rd ed. Heidelberg and Berlin: DANTE – lehmanns media, 2014.
[10] Michael Wiedmann and Peter Karp. References for TEX and Friends. 2003. URL: http://www.
miwie.org/tex-refs/.
Index
Symbole – endWL, 4
*, 21 – linecolor, 8
**, 21 – plotpoints, 19
– rot, 8
A – rotateSymbol, 11
\AddToShipoutPicture, 3 – showpoints, 19
algebraic, 10 – startAngle, 11
arrowLW, 21 – startLW, 4
arrowscale, 21 – startWL, 4
auto-pst-pdf, 3 – symbol, 11
– symbolFont, 11
C
– symbolStep, 11
Class
– variableColor, 4
– pst-doc, 3
– variableLW, 4
– scrartcl, 3
– VarStep, 19
correctAngle, 9
– VarStepEpsilon, 19
D – vlines, 8
dashcolor, 4
L
E latex, 3
enable-write18, 3 linecolor, 8
endLW, 4
M
endWL, 4
Macro
Environment
– \AddToShipoutPicture, 3
– pspicture, 3
– \makeatletter, 16
eso-pic, 3
– \makeatother, 16
F – \parametricplot, 10
File – \psarc, 4
– pst-doc-pdf, 3 – \pscircle, 4
– pst-fp, 16 – \pscurve, 4
fp, 16 – \psellipse, 4
– \psellipticarc, 4, 8
I – \psForeach, 23
IfTE, 19 – \psforeach, 23
– \pslinewidth, 4
K
– \psparametricplot, 4
Keyvalue
– \psplot, 4, 10
– PSTricksDotFont, 11
– \pstFPadd, 16
– symbol, 11
– \pstFPDiv, 17
Keyword
– \pstFPdiv, 16
– algebraic, 10
– \pstFPMul, 17
– arrowLW, 21
– \pstFPmul, 16
– arrowscale, 21
– \pstFPstripZeros, 17
– correctAngle, 9
– \pstFPsub, 16
– dashcolor, 4
– \rput, 8
– endLW, 4
26
Index 27
– \SpecialCoor, 3 pst-fp, 16
– \Sum, 18 pst-node, 24
– \uput, 3 pst-pdf, 3
\makeatletter, 16 pst-plot, 24
\makeatother, 16 pst2pdf, 3
\pstFPadd, 16
O \pstFPDiv, 17
o, 21 \pstFPdiv, 16
oo, 21 \pstFPMul, 17
\pstFPmul, 16
P
\pstFPstripZeros, 17
Package
\pstFPsub, 16
– auto-pst-pdf, 3
pstricks, 10
– eso-pic, 3
pstricks-add, 17
– fp, 16
PSTricksDotFont, 11
– pst-node, 24
– pst-pdf, 3 R
– pst-plot, 24 rot, 8
– pstricks, 10 rotateSymbol, 11
– pstricks-add, 17 \rput, 8
– xkeyval, 24
S
Package option
scrartcl, 3
– enable-write18, 3
shell-escape, 3
– pdf, 3
showpoints, 19
– shell-escape, 3
\SpecialCoor, 3
\parametricplot, 10
startAngle, 11
pdf, 3
startLW, 4
pdflatex, 3
startWL, 4
plotpoints, 19
\Sum, 18
PostScript
symbol, 11
– IfTE, 19
symbolFont, 11
Program
symbolStep, 11
– latex, 3
Syntax
– pdflatex, 3
– *, 21
– pst2pdf, 3
– **, 21
\psarc, 4
– o, 21
\pscircle, 4
– oo, 21
\pscurve, 4
\psellipse, 4 U
\psellipticarc, 4, 8 \uput, 3
\psForeach, 23
V
\psforeach, 23
variableColor, 4
\pslinewidth, 4
variableLW, 4
psLoopIndex, 24
VarStep, 19
\psparametricplot, 4
VarStepEpsilon, 19
pspicture, 3
vlines, 8
\psplot, 4, 10
pst-doc, 3 X
pst-doc-pdf, 3 xkeyval, 24