\title{\texttt{pstricks-add}\\additionals Macros for \texttt{pstricks}% %\thanks{% % This document was written with \texttt{Kile: 1.7 (Qt: 3.1.1; KDE: 3.3;} % \url{http://sourceforge.net/projects/kile/}) and the PDF output % was build with VTeX/Free (\url{http://www.micropress-inc.com/linux})} \\ \small v.\pstricksaddFV} \author{Herbert Vo\ss} \date{\today} \maketitle \begin{abstract} This version of \verb+pstricks-add+ needs \verb+pstricks.tex+ version >1.04 from June 2004, otherwise the additional macros may not work as espected. The ellipsis material and the option \verb+asolid+ (renamed to \verb+eofill+) are now part of the new \verb+pstricks.tex+ package, available at CTAN or at \url{http://perce.de/LaTeX/}. \verb+pstricks-add+ will for ever be an experimental and dynamical package, try it at your own risk. \begin{itemize} \item It is important to load \verb+pstricks-add+ as \textbf{last} PSTricks related package, otherwise a lot of the macros won't work in the expected way. \item \verb+pstricks-add+ uses the extended version of the keyval package. So be sure, that you have installed \verb+pst-xkey+ which is part of the \verb+xkeyval+-package and that all packages, that uses the old keyval interface are loaded \textbf{before} the \verb+xkeyval+.\cite{xkeyval} \item the option \verb+tickstyle+ from \verb+pst-plot+is no more supported, use \verb+ticksize+ instead. \item the option \verb+xyLabel+ is no more supported, use the macros \verb+\def\pshlabel#1{...}+ and \verb+\def\psvlabel#1{...}+ instead. \end{itemize} \end{abstract} \clearpage \tableofcontents \clearpage %-------------------------------------------------------------------------------------- \part{\texttt{pstricks}} %-------------------------------------------------------------------------------------- %-------------------------------------------------------------------------------------- \section{Numeric functions} %-------------------------------------------------------------------------------------- All macronames contain a \textat{} in their name, because they are only for internal use, but it is no problem to use it as the other macros. One can define another name without a \textat{}: \begin{verbatim} \makeatletter \let\pstdivide\pst@divide \makeatother \end{verbatim} or put the macro inside of the \verb+\makeatletter+ -- \verb+\makeatother+ sequence. %-------------------------------------------------------------------------------------- \subsection{\CMD{pst\textat{}divide}} %-------------------------------------------------------------------------------------- \verb+pstricks+ itself has its own divide macro, called \verb+\pst@divide+ which can divide two lengthes and saves the quotient as a floating point number: \begin{verbatim} \pst@divide{}{}{} \end{verbatim} \begin{LTXexample}[width=2cm] \makeatletter \pst@divide{34pt}{6pt}\quotient \quotient\\ \pst@divide{-6pt}{34pt}\quotient \quotient \makeatother \end{LTXexample} \noindent this gives the output $5.66666$. The result is not a length! %-------------------------------------------------------------------------------------- \subsection{\CMD{pst\textat{}mod}} %-------------------------------------------------------------------------------------- \verb+pstricks-add+ defines an additional numeric function for the modulus: \begin{verbatim} \pst@mod{}{}{} \end{verbatim} \begin{LTXexample}[width=2cm] \makeatletter \pst@mod{34}{6}\modulo \modulo\\ \pst@mod{25}{-6}\modulo \modulo \makeatother \end{LTXexample} \noindent this gives the output $4$. Using this internal numeric functions in documents requires a setting inside the \verb+makeatletter+ and \verb+makeatother+ environment. It makes some sense to define a new macroname in the preamble to use it throughou, e.g. \verb+\let\modulo\pst@mod+. %-------------------------------------------------------------------------------------- \subsection{\CMD{pst\textat{}max}} %-------------------------------------------------------------------------------------- \begin{verbatim} \pst@max{}{}{} \end{verbatim} \begin{LTXexample}[width=2cm] \newcount\maxNo \makeatletter \pst@max{-34}{-6}\maxNo \the\maxNo\\ \pst@max{0}{11}\maxNo \the\maxNo \makeatother \end{LTXexample} %-------------------------------------------------------------------------------------- \subsection{\CMD{pst\textat{}maxdim}} %-------------------------------------------------------------------------------------- \begin{verbatim} \pst@maxdim{}{}{} \end{verbatim} \begin{LTXexample}[width=2cm] \newdimen\maxDim \makeatletter \pst@maxdim{34cm}{1234pt}\maxDim \the\maxDim\\ \pst@maxdim{34cm}{123pt}\maxDim \the\maxDim \makeatother \end{LTXexample} %-------------------------------------------------------------------------------------- \subsection{\CMD{pst\textat{}abs}} %-------------------------------------------------------------------------------------- \begin{verbatim} \pst@abs{}{} \end{verbatim} \begin{LTXexample}[width=2cm] \newcount\absNo \makeatletter \pst@abs{-34}\absNo \the\absNo\\ \pst@abs{4}\absNo \the\absNo \makeatother \end{LTXexample} %-------------------------------------------------------------------------------------- \subsection{\CMD{pst\textat{}absdim}} %-------------------------------------------------------------------------------------- \begin{verbatim} \pst@absdim{}{} \end{verbatim} \begin{LTXexample}[width=2cm] \newdimen\absDim \makeatletter \pst@absdim{-34cm}\absDim \the\absDim\\ \pst@absdim{4sp}\absDim \the\absDim \makeatother \end{LTXexample} %-------------------------------------------------------------------------------------- \section{Dashed Lines} %-------------------------------------------------------------------------------------- Tobias N�ring implemented an enhanced feature for dashed lines. The number of arguments is no more limited. \begin{verbatim} dash=value1[unit] value2[unit] ... \end{verbatim} \begin{LTXexample}[width=0.4\linewidth] \psset{linewidth=2.5pt,unit=0.6} \begin{pspicture}(-5,-4)(5,4) \psgrid[subgriddiv=0,griddots=10,gridlabels=0pt] \psset{linestyle=dashed} \pscurve[dash=5mm 1mm 1mm 1mm,linewidth=0.1](-5,4)(-4,3)(-3,4)(-2,3) \psline[dash=5mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm 1mm](-5,0.9)(5,0.9) \psccurve[linestyle=solid](0,0)(1,0)(1,1)(0,1) \psccurve[linestyle=dashed,dash=5mm 2mm 0.1 0.2,linetype=0](0,0)(-2.5,0)(-2.5,-2.5)(0,-2.5) \pscurve[dash=3mm 3mm 1mm 1mm,linecolor=red,linewidth=2pt](5,-4)(5,2)(4.5,3.5)(3,4)(-5,4) \end{pspicture} \end{LTXexample} %-------------------------------------------------------------------------------------- \section{\CMD{rmultiput}: a multiple \CMD{rput}} %-------------------------------------------------------------------------------------- \verb+PSTricks+ already knows a \verb+multirput+, which puts a box n times with a difference of $dx$ and $dy$ relativ to each other. It is not possible to put it with a different distance from one point to the next one. This is possible with \verb+rmultiput+: \begin{verbatim} \rmultiput[]{}(x1,y1)(x2,y2) ... (xn,yn) \rmultiput*[]{}(x1,y1)(x2,y2) ... (xn,yn) \end{verbatim} \begin{LTXexample}[width=6.2cm] \psset{unit=0.75} \begin{pspicture}(-4,-4)(4,4) \rmultiput[rot=45]{\red\psscalebox{3}{\ding{250}}}% (-2,-4)(-2,-3)(-3,-3)(-2,-1)(0,0)(1,2)(1.5,3)(3,3) \rmultiput[rot=90,ref=lC]{\blue\psscalebox{2}{\ding{253}}}% (-2,2.5)(-2,2.5)(-3,2.5)(-2,1)(1,-2)(1.5,-3)(3,-3) \psgrid[subgriddiv=0,gridcolor=lightgray] \end{pspicture} \end{LTXexample} %-------------------------------------------------------------------------------------- \section{\CMD{psrotate}: Rotating objects} %-------------------------------------------------------------------------------------- \CMD{rput} also has an optional argument for rotating objects, but always depending to the \CMD{rput} coordinates. With \CMD{psrotate} the rotating center can be placed anywhere. The rotation is done with \verb+\pscustom+, all optional arguments are only valid if they are part of the \verb+\pscustom+ macro. \begin{verbatim} \psrotate[options](x,y){rot angle}{} \end{verbatim} \begin{LTXexample}[width=0.4\linewidth] \psset{unit=0.75} \begin{pspicture}(-0.5,-3.5)(8.5,4.5) \psaxes{->}(0,0)(-0.5,-3)(8.5,4.5) \psdots[linecolor=red,dotscale=1.5](2,1) \psarc[linecolor=red,linewidth=0.4pt,showpoints=true] {->}(2,1){3}{0}{60} \pspolygon[linecolor=green](2,1)(5,1.1)(6,-1)(2,-2) \psrotate[linecolor=blue](2,1){60}{ \pspolygon(2,1)(5,1.1)(6,-1)(2,-2)} \end{pspicture} \end{LTXexample} %-------------------------------------------------------------------------------------- \section{\CMD{pslineII}: Colored lines} %-------------------------------------------------------------------------------------- The dashed lines are by default black and white lines. The new macro \verb|\pslineII| offers two-color lines and has the same syntax as \verb|\psline|. \begin{LTXexample}[width=8cm] \begin{pspicture}(0,-0.5)(7,0.5) \pslineII[linewidth=5pt,arrowscale=2]{o-o}(0,0)(7,0) \end{pspicture} \end{LTXexample} %-------------------------------------------------------------------------------------- \subsection{The options} %-------------------------------------------------------------------------------------- \begin{center} \begin{tabular}{l|p{6cm}} name & meaning\\\hline \verb|dashColorI| & first color, default is \verb|black|\tabularnewline \verb|dashColorII| & second color, default is \verb|red|\tabularnewline \verb|dashNo| & the difference in per cent of the colored lines, default is $0.2$\tabularnewline \verb|linecap| & \parbox[t]{6cm}{how two lines are connected.\\ 0: no modification\\ 1: rounded edges\\ 2: an additional half square at both ends} \end{tabular} \end{center} \verb|dashNo| can have values greater than $1$. In this case the value will be taken as an absolute width in the pt unit. Only this unit is possible! \subsection{Examples} \begin{LTXexample}[width=3.5cm] \psset{linewidth=2pt} \begin{pspicture}(3,3) \pslineII{->}(0,0)(3,3) \end{pspicture} \end{LTXexample} \begin{LTXexample}[width=3.5cm] \psset{linewidth=2pt} \begin{pspicture}(3,3) \pslineII[dashColorI=blue]{->}(0,0)(3,3) \end{pspicture} \end{LTXexample} \begin{LTXexample}[width=3.5cm] \psset{linewidth=2pt} \begin{pspicture}(3,3) \pslineII[dashColorI=blue,dashNo=15]{->}(0,0)(3,3) \end{pspicture} \end{LTXexample} \begin{LTXexample}[width=3.5cm] \psset{linewidth=2pt} \begin{pspicture}(3,3) \pslineII[dashColorI=blue,linecap=1,% dashNo=0.3,linewidth=0.5](0,0)(2,3) \end{pspicture} \end{LTXexample} \begin{LTXexample} \psset{linecolor=red,arrowscale=3} \psset{dashColorI=red,dashColorII=blue,dashNo=20,linewidth=2pt} \begin{pspicture}(0,0)(7,-5) \pslineII{<->}(0,0)(7,0)(7,-5)(0,-5) \pslineII[linewidth=5pt,% dashNo=0.1,arrowscale=2]{o-o}(0,-2.5)(7,-2.5) \end{pspicture} \end{LTXexample} \begin{LTXexample}[pos=t] \psset{linewidth=15pt,dashNo=10} \begin{pspicture}(0,1)(10,-6) \pslineII[linecap=2](0,0)(5,0)(5,-5)(0,-5)(0,0) \rput{45}(7,-2.5){% \pslineII[linecap=1,dashColorI=yellow,% dashColorII=cyan](0,0)(5,0)(5,-5)(0,-5)(0,0)% } \end{pspicture} \end{LTXexample} %-------------------------------------------------------------------------------------- \section{\CMD{pslineIII} Variable linewidth} %-------------------------------------------------------------------------------------- By default all lines have a fixed width. \verb|\pslineIII| allows to define the start and the end width of a line. It has the same syntax as \verb|\psline|. \begin{center} \begin{pspicture}(0,-0.5)(12,0.5) \pslineIII[wBegin=1cm,wEnd=0.3cm,linecolor=cyan](0,0)(12,0) \end{pspicture} \end{center} \begin{lstlisting}[basicstyle=\ttfamily\footnotesize] \pslineIII[wBegin=1cm,wEnd=0.3cm,linecolor=cyan](0,0)(12,0) \end{lstlisting} %-------------------------------------------------------------------------------------- \subsection{The options} %-------------------------------------------------------------------------------------- \begin{center} \begin{tabular}{l|p{8cm}} name & meaning\\\hline \verb|wBegin| & first width, default is \verb|\pslinewidth|\tabularnewline \verb|wEnd| & last width, default is \verb|\pslinewidth|\tabularnewline \end{tabular} \end{center} It is also possible to use \verb|pslineIII| with more than two coordinates, like \begin{center} \begin{pspicture}(0,-0.5)(12,2) \pslineIII[wBegin=1cm,wEnd=0.1cm,linecolor=red](0,0)(3,1.5)(9,1.5)(12,0) \end{pspicture} \end{center} \begin{lstlisting}[basicstyle=\ttfamily\footnotesize] \pslineIII[wBegin=1cm,wEnd=0.1cm,linecolor=cyan](0,0)(0,1.5)(12,1.5)(12,0) \end{lstlisting} \iffalse %-------------------------------------------------------------------------------------- \subsection{Examples} %-------------------------------------------------------------------------------------- \begin{LTXexample} \begin{pspicture}(-5,-5)(5,5) \psgrid[griddots=10, gridlabels=7pt, subgriddiv=0] % \pslineIII[wBegin=1cm,wEnd=0.2cm,linecolor=cyan]% (-4,4)(3,4)(5,2)(2,-5)(-5,-2)(-5,0) \pslineIII[wBegin=0.5cm](-5,-3)(5,3) \pslineIII[wBegin=0.5cm,wEnd=0.1cm,linecolor=red](0,-5)(0,0)(0,5) \pslineIII[wBegin=1cm,wEnd=0.3cm,linecolor=blue](-4,4)(5,-4) % \end{pspicture} \end{LTXexample} \clearpage \fi %-------------------------------------------------------------------------------------- \section{\CMD{psbrace}} %-------------------------------------------------------------------------------------- \subsection{Syntax} \begin{verbatim} \psbrace[]()(){} \end{verbatim} \begin{LTXexample}[width=4.5cm] \begin{pspicture}(4,4) \psgrid[subgriddiv=0,griddots=10] \pnode(0,0){A} \pnode(4,4){B} \psbrace[linecolor=red,ref=lC](A)(B){Text I} \psbrace[linecolor=blue,ref=lC](3,4)(0,1){Text II} \end{pspicture} \end{LTXexample} \bigskip The option \verb|\specialCoor| is enabled, so that all types of coordinates are possible, (nodename), ($x,y$), ($nodeA|nodeB$), ... %-------------------------------------------------------------------------------------- \subsection{Options} %-------------------------------------------------------------------------------------- Additional to all other available options from \verb|pstricks| or the other related packages, there are two new option, named \verb|braceWidth| and \verb|bracePos|. All important ones are shown in the following table. \begin{center} \begin{tabular}{l|l} name & meaning\\\hline \verb|braceWidth| & default is $0.35$\\ \verb|bracePos| & relative position (default is $0.5$)\\ \verb|linearc| & absolute value for the arcs (default is $2$mm)\\ \verb|nodesepA| & x-separation (default is $0pt$)\\ \verb|nodesepB| & y-separation (default is $0pt$)\\ \verb|rot| & additional rotating for the text (default is $0$)\\ \verb|ref| & reference point for the text (default is c) \end{tabular} \end{center} By default the text is written perpedicular to the brace line and can be changed with the \verb|pstricks| option \verb|rot=...|. The text parameter can take any object and may also be empty. The reference point can be any value of the combination of \verb|l| (left) or \verb|r| (right) and \verb|b| (bottom) or \verb|B| (Baseline) or \verb|C| (center) or \verb|t| (top), where the default is \verb|c|, the center of the object. %-------------------------------------------------------------------------------------- \subsection{Examples} %-------------------------------------------------------------------------------------- \begin{LTXexample} \begin{pspicture}(8,2.5) \psbrace(0,0)(0,2){\fbox{Text}}% \psbrace[nodesepA=20pt](2,0)(2,2){\fbox{Text}} \psbrace[ref=lC](4,0)(4,2){\fbox{Text}} \psbrace[ref=lt,rot=90,nodesepB=-15pt](6,0)(6,2){\fbox{Text}} \psbrace[ref=lt,rot=90,nodesepA=-5pt,nodesepB=15pt](8,2)(8,0){\fbox{Text}} \end{pspicture} \end{LTXexample} \begin{LTXexample} \def\someMath{$\int\limits_1^{\infty}\frac{1}{x^2}\,dx=1$} \begin{pspicture}(8,2.5) \psbrace(0,0)(0,2){\someMath}% \psbrace[nodesepA=30pt](2,0)(2,2){\someMath} \psbrace[ref=lC](4,0)(4,2){\someMath} \psbrace[ref=lt,rot=90,nodesepB=-30pt](6,0)(6,2){\someMath} \psbrace[ref=lt,rot=90,nodesepB=30pt](8,2)(8,0){\someMath} \end{pspicture} \end{LTXexample} %$ \begin{LTXexample} \begin{pspicture}(\linewidth,5) \psbrace(0,0.5)(\linewidth,0.5){\fbox{Text}}% \psbrace[bracePos=0.25,nodesepB=-10pt,rot=90](0,2)(\linewidth,2){\fbox{Text}} \psbrace[ref=lC,nodesepA=-3.5cm,nodesepB=-15pt,rot=90](0,4)(\linewidth,4){% \fbox{some very, very long wonderful Text}} \end{pspicture} \end{LTXexample} \begin{LTXexample} \def\someMath{$\int\limits_1^{\infty}\frac{1}{x^2}\,dx=1$} \begin{pspicture}(12,11) \psgrid[subgriddiv=0,griddots=10] \pnode(0,0){A} \pnode(4,6){B} \psbrace[ref=lC](A)(B){One} \psbrace[rot=180,nodesepA=-5pt,ref=rb](B)(A){Two} \psbrace[linecolor=blue,bracePos=0.25,braceWidth=1,ref=lB](8,1)(1,7){Three} \psbrace[braceWidth=-1,rot=180,ref=rB](8,1)(1,7){Four} \psbrace[linearc=0.5,linecolor=red,linewidth=3pt,braceWidth=1.5,% bracePos=0.25,ref=lC](8,1)(8,9){\someMath} \psbrace(4,9)(6,9){} \psbrace(6,9)(6,7){} \psbrace(6,7)(4,7){} \psbrace(4,7)(4,9){} \psset{linecolor=red} \psbrace[ref=lb](7,10)(3,10){I} \psbrace[ref=lb,bracePos=0.75](3,10)(3,6){II} \psbrace[ref=lb](3,6)(7,6){III} \psbrace[ref=lb](7,6)(7,10){IV} \end{pspicture} \end{LTXexample} %$ \begin{LTXexample}[width=5cm] \[ \begin{pmatrix} \Rnode[vref=2ex]{A}{~1} \\ & \ddots \\ && \Rnode[href=2]{B}{1} \\ &&& \Rnode[vref=2ex]{C}{0} \\ &&&& \ddots \\ &&&&& \Rnode[href=2]{D}{0}~ \\ \end{pmatrix} \] \psbrace[linewidth=0.1pt,rot=-90,nodesep=0.2](B)(A){\small n times} \psbrace[linewidth=0.1pt,rot=-90,nodesep=0.2](D)(C){\small n times} \end{LTXexample} It is also possible to put a vertical brace around a default paragraph. This works with setting two invisible nodes at the beginning and the end of the paragraph. Inentation is possible with a minipage. \begin{framed} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \noindent\rnode{A}{} \vspace*{-1ex} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \vspace*{-2ex} \noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \medskip \hfill\begin{minipage}{0.95\linewidth} \noindent\rnode{A}{} \vspace*{-1ex} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \vspace*{-2ex} \noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){} \end{minipage} \end{framed} \begin{lstlisting} \begin{framed} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \noindent\rnode{A}{} \vspace*{-1ex} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \vspace*{-2ex} \noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \medskip \hfill\begin{minipage}{0.95\linewidth} \noindent\rnode{A}{} \vspace*{-1ex} Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. Some nonsense text, which is nothing more than nonsense. \vspace*{-2ex} \noindent\rnode{B}{}\psbrace[linecolor=red](A)(B){} \end{minipage} \end{framed} \end{lstlisting} %-------------------------------------------------------------------------------------- \section{Random dots} %-------------------------------------------------------------------------------------- The syntax of the new macro \verb+\psRandom+ is: \begin{verbatim} \psRandom[