\documentclass[a4,notes]{seminar}
\slideframewidth1pt
\slidestyle{empty}
\twoup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}
\usepackage{amsmath,amsfonts}
\usepackage{color}
\usepackage{graphicx}
\usepackage{psfrag,pstricks,pst-node,pst-plot}
\usepackage{pst-grad}
\usepackage{pst-text,pst-char,ae}
\usepackage{pstricks-add}
\usepackage{wasysym,marvosym}
\newdimen\BaseUnit
\BaseUnit0.5cm
\psset{unit=1\BaseUnit}
\def\slidefonts{\sf}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifred
\catcode`\§=\active
\def§{\ifred\color{black}\redfalse\else\color{red}\redtrue\fi}
\catcode`\°=\active
\def°#1°{\color{#1}}
\definecolor{brown}{rgb}{0.4,0.2,0}
\definecolor{lightred}{rgb}{0.7,0.5,0}
\newrgbcolor{brown}{0.4 0.4 0.2}
\newrgbcolor{lightbrown}{0.8 0.8 0.4}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newbox\mybox
\def\widthof#1{}
\def\bNew{\bgroup\color{red}}\def\eNew{\egroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%\special{landscape}
%%\psset{xunit=0.1\textwidth,yunit=0.1\textheight}
\let\oldslide\slide
\let\endoldslide\endslide
\renewenvironment{slide}{\begin{oldslide}}{\vfill\par\end{oldslide}}
\def\todo#1{\footnote{Todo: #1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% pstricks-hacks:
%% x1 y1 x2 y2 -> AddPairs -> (x1+x2) (y1+y2)
\def\AddPairs{ exch 4 1 roll add 3 1 roll add exch }
%% x1 y1 x2 y2 -> SubPairs -> (x1-x2) (y1-y2)
\def\SubPairs{ exch 4 1 roll sub 3 1 roll exch sub exch }
\def\ScalePair{
  dup 4 -1 roll %% Scaling Factor 
  mul
  3 1 roll
  mul
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\bigtimes{\mathop{\mathsf{X}}}
\def\PSTricks{PSTricks}
\title{Short introduction to PSTricks}
\author{Tobias N\"{a}hring}
\begin{document}
\begin{slide}
  \maketitle
\end{slide}
This presentation was held in German at the \TeX-user-meeting Dresden
\mbox{(Germany)} at June 12, 2004 (see also
\texttt{http://www.carstenvogel.de}).

The slides are shown here in a scaled-down version with minor changes
and some explanations are added.


\PSTricks{} is well suited to draw simple vector graphics
inside of \LaTeX{} documents. The basic syntax of \PSTricks{} is quite
similar to that one of the \texttt{picture} environment native to
\LaTeX{} but the macros of \PSTricks{} are in general much more
comfortable and powerful.

Even if \PSTricks{} is rather powerful it should be emphasised that
every program should be used for the task it is designed for. For an
example, if you want to construct complicated realistic
three-dimensional scenes you should better use some ray
tracer\footnote{\dots even if less complicated three-dimensional
  scenes can be visualized with the help of the \PSTricks add-on
  \texttt{vue3d}} (e.\,g. the freely available ray tracer
\texttt{povray}).

\newpage
\begin{slide}
  \section{Sources}
  \begin{itemize}
  \item \texttt{http://www.tug.org/applications/PSTricks/}\\
    Many, many examples. (Learning by doing.)
  \item    \texttt{http://www.pstricks.de/}\\
    Ditto.
  \item    \texttt{http://www.pstricks.de/docs.phtml}\\
    PSTricks user guide:  as one PDF,\quad PSTricks quick reference card
  \item Elke \& Michael Niedermair, \LaTeX{} Praxisbuch, 2004,
    Franzis-Verlag,\\ (Studien\/ausgabe für 20\EURhv)
  \end{itemize}
\end{slide}
\vspace*{-2cm}
The original documentation of \PSTricks{} written by Timothy van Zandt
(the author of the base packages of \PSTricks{}) is 100 pages long.
Documentations of add-ons for pstricks cover again hundreds of pages.

From that fact, it is clear that this short presentation can only
cover very few aspects of the \PSTricks{} package.
So, the first slide gives some sources of informations about the
\PSTricks{}-package.

The intention of this presentation is to give an impression of what is
possible with the basic \PSTricks{}-packages and to encourage
interested people to give \PSTricks{} a try.

\newpage
\begin{slide}
  \tableofcontents
\end{slide}
\newpage
\mbox{}
\newpage
At first, some §geometric objects§ of \PSTricks{} are presented
followed by some macros for the §modification§ of these objects.  This
includes §function plots§ and §embedded eps figures§.

Then, the power of the \PSTricks{}-constructs called `§nodes§' and `§node
connections§' are demonstrated with the help of some examples. 

After that, the usage of §PDF\LaTeX{}§ for documents with
\PSTricks{}-pictures is discussed.

At last, two slides with §other nice stuff§ of \PSTricks{} are shown.

Pieces of §embedded Postscript fragments§ throughout the presentation
show the close relation of \PSTricks{} with the Postscript language.

Some basic knowledge is advantageous when using \PSTricks{} but many
things are also possible without such knowledge.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \psset{unit=2\BaseUnit,gridcolor=green,subgridcolor=yellow}
  \section{First example}
  \begin{minipage}{0.5\textwidth}
\begin{verbatim}
\documentclass{article}
§\usepackage{pstricks}§
\begin{document}
\begin{figure}
 §\begin{pspicture}(4,5)
    \psframe(0.7,2)(3.3,3)
    \rput(2,2.5){First Example}
  \end{pspicture}§
\end{figure}
\end{document}
\end{verbatim}
  \end{minipage}
\begin{minipage}{0.45\textwidth}\centering
  \begin{pspicture}(4,5)
    \psframe(0.7,2)(3.3,3)
    \rput(2,2.5){First Example}
  \end{pspicture}\\[1em]
\end{minipage}
  pspictures can replace simple eps-figures.
\end{slide}
To use \PSTricks{} macros in \LaTeX{} at least the style file
\texttt{pstricks.sty} must be loaded. The basic \PSTricks{} package
has many more style files for various tasks. If you do not mind
processing time then you can load all these files with the command
\verb=§\usepackage{pst-all}§= instead of \verb=\usepackage{pstricks}=.

With the \verb=\psframe= macro above the rectangle in the picture is
drawn. \PSTricks{} macros such as \verb=\psframe= do not modify the current
\LaTeX{} position. If there is no extra space is reserved for the
\PSTricks{} objects then the following \LaTeX{} Text overwrites the
objects as it is demonstrated \psframe[linecolor=lightgray](0.1ex,1ex)(2cm,-1cm)here.

The task of reserving space for the \PSTricks{} pictures is accomplished
by the \texttt{pspicture} environment. In the form above the
coordinate pair \verb=(4,5)= in \verb=\begin{pspicture}(4,5)= stands
for the width and the height  of the \PSTricks{} picture. By default
lengths are measured in centimetres.

The pairs of numbers in the parentheses following the \verb=\psframe= macro
are the coordinates of the lower left and the upper right corners of
the rectangle.

The most simple form of the \verb=\rput= macro used above works very
much like the \verb=\put= macro of the \LaTeX{} picture environment.
Later we will see that the \verb=\rput= macro is the much more
powerful one of both.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Important tool: The grid}
  \begin{minipage}{0.5\textwidth}
\begin{verbatim}
\begin{pspicture}(4,5)
  §\psgrid§
  ...
\end{pspicture}
\end{verbatim}
\vspace{1ex}
{
  \flushleft
  Globally deactivated via\\
  \verb=§\let\psgrid\relax§=\\
  in the final version.
}
  \end{minipage}
  \psset{unit=2\BaseUnit}
  \begin{minipage}{0.45\textwidth}\centering
    \begin{pspicture}(4,5)
      \psgrid
      \psframe(0.7,2)(3.3,3)
      \rput(2,2.5){First Example}      
    \end{pspicture}    
  \end{minipage}
\end{slide}
One important tool for drawing pictures with pstricks is the grid. It
can be activated with the \verb=\psgrid= macro. If no further
arguments are given in the \verb=\psgrid= command it produces a grid with
width and height as determined by the size of the enclosing pspicture.

If one wants all other \PSTricks{} elements in the pspicture drawn
onto the grid one should specify \verb=\psgrid= at first inside the
pspicture environment as indicated above. On the other side, if one
wants the grid drawn onto all the other stuff in the pspicture one
should specify the grid as the last thing in the pspicture environment.

To remove all grids in the final document one can simply deactivate
all the \verb=\psgrid= commands in the document by the single command
\verb=\let\psgrid\relax= at the beginning of the document.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \psset{unit=2\BaseUnit}
  \section{Setting options}
  \begin{minipage}{0.5\linewidth}
\begin{verbatim}
§\psset{gridcolor=green,
       subgridcolor=yellow}§
\begin{pspicture}(4,5)
 ...
  \psframe§[linecolor=blue,
            fillcolor=red,
            fillstyle=solid]§
            (0.7,2)(3.3,3)
 ...
\end{verbatim}
\begin{verbatim}
\end{pspicture}
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.45\linewidth}\centering
    \psset{gridcolor=green,subgridcolor=yellow}
    \begin{pspicture}(4,5)
      \psgrid
      \psframe[fillcolor=red,
               fillstyle=solid,
               linecolor=blue]
               (0.7,2)(3.3,3)
      \rput(2,2.5){First Example}
    \end{pspicture}
  \end{minipage}
\end{slide}
Many, many options can be set for \PSTricks{} elements.
There are two main ways to do so.

To set the options for all following \PSTricks{} elements inside the
scope of the current group one can use the \verb=\psset= macro.  The
options are given as a coma separated list of key=value pairs. It is
admissible to place \verb=\psset= macros outside of pspicture
environments.

For specifying options for a specific \PSTricks{} element most
\PSTricks{} macros accept optional arguments in brackets as indicated
 on the slide.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \psset{unit=2\BaseUnit}
  \section{Star versions of objects}
  \begin{minipage}{0.5\linewidth}
\begin{verbatim}
\begin{pspicture}(4,5)
 ...
  \psframe§*§[linecolor=blue,
              fillcolor=red]
            (0.7,2)(3.3,3)
 ...
\end{verbatim}
\begin{verbatim}
\end{pspicture}
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.45\linewidth}\centering
    \psset{gridcolor=green,subgridcolor=yellow}
    \begin{pspicture}(4,5)
      \psgrid
      \psframe*[linecolor=blue]
               (0.7,2)(3.3,3)
      \rput(2,2.5){First Example}
    \end{pspicture}
  \end{minipage}
\end{slide}
Often one needs just one evenly colorised area. For that purpose most
\PSTricks{} elements have a corresponding star version (Note the red
star on the slide).  The area of the star form of a \PSTricks{}
element is filled with the \texttt{linecolor} -- regardless of the
current setting of the option \texttt{fillcolor}.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Further basic geometric objects}
  \begin{minipage}{0.45\linewidth}
\begin{verbatim}
§\psline
\psdots
\pspolygon
\pscircle
\psellipse
\psarc
\pscurve
\psbezier§
\end{verbatim}
  \end{minipage}
  \psset{xunit=0.1\textwidth,yunit=0.1\textheight}\centering
  \begin{minipage}{0.5\linewidth}
    \begin{pspicture}(0,-0.5)(4,5)
      %% \psgrid
      \rput[b](1,4.8){Lines and dots}
      \psline[showpoints=true,arrowsize=2.5pt 10]{<->}(0,4.0)(0.5,4.7)(0.8,3.9)(2.0,4.5)
      \rput(1,2.4){Polygons}
      \pspolygon(0.3,2)(0.3,3)(1,3.5)(1.7,3)(1.7,2)
      \rput[l](3.10,3.40){\setbox\mybox\hbox{Ellipses,}\parbox{\wd\mybox}{Ellipses,\\Circles,\\Arcs}}
      \pscircle(2.60,3.40){1}
      \psellipse(2.60,3.40)(0.50,1.50)
      \rput(2.30,3.10){
        \psline(0,0)(0.6,0)
        \psarc(0,0){1}{0}{45}
        \rput{45}(0,0){
          \psline(0,0)(0.6,0)
        }}
      \rput[tl](1.7,0.5){\setbox\mybox\hbox{(interpolated
      splines)}\parbox{\wd\mybox}{Curves\\(interpolated splines)}}
      \pscurve[showpoints=true](2,1)(2.5,1.5)(3,0.5)(3.5,1.5)
      \rput[b](1,1.3){Beziér-Splines}
      \psbezier[showpoints=true](0.3,0.2)(0.7,1.0)(1.5,1.1)(1,0.3)
    \end{pspicture}
  \end{minipage}

  Exact syntax: \texttt{pst-usr.pdf}/\texttt{pst-quik.ps}
\end{slide}

This slide just shows some of the more important geometrical
\PSTricks{} elements.

The interpolated points of the curve and the control points of the
Bezier spline are visible because of the option \texttt{showpoints} is
set to \texttt{true}.

For the exact syntax of the corresponding macros the reader is referred
to the \PSTricks{} user guide.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Line ends `Arrows'}
  \begin{minipage}{0.5\linewidth}
\begin{verbatim}
\psline§{-*}§(1,6)(2,6)
\psline§{-}§(3,6)(4,6)
\psline§{->}§(2.5,5)(2.5,3)
\pscurve§{|-|}§(1,2)(2.5,1)(4,2)
\end{verbatim}
  \end{minipage}
  \psset{xunit=0.1\textwidth,yunit=0.1\textheight}
  \begin{minipage}{0.45\linewidth}
    \begin{pspicture}(\linewidth,0.8\textheight)
      \psset{dotsize=2pt 10,tbarsize=2.5pt 10,arrowsize=2.5pt 10}
      \psline{-*}(1,6)(2,6)
      \psline{-}(3,6)(4,6)
      \pscurve{|-|}(1,2)(2.5,1)(4,2)
      \psline{->}(2.5,5)(2.5,3)
    \end{pspicture}
  \end{minipage}
\end{slide}
There is a special way to specify the look of the ends of lines,
curves, splines and some other one-dimensional objects. Such ends
are called as arrow heads in the user guide.  You can set the shape
of the arrow heads in curly braces just before the coordinate pairs of
the points of the \PSTricks{} element.  There are many more arrow
heads available in \PSTricks{} than those on the slide.

Using all possibilities to specify options of one-dimensional objects
one ends up with the sequence: \textbf{1st} options in brackets,
\textbf{2nd} arrow options in curly braces, \textbf{3rd} points in
parenthesis\footnote{Thanks to Stefan Berthold who pointed out that I
  should mention that.}.

\noindent Example: 
\begin{verbatim}
\psline[tbarsize=10pt 5]{|->}(0.5,0.5ex)(\linewidth,0.5ex)
\end{verbatim}
\psline[tbarsize=10pt 5]{|->}(0.5cm,0.5ex)(\linewidth,0.5ex)

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{File plots}
  \begin{minipage}[t]{0.475\linewidth}
\begin{verbatim}
\usepackage{§pst-plot§}
...
\psset{§xunit=0.3\psunit§,§yunit=2\psunit§}
§\psaxes[Dx=5]{->}(0,0)(0,-1)(24,1.5)§
§\fileplot{§bessel.dat§}§
\end{verbatim}
    \vspace{1ex}
    \hrule\mbox{}\\[0.2ex]
    Contents of the file bessel.dat:
\begin{verbatim}
 0  1  
 0.20202  0.989823
 0.40404  0.959602
\end{verbatim}\setbox\mybox\hbox{\texttt{ 0.40404 }}
\hspace*{1\wd\mybox}$\vdots$
  \end{minipage}
  \psset{xunit=0.1\textwidth,yunit=0.1\textheight}
  \begin{minipage}[t]{0.475\linewidth}
    \begin{pspicture}(-1.8,2.5)(2.5,2.5)
      % \psgrid
      \psset{arrowsize=2pt 5,labelsep=10pt}
      \psset{xunit=0.3\BaseUnit,yunit=2\BaseUnit}
      \rput(0,-10ex){
        \psset{xunit=0.3\psunit,yunit=2\psunit}
        \psaxes[Dx=5]{->}(0,0)(0,-1)(24,1.5)
        \fileplot{bessel.dat}
      }
    \end{pspicture}
  \end{minipage}
\end{slide}

A further basic \PSTricks{} element is the file plot which is defined
in the style file \texttt{pst-plot.sty}.

With the \verb=\fileplot= macro data is read from a file (on the slide
the file's name is \texttt{bessel.dat}). The points from the data file are
plotted with lines connecting consecutive points (the latter
behaviour can be changed via the option \texttt{§plotstyle§}).

The scale of the plot is determined by the options \texttt{§xunit§}
and \texttt{§yunit§}. The origin of the coordinates is the current
point (0,0).

The \verb=\psaxes= macro can be used to provide the plot with
axes. The first of the three coordinate pairs behind
\verb=\psaxes= determines the origin of the coordinate system the
second one determines the lower left corner of the coordinate system
and the third the upper right corner (a similar syntax can be used for
the \verb=\psgrid= macro mentioned above).

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}{}
  \section{Function plots (parametric)}
  \begin{minipage}[B]{0.625\linewidth}
\begin{verbatim}
\def\Euler{2.718 }
§\parametricplot[plotstyle=curve]{0}{360}{
  3 t mul cos \Euler -0.01 t mul exp mul
  3 t mul sin \Euler -0.01 t mul exp mul }§
\end{verbatim}
  \begin{align*}
  (x(t),y(t))=\exp(-0.01t)\cdot(\cos(3t),\sin(3t))\\
  \text{with }t\in[0,360^{\circ}]
  \end{align*}
  \end{minipage}
  \begin{minipage}[B]{0.275\linewidth}
    \psset{unit=3.5\BaseUnit}
    \begin{pspicture}(-1.2,-1.2)(1.2,1.2)
                                % \psgrid
      \def\Euler{2.718 }
      \parametricplot[plotstyle=curve]
      {0}{360}{ 3 t mul cos \Euler -0.01
        t mul exp mul 3 t mul sin \Euler -0.01 t mul exp mul }
    \end{pspicture}
  \end{minipage}
  Postscript: Chapter `Operators' in \texttt{RedBook.pdf} by Adobe Inc.
\end{slide}
\vspace*{-4cm}
Also function plots can be made by \PSTricks. For
$x$-$y$-plots the \verb=\psplot= macro may be used. On this slide,
however, the more flexible \verb=\parametricplot= macro is
demonstrated.

The parametric description of the curve to be plotted is shown as the
black formula on the slide (it represents three windings of a
logarithmic spiral).

The parameter identifier in parametric plots is always \texttt{t}.
The start and the end of the parameter domain are given inside the first
and the second curly braces, resp., of the \verb=\parametricplot= macro. 

The defining function of the curve is described as a postscript
program fragment inside the third curly braces of the
\verb=\parametricplot= macro.

With the option \texttt{plotstyle} set to \texttt{curve} splines are
used to interpolate the computed samples along the function graph.
Without this option points are connected with line segments. You
should try this for yourself to see the difference.


For an exact description of the Postscript programming language the
reader is referred to the Postscript Language Reference called the Red
Book which can be downloaded from\\
\url{http://partners.adobe.com/asn/tech/ps/specifications.jsp}.\\
For the moment think of the program segment just as
a representation of the formula in reverse polish notation\todo{This
  should be explained in some more detail.}.

In postscript fragments expandable \LaTeX{} macros such as
\verb=\Euler= on the slide may be used. Note
the space in the definition of the macro \verb=\Euler=.
This space is necessary since the space after \verb=\Euler= in the
postscript fragment is eaten during the \LaTeX{} expansion process.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}{}
  \section{Placing whatever, wherever}
  \begin{minipage}[b]{0.75\linewidth}
\begin{verbatim}
\psdots[linecolor=red,dotsize=10pt]
(0,5)(-1,3)(1,2)(0.5,1)
§\rput(0,5){§Center,Middle§}§
\rput§[bl]§(-1,3){$\underbrace{
       \text{bottom,left}
     }_{\text{Really!}}$}
\rput§[Br]§(1,2){$\underbrace{
       \text{Baseline,right}
     }_{\text{Really!}}$}
\rput[tr]§{45}§(0.5,1)
  {\parbox{5cm}{\flushright Rotated\\
                      by $45^{\circ}$}}
\end{verbatim}
  \end{minipage}
  \psset{xunit=2\BaseUnit,yunit=2\BaseUnit}
  \begin{minipage}[b]{0.2\linewidth}
    \psset{yunit=2.3\BaseUnit}
    \begin{pspicture}(-1,0)(1,5)
      \psgrid[subgriddiv=1,griddots=10]
      \psdots[linecolor=red,dotsize=5pt](0,5)(-1,3)(1,2)(0.5,1)
      \rput(0,5){Center,Middle}
      \rput[bl](-1,3)
      {$\underbrace{\text{bottom,left}}_{\text{Really!}}$}
      \rput[Br](1,2){$\underbrace{\text{Baseline,right}}_{\text{Really!}}$}
      \rput[tr]{45}(0.5,1){\parbox{5\BaseUnit}{\flushright Rotated\\by $45^{\circ}$}}
    \end{pspicture}
  \end{minipage}
\end{slide}
Now, that we know some \PSTricks{} elements we can focus on the
modification of such elements or groups of such elements.

As we have already seen, the \verb=\rput= macro can be used to place
objects.  The second mandatory argument (in curly braces) is the stuff
to place the first mandatory argument (in parenthesis) is the
coordinate pair of the point where the stuff is placed.

Now we turn to the optional arguments of the
\verb=\rput= macro.

The first one is given in brackets.  It determines the justification
of the bounding box of the object to place with respect to the point
given in parenthesis. The admissible values are the same as the values
for the option \texttt{origin} of the \verb=\includegraphics= macro.
For an instance \texttt{[br]} for bottom~--~right. The default is
\texttt{mc} meaning middle~--~center.

The second optional argument is given in curly braces just before the
left parenthesis. It is a number that stands for the rotation angle as
illustrated in the last instance of the \verb=\rput= macro on the
slide.

The two optional arguments make \verb=\rput= more flexible than the
\verb=\put= macro of the \verb=picture= environment.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Clipping and scaling}
  \begin{minipage}{0.6\linewidth}
    \psset{unit=1\BaseUnit}
\begin{verbatim}
\def\myEye{
  §\begin{psclip}{§\psellipse(0,0)(0.8,1.5)§}§
     \pscircle*[linecolor=blue](0,-1){1}
  §\end{psclip}§
  \pspolygon*(-0.4,1.5)(0.7,1.8)
             (0.2,2.2)(-0.5,1.6)
}
\rput(8,2){\myEye}
\rput(6,2){§\scalebox{-1 1}{§\myEye§}§}
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.35\linewidth}
    \psset{unit=1\BaseUnit}
    \pspicture(5,4)
    %%\psgrid
    \def\myeye{
      \begin{psclip}{\psellipse(0,0)(0.8,1.5)}
        \pscircle*[linecolor=blue](0,-1){1}
      \end{psclip}
      \pspolygon*(-0.4,1.5)(0.7,1.8)(0.2,2.20)(-0.5,1.6)}
    \rput(5,1){\myeye}
    \rput(2,1){\scalebox{-1 1}{\myeye}}
  %\psgrid
    \endpspicture
  \end{minipage}
\end{slide}
\vspace*{-2cm}
A very important feature provided by Postscript is clipping. Clipping
is also supported by \PSTricks. It makes \PSTricks{} even
superior to some wysiwyg\footnote{What You See Is What You Get.} vector
drawing programs.

Clipping requires two arguments firstly a closed path the so called
clip path and secondly the clipped graphics.  Only that portion of the
clipped graphics is shown that lies inside the region bounded by the
clip path.

\PSTricks{} provides the \texttt{psclip} environment for clipping. The
mandatory argument of the \texttt{psclip} environment in the curly
braces is the clip path. The clipped graphics is written into the
\texttt{psclip} environment. On the slide the blue iris of the eye is
drawn as a blue full circle. The visible part of the iris is cut out
via a clip path drawn by a \verb=\psellipse= macro. Note, that the
clip path is drawn as an ordinary \PSTricks{} element with the current
line style and fill style. If you want to
make the clip path invisible you have to set the \texttt{linestyle}
option to \texttt{none}.

A standard feature of drawing programs is scaling. This is provided by
\PSTricks{} through the \verb=\scalebox= macro. The two numbers in the
first argument of \verb=\scalebox= are the scaling factors in $x$- and
$y$-direction. The stuff to be scaled is put into the second argument.

On the slide we use scaling for reflecting the eye in
$x$-direction\footnote{One can also use \texttt{\textbackslash reflectbox} for this
  purpose (thanks to Bj\"{o}rn).}.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Easy way to scale everything}
  \begin{minipage}{0.45\linewidth}
\begin{verbatim}
\begin{pspicture}(4,5)
  \rput(2,2)\myeye
\end{pspicture}
\hspace{1cm}
§\psset{unit=0.75cm}§
\begin{pspicture}(4,5)
  \rput(2,2)\myeye
\end{pspicture}
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.45\linewidth}
    \def\myeye{
      \begin{psclip}{\psellipse(0,0)(0.8,1.5)}
        \pscircle*[linecolor=blue](0,-1){1}
      \end{psclip}
      \pspolygon*(-0.45,1.5)(0.75,1.83)(0.19,2.20)(-0.5,1.6)}
    \psset{unit=1\BaseUnit,gridcolor=green,subgridcolor=yellow}
    \begin{pspicture}(4,5)
      \psgrid
      \rput(2,2)\myeye
    \end{pspicture}\hspace{1\BaseUnit}
    \psset{unit=0.75\BaseUnit}
    \begin{pspicture}(4,5)
      \psgrid
      \rput(2,2)\myeye
    \end{pspicture}
  \end{minipage}
\end{slide}
One could put units (like \texttt{pt, cm, in}) on each measure inside
a \texttt{pspicture} environment. But it is very wise \textbf{not} to do so,
since if one uses unit-free measures the picture keeps scalable.

One can easily change the size of the picture by setting the option
\texttt{unit} to the desired value. None-uniform scaling is also
possible with the options \texttt{xunit} and \texttt{yunit}.

On the slide the default value of \texttt{1cm} for \texttt{unit} is
used for the left picture. Exactly the same picture is drawn on the
right side with \texttt{unit} set to \texttt{0.75cm}.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Enrolling one's own path}
\begin{minipage}{0.5\linewidth}
\begin{verbatim}
\psset{linecolor=red,fillcolor=pink,fillstyle=solid}
\rput(0,2){
  \pscurve(1,0)(0,-1.0)(-1,0)
  \pscurve(-1,0)(0,-0.5)(1,0)
}
§\pscustom{§
  \pscurve(1,0)(0,-1.0)(-1,0)
  \pscurve[§liftpen=1§](-1,0)(0,-0.5)(1,0)
§}§
\end{verbatim}
\end{minipage}
    \psset{xunit=2\BaseUnit}
    \newrgbcolor{pink}{1 0.7 0.7}
      \psset{linecolor=red,fillcolor=pink,fillstyle=solid}
    \def\Mouth#1{
      \pscurve(1,0)(0,-1.0)(-1,0)
      \pscurve#1(-1,0)(0,-0.5)(1,0)
    }
  \begin{minipage}{0.4\linewidth}
    \begin{pspicture}(-0.5\linewidth,-0.4\textheight)(0.5\linewidth,0.4\textheight)
      \rput(0,2){\Mouth{}}
      \pscustom{
        \Mouth{[liftpen=1]}
      }                 
      %%\psgrid
    \end{pspicture}
  \end{minipage}
\end{slide}
\vspace*{-4cm}
With the Postscript language a visible object is created in two steps.
In the first step a path is defined and in the second step some
visualisation like stroking or filling is done with the path.
Different geometrical objects can be used to describe one path. An
example is the postscript fragment
\begin{verbatim}
  0 -50 rlineto
  50 0  100 0 100 50 rcurveto
  stroke
\end{verbatim}
which defines a path consisting of a line and a bezier curve
and afterwards strikes the path. The result of this Postscript fragment is shown here:~\parbox{1cm}{\mbox{}
\special{ps:
  gsave 
  0 -50 rlineto
  50 0  200 0 200 50 rcurveto
  stroke
  grestore}
}
with \texttt{stroke} replaced by \texttt{fill} one obtains:~\parbox{1cm}{\mbox{}
\special{ps:
  gsave 
  0 -50 rlineto
  50 0  200 0 200 50 rcurveto
  fill
  grestore}
}

Normally, \PSTricks{} concludes the postscript fragment corresponding
to a macro like \verb=\pscurve= immediately with a \texttt{stroke}
and/or \texttt{fill} command (depending on the
\texttt{linestyle/fillstyle} options). Thus, each of the first two
\verb=\pscurve= commands on the slide fills its own path and one
obtains the upper figure on the slide.

It might be that one just wanted to fill
the region between the two curves. This means
that the two curves should belong to the same filled path.

\PSTricks{} defines the \verb=\pscustom= macro. Inside the
argument of this macro the Postscript fragments belonging to macros
like \verb=\pscurve/\psline/\psbezier= are not concluded with
\verb=fill= or \verb=stroke=. Thus all the objects inside the
\verb=\pscustom= argument belong to the same path. At the end of the
execution of the
\verb=\pscustom= macro the path is stroked/filled according to the
\texttt{fillstyle/linestyle} options.

The option \texttt{liftpen=1} prevents \PSTricks{} to try to connect
the two curves in some strange manner. Without this option one would
obtain something like:
{    \psset{xunit=2\BaseUnit}
    \newrgbcolor{pink}{1 0.7 0.7}
      \psset{linecolor=red,fillcolor=pink,fillstyle=solid}
    \def\Mouth#1{
      \pscurve(1,0)(0,-1.0)(-1,0)
      \pscurve#1(-1,0)(0,-0.5)(1,0)
    }
    \pscustom{\Mouth{}}
}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}[28cm,15cm]
  \section{Repetition (and rgbcolors)}
  \begin{minipage}[b]{0.65\linewidth}
\begin{verbatim}
\usepackage{§pstcol§,§multido§}
...
\psset{fillstyle=solid,linestyle=none}
§\multido{\nx=0.0+0.1}{10}{§%
   §\multido{\ny=0.0+0.1}{10}{§%
      §\newrgbcolor{c}{{\nx} {\ny} 0}§%
      \rput(\nx,\ny){%
        \psframe[fillcolor=c](0,0)(0.1,0.1)%
}§}}§
§\multirput[Bl](0,0.92)(0.084,-0.1){10}{§Nice!§}§
\end{verbatim}
  \end{minipage}
\begin{minipage}{0.25\linewidth}
    \begin{pspicture}(1,1)
      \psset{unit=8\BaseUnit}
      \psset{fillstyle=solid,linestyle=none}
      \multido{\nx=0.0+0.1}{10}{%
        \multido{\ny=0.0+0.1}{10}{%
          \newrgbcolor{c}{{\nx} {\ny} 0}%
          \rput(\nx,\ny){\psframe[fillcolor=c](0,0)(0.1,0.1)}%
        }}
      \multirput[Bl](0,0.92)(0.084,-0.1){10}{\bf Nice!}
  \end{pspicture}
\end{minipage}
\end{slide}
\vspace*{-3cm}
The \verb=multido= style file from the \PSTricks{} package provides
the two macros \verb=\multido= and \verb=\multirput=.

The \verb=\multido= macro allows to repeat some sequence of \LaTeX{}
macros a given number of times. The first argument of the
\verb=\multido= macro contains an 'identifier = initial value +
increment' sequence, the second argument contains the number of
repetitions and the last one contains the \LaTeX{} commands to be
repeatedly executed.

The first letter in the identifier of the control variable must be a
'n' for a real number and an 'i' for an integer.

As demonstrated on the slide the \verb=\multido= macros may be
nested.

More than one control variable might be defined in the first argument of
the \verb=\multido= macro by a coma separated list.

The \verb=\multirput= macro on the slide produces once a box from
the \LaTeX{} code `\texttt{Nice!}' then it places it ten times with
initial position (0,0.92) and increment (0.084,-0.1).

The package \texttt{pstcol} allows to define new RGB-colors with the
help of a macro \verb=\newrgbcolor=.

The first argument of \verb=\newrgbcolor= is the name of the
new color the second argument is a space separated triple of numbers
which stand for the red, green, and blue fraction of the newly defined
color.

That color can then be used as value for color options
like \texttt{linecolor} and \texttt{fillcolor}.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Special coordinates \mbox{}\protect\\(e.g. polar coordinates)}
  \begin{minipage}{0.7\linewidth}
\begin{verbatim}
§\SpecialCoor§
\rput(2,3){
  \psline§(0.6;30)§(0,0)§(0.6;75)§
  \psarc(0,0){0.5}{30}{75}
  \rput[bl]§(0.6;52.5)§{$45^{\circ}$}
}
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.2\linewidth}
    \psset{unit=5\BaseUnit}
    \centerline{
      \begin{pspicture}(2,3)(3,4)
        \SpecialCoor
        \psgrid[unit=1.0]
        \rput(2,3){
          \psline(0.6;30)(0,0)(0.6;75)
          \psarc(0,0){0.5}{30}{75}
          \rput[bl](0.6;52.5){$45^{\circ}$}
        }
      \end{pspicture}}
  \end{minipage}
\end{slide}
Normally, points are specified in Cartesian coordinates written as a
\textbf{coma} separated pair inside of parenthesis. With the
\verb=\SpecialCoor= macro one can tell \PSTricks{} to recognise other
types of coordinates.

For an example polar coordinates are written as a pair of radius and
angle (in degrees) separated by a \textbf{semicolon}.

Polar coordinates are always given with respect to the current
origin. If needed one can move that origin first with the help of the
\verb=\rput= macro (that is done by the \verb=\rput(2,3)= on the slide).

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Special coordinates (postscript)}
  \begin{minipage}[t]{0.6\linewidth}
    \vspace*{1ex}
\newrgbcolor{brown}{8 8 0}
\begin{verbatim}
\Pt A(-1,0)\Pt B(-2,1)\Pt C(3,1)
°brown°% \Pt A(-1,0) -> \A=-1,0 \AX=-1 \AY=0°black°
\pspolygon[fillstyle=solid,fillcolor=yellow](\B)(\A)(\C)
§(!
  \BX\space \CX\space add \AX\space sub
  \BY\space \CY\space add \AY\space sub
)§
\end{verbatim}
  \end{minipage}
  \begin{minipage}[t][0.8\textheight]{0.3\linewidth}
    \centering
    \psset{unit=\psunit}
  \begin{pspicture}(-3,-1)(3,3)
    \psgrid[gridwidth=0.5\pslinewidth,
    subgridwidth=0.25\pslinewidth,
    gridcolor=green,
    subgridcolor=yellow]
    \SpecialCoor
    \def\Pt#1(#2,#3){
      \def\Def##1##2{\expandafter\def\csname##1\endcsname{##2}}
      \Def#1{#2,#3}%
      \Def{#1X}{#2}%
      \Def{#1Y}{#3}}
    \Pt A(-1,0)\Pt B(-2,1)\Pt C(3,1)
    \pnode(!
    \CX\space \BX\space add \AX\space sub
    \CY\space \BY\space add \AY\space sub
    ){D}
    \pspolygon[fillstyle=solid,fillcolor=yellow](\B)(\A)(\C)(D)
    \uput[-90](\A){A}
    \uput[0](\C){C}
    \uput[180](\B){B}
    \uput[90](D){B+C-A}
  \end{pspicture}
  \end{minipage}
\end{slide}
One can also use Postscript fragments to compute the Cartesian
coordinates of a point. This is determined by the exclamation
mark next to the left parenthesis. On the slide we use a Postscript
fragment to compute the fourth point of a parallelogram.

\verb=\Pt= is a self-made auxiliary macro to extract the coordinates
from a given pair (it assigns to an argument like \texttt{A(-1,0)} the
macros \verb=\A=, \verb=\AX= and \verb=\AY= as indicated in the
comment on the slide).

Note the \verb=\space= macros in the Postscript fragment. These expand
to spaces which are necessary because of \LaTeX{} eats all spaces
behind a macro name. With \verb/\BX=-1/ and \verb/\CX=3/ the sequence
`\verb/\BX \CX add/' would expand to `\verb/-13add/' instead of the
desired `\verb/-1 3 add/'.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Example for the usage of (LA)\TeX-commands}
    \begin{minipage}{0.6\linewidth}
\begin{verbatim}
§\newcommand\myPairs{(0.3,0.2)(0.7,1.0)%
                   (1.5,1.1)(1,0.3)}§
{\psset{linestyle=dotted,
        linewidth=1.5\pslinewidth}
  §\expandafter§\psline§\myPairs§
  §\expandafter§\psbezier§\myPairs§
}
\end{verbatim}
\end{minipage}
\begin{minipage}{0.3\linewidth}
  \psset{xunit=5\BaseUnit,yunit=4\BaseUnit}
  \begin{pspicture}(0.3,0.1)(1.5,1.2)
    \newcommand\Punkte{(0.3,0.2)(0.7,1.0)(1.5,1.1)(1,0.3)}
    {\psset{linestyle=dotted,
        linewidth=1.5\pslinewidth}
      \expandafter\psline\Punkte}
    \expandafter\psbezier\Punkte
  \end{pspicture}
\end{minipage}
\end{slide}
(This slide should probably be left out.)

In general \LaTeX{} macros can be used together with \PSTricks{}
macros. Thereby, one has to be careful with the argument expansion of
\PSTricks{} macros.

In the example on the slide a sequence of points is used twice and,
therefore, abbreviated by a macro \verb=\myPoints=. The \verb=\psline=
macro expects the coordinates of the polygon section points in
parenthesis. Therefore, we have to expand \verb=\myPairs= to
get the parenthesis before we may expand \verb=\psline=. An
\verb=\expandafter= before \verb=\psline= serves that purpose.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}[27cm,15cm]%
\section{Importing eps-files}
\rput(0.75\linewidth,-0.5\textheight){%
\includegraphics[width=0.7\linewidth]{graph1.eps}}%
\begin{verbatim}
\usepackage{§graphicx§}
...
\rput(7,-5){%
 §\includegraphics%
      [width=1\linewidth]%
      {graph1.eps}§%
}
\end{verbatim}
\end{slide}

No special macro is provided by \PSTricks{} to embed pictures into the
document. This is no problem at all since the \texttt{graphicx}
package already provides the \verb=\includegraphics= macro that is
very well suited for that purpose.

As shown on the slide the \verb=\rput= macro of \PSTricks{} can help
to place figures.  That picture had been created by the function
plotting program \texttt{gnuplot}. The labels \texttt{a,b,c,d} have
been placed by \texttt{gnuplot} with their center exactly at the
vertices of the domain of the plotted functions. That is relevant for
the next slide where we will see that \PSTricks{} is a good tool to
make certain modifications in embedded eps pictures.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}[27cm,15cm]%
    \section{Nodes and node connections}
    \vbox{
  \psfrag{a}[mc][mc]{\pnode{g1a}}%
  \psfrag{b}[mc][mc]{\pnode{g1b}}%
  \psfrag{c}[mc][mc]{\pnode{g1c}}%
  \psfrag{d}[mc][mc]{\pnode{g1d}}%
  \rput[mc](0.75\linewidth,-0.5\textheight){%
    \includegraphics[origin=tc,width=0.7\linewidth]{graph1.eps}}%
  \ncdiag[angle=-130,arm=2\BaseUnit,linearc=0.25\BaseUnit]{g1a}{g1b}\mput*{$\Omega$}%
  \ncdiag[angle=-130,arm=1\BaseUnit,linearc=0.25\BaseUnit]{g1c}{g1d}\mput*{$G_{\varepsilon}$}%
\begin{verbatim}
\usepackage{°blue°psfrag°black°,§pst-node§}
...
°blue°\psfrag°black°{a}[mc][mc]{§\pnode{NodeA}§}
°blue°\psfrag°black°{b}[mc][mc]{§\pnode{NodeB}§}
\includegraphics ...
§\ncdiag[angle=-130,
        arm=2cm,
        linearc=0.25cm]
   {NodeA}{NodeB}
\mput*§{$\Omega$}
\end{verbatim}}
\end{slide}
\vspace*{-1cm}
Nodes and Node connections are extremely useful tools of \PSTricks.

With the help of nodes one can refer to the position of 
\LaTeX{} objects (or better their Postscript representations) without
knowing their exact coordinates.

On the slide the \verb=\psfrag= macro of the package \verb=psfrag.sty=
has been used for replacing the labels \texttt{a,b,c,d} (see the
figure on the previous slide) with \texttt{pnode}s.  These nodes do
not have a geometrical extent (\texttt{pnode} stands for
`point~node'). They just make the label positions available to
\PSTricks{}.  The nodes created in that way can then be referred to by
the assigned node names \texttt{NodeA} and \texttt{NodeB}.

In the example on the slide the nodes NodeA and NodeB are connected by
a line (NodeC and NodeD are treated analogously). This connection has
been created by the \verb=\ncdiag= macro (\verb=\ncdiag= standing for
`node connect diagonal'). The \verb=\ncdiag= macro
draws arms of \texttt{arm=2cm} length in an angle of
\texttt{angle=-130} degrees starting from the nodes. The end points of
these arms are then connected by a straight line. The option
\texttt{linearc=0.25cm} smoothes out the resulting vertices at the arm
ends by small arcs.

The label $\Omega$ is placed in the middle of the node connection by
the \verb=\mput*= macro. The star form of \verb=\mput= is used to get
the white underlay of the label~$\Omega$.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{`Labeling' node connections}
  \begin{minipage}{0.6\linewidth}
\begin{verbatim}
\usepackage{§pstricks-add§}
...
§\cnodeput(2,1){cnA}{Circle A}§
\cnodeput(2.5,4){cnB}{Circle B}
§\nccurve§[§ArrowInside=->§,§ArrowInsidePos=0.25§,
  §angleA=40§,§angleB=-50§]{cnA}{cnB}
§\aput(0.25){§$W_{12}$§}§
§\lput{:0}{§
  \psline{->}(0,0)(1,0)
  §\uput[0]{*0}(1,0){§$\mathbf{t}$§}§
  \psline{->}(0,0)(0,-1)
  \uput[90]{*0}(0,-1){$\mathbf{n}$}§}§
\end{verbatim}
  \end{minipage}
  \psset{unit=2\BaseUnit,arrowsize=0.1 5}
  \begin{minipage}{0.3\linewidth}
    \begin{pspicture}(5,5)
      \cnodeput(2,1){cn1}{Circle A}
      \cnodeput(2.5,4){cn2}{Circle B}
      \nccurve[ArrowInside=->,
      ArrowInsidePos=0.25,
      angleA=40,
      angleB=-50]{cn1}{cn2}
      \lput{:0}{
        {
          \psline{->}(0,0)(1,0)
          \uput[0]{*0}(1,0){$\mathbf{t}$}
          \psline{->}(0,0)(0,-1)
          \uput[90]{*0}(0,-1){$\mathbf{n}$}
        }
      }
      \aput(0.25){$W_{12}$}
     %% \psgrid
    \end{pspicture}
  \end{minipage}
\end{slide}
\vspace*{-3.5cm}
There are many different types of nodes. On this slide 
\verb=\cnodeput= has been used to create two circle nodes with
inserted text.
The curve connecting the cycles is created by the \verb=\nccurve=
macro. The options \texttt{angleA=40, angleB=-50} determine the angles
at which the curve leaves the circle nodes.

\texttt{ArrowInside=->, ArrowInsidePos=0.25} are options that were added
to \PSTricks{} after the development of \PSTricks{} had been froze.
Such add-ons to \PSTricks{} are contained in \texttt{pstricks-add.sty}
which must be loaded separately.

With help of the \texttt{ArrowInside=->} option one can set an arrow
head anywhere on a curve. The place where to set the
arrow head is determined by the \texttt{ArrowInsidePos=0.25}
option. The curve is parameterised from 0 to 1 and the 0.25 tells
\PSTricks{} to set the arrow head at one quarter of the curve.

The \verb=\aput= macro is used to put the label `$W_{12}$' above the
curve at the curve parameter~$0.25$ given in parenthesis.


The \verb=\lput= macro is also intended for labelling. In the example
however, it serves to draw the local coordinate system with the
tangent vector $\mathbf{t}$ and the normal vector $\mathbf{n}$.  The
stuff to be placed is given in the second argument of \verb=\lput=.
The stuff is rotated by the angle in the first argument of
\verb=\lput=. The colon says that the angle is given in local polar
coordinates of the curve. That means the tangent of the curve has an
angle of 0 degrees.  That makes the task to draw the tangent and the
normal vector of the curve very easy.

The \verb=\uput= macro is used to label the vectors $\mathbf{t}$ and
$\mathbf{n}$. The angle in the brackets determines in which direction
the label is translated from the point given in parenthesis. The argument
in the first curly braces determines the angle by which the label is
rotated. The star indicates that the angle is measured with respect to
the global coordinate system. The value 0 leaves the labels
unrotated upright.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{More nodes and node connections}%
\vbox{\rput(0.85\textwidth,-0.5\textheight){
    \begin{minipage}{0.3\textwidth}
    \psset{nodesep=0.3\BaseUnit}
    \begin{equation*}
      \begin{array}{c@{\hspace{3\BaseUnit}}c}
        \Rnode{N1}{X} & \Rnode{N2}{\bigtimes\limits_{i\in I} Y_{i}}\\[3\BaseUnit]
        &\Rnode{N3}{Y_{j}}
      \end{array}
      \everypsbox{\scriptstyle}
      \ncLine{->}{N1}{N2}\Aput{f}
      \ncLine{->}{N1}{N3}\Bput{f_{j}=\pi_{j}\circ f}
      \ncLine{->}{N2}{N3}\Aput{\pi_{j}}
    \end{equation*}  
    \end{minipage}
  }%
\begin{verbatim}
\begin{equation*}
 \begin{array}{c@{\hspace{3cm}}c}
  §\Rnode{N1}{§X§}§ & \Rnode{N2}{
    \times\limits_{i\in I} Y_{i}}\\[3cm]
  &\Rnode{N3}{Y_{j}}
 \end{array}
 \psset{§nodesep§=0.3cm}
 §\everypsbox§{\scriptstyle}
 §\ncLine{->}{N1}{N2}\Aput{§f§}§
 \ncLine{->}{N1}{N3}§\Bput{§f_{j}=\pi_{j}\circ f§}§
 \ncLine{->}{N2}{N3}\Aput{\pi_{j}}
\end{equation*}
\end{verbatim}}
\end{slide}
Another important application of nodes and node connections is the
illustration of relationships as, for an example, the commutative
diagram on the slide.

The diagram is embedded into an \texttt{equation*} environment of
AMS-\LaTeX.  For node placing the \LaTeX{} native \texttt{array}
environment is used. That shows that nodes and node connections can be
used everywhere in a \LaTeX{} document. They are not restricted to
pspicture environments.

The \verb=\Rnode= macro puts a invisible rectangular node with the
name its first argument around the
stuff in its second argument. The arrows are drawn by the
\verb=\ncLine= commands. Labels are attached to the arrows by the
\verb=\Aput= and \verb=\Bput= commands.
\verb=\Aput= and \verb=\Bput= are variants of \verb=\aput= and
\verb=\bput= which use default values for the positioning of the
labels.

\verb=\ncLine= is a variant of \verb=\ncline= which takes care that
lines  connecting nodes on the same line are straight
horizontal independent of the size of the stuff inside the nodes.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{Node placement with psmatrix}
  \begin{minipage}{0.7\linewidth}
\begin{verbatim}
\begin{§psmatrix§}[§mnode=R,colsep=3cm,rowsep=3cm§]
 § X & \bigtimes\limits_{i\in I} Y_{i}\\
    &Y_{j}§
\end{§psmatrix§}
\psset{nodesep=0.3cm}
\everypsbox{\scriptstyle}
\ncLine{->}{§1,1§}{§1,2§}\Aput{f}
\ncLine{->}{1,1}{2,2}\Bput{f_{j}=\pi_{j}\circ f}
\ncLine{->}{1,2}{2,2}\Aput{\pi_{j}}
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.2\linewidth}
    \psset{nodesep=0.3\BaseUnit}
    \begin{equation*}
      \begin{psmatrix}[mnode=R,colsep=3\BaseUnit,rowsep=3\BaseUnit]
        X & \bigtimes\limits_{i\in I} Y_{i}\\
        &Y_{j}
      \end{psmatrix}
      \everypsbox{\scriptstyle}
      \ncLine{->}{1,1}{1,2}\Aput{f}
      \ncLine{->}{1,1}{2,2}\Bput{f_{j}=\pi_{j}\circ f}
      \ncLine{->}{1,2}{2,2}\Aput{\pi_{j}}
    \end{equation*}
  \end{minipage}
\end{slide}

The same commutative diagram as on the previous slide is created here
via the \texttt{psmatrix} environment of \PSTricks. This is an environment
especially designed for node placing.

About each entry of the \texttt{psmatrix} a node is set whose type is
determined by the \texttt{mnode} option of the \texttt{psmatrix}
environment (\texttt{mnode=R} stands for \verb=\Rnode=).

The \texttt{colsep} and \texttt{rowsep} options specify the distances
of the nodes.

The node labels of the \texttt{psmatrix} entries are automatically
generated as pairs of row and column numbers.

These labels can then be used with the \verb=\ncLine= macros.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \enlargethispage{1\BaseUnit}
  \section{Including postscript code in \textbackslash\texttt{pscustom}}
  \begin{minipage}{0.6\linewidth}
\begin{verbatim}
\pnode(0.0,-0.6){AA}
...
\pnode(1,4.1){DC}
\pscurve(AD)(AC)(AB)(AA)
...
§\pscustom[§fillcolor=yellow,fillstyle=solid§]{§
  \psline(BC)(BB)(CB)
  §\coor§(BC)(CB)
  §\code§{\AddPairs} % x1 y1 x2 y2 -> (x1+x2) (y1+y2)
  \coor(BB)
  \code{\SubPairs lineto}
 §\closepath}§
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.3\linewidth}
    \psset{unit=1\BaseUnit}
    \begin{pspicture}(-1.5,-5)(1,2)
    \SpecialCoor
    %% Makro zur Speicherung der Gitterpunkte:
    \def\pt#1(#2){\def#1{#2}}
    %% Hilfsmakro der Koordinaten:
    \def\ptx(#1,#2){#1}
    \def\pty(#1,#2){#2}
    %% Makro zur Ermittlung der Koordinaten in postscript-Makros:
    \def\eptx#1{\expandafter\ptx\expandafter(#1)}
    \def\epty#1{\expandafter\pty\expandafter(#1)}
    %% Die gekr"ummte Fl"ache A im Raum:
    %% Zun"achst die Definition der Punkte der
    %% gekr"ummten Fl"ache:
    \def\pn(#1)#2{\pnode(#1){#2}\uput*[90](#1){#2}}
    \pn(0.0,-0.6){AA}\pn(-1.2,1.0){AB}\pn(-3.0,1.7){AC}\pn(-4.5,1.2){AD}
    \pn(1.5,1.2){BA}\pn(0.0,2.6){BB}\pn(-2.1,3.0){BC}\pn(-3.6,2.9){BD}
    \pn(3.0,1.7){CA}\pn(1.0,3.5){CB}\pn(-0.2,4.0){CC}\pn(-1.5,4.0){CD}
    \pn(4.5,1.7){DA}\pn(3.0,3.5){DB}\pn(1.0,4.1){DC}
    %% Alle Kurven der gekr"ummten Fl"ache, bis auf zwei, die
    %% oberhalb des Parallelogramms liegen:
    \pscurve(AD)(AC)(AB)(AA)
    \pscurve(CD)(CC)(CB)(CA)
    \pscurve(AA)(BA)(CA)(DA)
    \pscurve(AC)(BC)(CC)(DC)
    \pscurve(AD)(BD)(CD)(DC)(DB)(DA)
    %% Parallelogramm:
    %% Der vierte Punkt wird aus den drei anderen
    %% berechnet.
    \pscustom[fillcolor=yellow,fillstyle=solid]{
      \psline(BC)(BB)(CB)
      \coor(BC)(CB)
      \code{\AddPairs} % x1 y1 x2 y2 -> (x1+x2) (y1+y2)
      \coor(BB)
      \code{\SubPairs lineto}
      \closepath
    }
    \psline[showpoints=true](CB)(BB)(BC)
    %% Die zwei oberhalb des Parallelogramms liegenden Kurven:
    \pscurve(BD)(BC)(BB)(BA)
    \pscurve(AB)(BB)(CB)(DB)
  \end{pspicture}
\end{minipage}
\end{slide}
\vspace*{-3.5cm}
We have already seen an example where the fourth point of a
parallelogram has been computed by a Postscript fragment.
There the coordinates of the points had been defined as \LaTeX{}
macros \verb=\AX,\AY,\BX,\BY,\CX,\CY=. The situation is a bit
different when the points are defined as nodes.

The coordinates of nodes are not already known during the \LaTeX{} run
but only when the Postscript file is interpreted.

In the example on the slide nodes are used to draw the curved surface
and the parallelogram has to be computed depending on these nodes.

Inside the \texttt{pscustom} environment (which we have already used
to construct Postscript paths) there are some additional macros
available which are in a certain sense `closer' to the postscript interpreter.

The \verb=\coor= macro allows to insert\footnote{More exactly,
  postscript code is inserted which computes the coordinates.} the
coordinate pairs of the points given as its arguments into the
  Postscript file. Thereby, the points can be specified in any
  admissible way of \PSTricks{}, especially as nodes, too.

The \verb=\code= macro allows to insert Postscript code
fragments. Such fragments do the calculations in the example. They are
abbreviated as macros \verb=\AddPairs= and \verb=\SubPairs=. The
definitions of these macros are given on the next slide.

The last Postscript fragment is finished with a \texttt{lineto}
command which draws the line from node \texttt{CB} to the just
computed point. The special command \verb=\closepath= is used to close
the parallelogram (The line from the computed point to the node
\texttt{BC} is automatically added).

The \verb=\pscustom= macro takes care of stroking and filling the path
corresponding the the chosen options.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}
  \section{The corresponding postscript codes}
\begin{verbatim}
  %% x1 y1 x2 y2 -> (x1+x2) (y1+y2)
  \def§\AddPairs§{ exch 4 1 roll add 3 1 roll add exch }

  %% x1 y1 x2 y2 -> (x1-x2) (y1-y2)
  \def§\SubPairs§{ exch 4 1 roll sub 3 1 roll exch sub exch }
\end{verbatim}
\end{slide}
These are just the Postscript fragments of the previous example.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}[25cm,16cm]
  \section{ps4pdf: Preparing the \LaTeX-file}
\begin{verbatim}
\documentclass{article}
\usepackage{hyperref,°blue°graphicx°blue°,§ps4pdf§}
§\PSforPDF{§°lightred°\usepackage{pstricks,pst-plot}§}§
\begin{document}
\title{Example for the usage of ps4pdf}\maketitle\centering
§\PSforPDF{§°lightred°
  \begin{pspicture}(-5,-5)(5,5)
    \rput(0,0){\psovalbox{That would be some complicated graphic.}}
  \end{pspicture}
§}%% End of PSforPDF.§
\par\hypertarget{Target}{That's the target.}
\newpage
\hyperlink{Target}{That's the link.}
\end{document}
\end{verbatim}
\end{slide}
\PSTricks{} produces Postscript fragments which are inserted into the
final Postscript file.
That means, that \LaTeX{} files with \PSTricks{} macros cannot directly be
translated by \texttt{pdflatex}.
On the other side some \LaTeX{} features are only available by
\texttt{pdflatex}.

The package \texttt{ps4pdf} makes it possible to translate \LaTeX{}
files with \PSTricks{} macros via \texttt{pdflatex}.

For the usage of \texttt{ps4pdf} the packages \texttt{graphicx} and
\texttt{ps4pdf} must be loaded and all \PSTricks{} relevant parts of
the document must be encapsulated as arguments of the \verb=\PSforPDF=
macro as shown in the example on the slide.

The next slide explains how to use the \LaTeX{} file with
\texttt{pdflatex}.

\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{slide}[25cm,15cm]
  \section{ps4pdf: pstricks \& pdflatex}
  CTAN: /tex-archive/macros/latex/contrib/ps4pdf/ps4pdf.sty\\
  (needs graphicx, preview, ifpdf, and ifvtex)\\
  \let\b=\psframebox
  \psset{shortput=tablr}
  \vfill

  \begin{psmatrix}[mnode=R,colsep=2\BaseUnit]
          & \b{foo.dvi} &[colsep=2.5\BaseUnit]\b{foo.ps} &[colsep=3\BaseUnit] \b{foo-pics.pdf} & \\
  \b{foo.tex} &         &        &  & \b{foo.pdf}
  \end{psmatrix}
  \psset{arrowsize=3pt 2,arrowinset=0}
  \ncline{->}{2,1}{1,2}\Aput{latex}
  \ncline{->}{1,2}{1,3}\aput(0.45){dvips}
  \ncline{->}{1,3}{1,4}\aput(0.45){ps2pdf}
  \ncline{->}{2,1}{2,4}
  \ncline{->}{2,1}{2,5}\aput(0.9){pdflatex}\aput[0](0.8){\pnode{nodePDF}}
  \nccurve[angleA=-90,angleB=180,ncurvA=0.9,ncurvB=1]{->}{1,4}{nodePDF}
\end{slide}

Translating a \LaTeX{} file \texttt{foo.tex} with \PSTricks{} macros
via \texttt{pdflatex} is a two path process which is shown on the
slide.

In the first path (the upper path on the slide) exclusively the pictures
are created in a Postscript file and translated into a PDF file via
\texttt{ps2pdf}. The resulting PDF file should be named
\texttt{foo-pics.pdf}.

In the second path \texttt{foo.tex} is translated with
\texttt{pdflatex} into \texttt{foo.pdf}. On this path the pictures
from \texttt{foo-pics.pdf} are included into the PDF file.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{random}
\newdimen\RandColorR
\newdimen\RandColorB
\newdimen\Xdim
\begin{slide}
  \section{Other nice stuff -- fillstyle=gradient}
  \begin{minipage}{0.6\linewidth}
\begin{verbatim}
\usepackage{§pst-grad§}
...
\begin{psclip}{
  \psframe[linestyle=none,
    §fillstyle=gradient,
    gradbegin=white,gradend=blue,
    gradmidpoint=1,
    gradangle=-45§](0,0)(5,5)
  }
 ... other stuff ...
\end{psclip}
\end{verbatim}
  \end{minipage}
  \begin{minipage}{0.3\linewidth}
    \centering
    \begin{pspicture}(5,5)
      \psclip{
        \newrgbcolor{gradbegin}{1 1 0.8}
        \newrgbcolor{gradend}{0 0 1}
        \psframe[linestyle=none,
        fillstyle=gradient,
        gradbegin=white,gradend=blue,
        gradmidpoint=1,
        gradangle=-45](0,0)(5,5)
      }
      \pscircle*[linecolor=yellow](6,6){3}
      \psccurve[fillstyle=gradient,gradbegin=green,gradend=brown](5,2)(2.5,1.5)(0.5,-1)
      (5,-2)(9.5,-1)
      \pscurve[fillstyle=solid,fillcolor=brown](4.5,0)(2.5,1.5)(0,2)(-3.5,0)(0,-5)
      \multido{\ny=1.0+-0.25,\ns=0.5+0.1,\nxx=0+0.2}{5}{
        \multido{\nx=0+0.3}{10}{
          \setrandim\RandColorR{0pt}{1pt}
          \setrandim\RandColorB{0pt}{1pt}
          \newrgbcolor{c}{{\pointless\RandColorR} 1.0 {\pointless\RandColorB}}
          \pssetlength{\Xdim}{\nx}\psaddtolength{\Xdim}{\nxx}
          \rput(\Xdim,\ny){
            \scalebox{\ns \ns}{
              \pspolygon[fillcolor=lightbrown,fillstyle=solid](-0.1,0)(-0.05,0.25)(0.05,0.25)(0.1,0)
              \psellipse[fillcolor=c,fillstyle=solid](0,0.6)(0.2,0.4)
        }}}}
  \endpsclip  
\end{pspicture}
\end{minipage}
\end{slide}
At the end of the presentation there are two slides left with some nice
funny features of \PSTricks.

The package \texttt{pst-grad} provides a new fill style named
\texttt{gradient}.
This fillstyle allows continuous transitions from one color to another
one. The start color and end the color can be set via the options
\texttt{gradbegin} and \texttt{gradend}. These options can also be set
like a color definition, e.\,g.,\\ % this comment protects \verb from linebreak
\verb=\newrgbcolor{gradbegin}{0.1 0.2 0.3}=\\
where 0.1, 0.2, and 0.3 are the red, the green and the blue color
value, resp.

The option \texttt{gradangle} determines the direction in which the
color keeps constant.

The region to be filled is parameterised by values from 0 to 1.
The parameter value set by the \texttt{gradmidpoint} option determines
where the color \texttt{gradend} is taken on. For an example with
\texttt{gradmidpoint=1} the color \texttt{gradend} is taken on at the
end of the filled region, e.\,g.
\psset{gradbegin=white,gradend=blue,fillstyle=gradient,gradangle=-90}
\pspicture(0,0)(5ex,1ex)\psframe[gradmidpoint=1](0,0)(5ex,1ex)\endpspicture,
and for the setting \texttt{gradmidpoint=0.5} the color is taken on in
the middle of the filled region, e.\,g.
\pspicture(0,0)(5ex,1ex)\psframe[gradmidpoint=0.5](0,0)(5ex,1ex)\endpspicture.


\newpage
\begin{slide}[27cm,15cm]
  \section{Other nice stuff -- Playing with Text}
  \begin{minipage}{0.45\linewidth}
\begin{verbatim}
\usepackage{§pst-text§,§pst-char§,°blue°ae°black°}
...
§\pstextpath(0,-3ex){§\psellipse(0,0)(3,2)§}{§
  \multido{}{6}{ PS\LaTeX{}}§}§
\psset{fillstyle=gradient,gradbegin=red,gradend=blue}
\rput(0,0){§\pscharpath{§\fontsize{1.3cm}{1.3cm}\selectfont\LaTeX§}§}
\end{verbatim}
  \end{minipage}
  \psset{unit=1\BaseUnit}
  \begin{minipage}{0.45\linewidth}
  \begin{pspicture}(-5,-5)(5,5)
    \rput(3,3){
    \psset{fillstyle=solid,fillcolor=yellow}
    \pstextpath(0,-3ex){\psellipse(0,0)(3,2)}
    {\multido{}{6}{ PS\LaTeX{}}}
    \psset{fillstyle=gradient,gradbegin=red,gradend=blue}
    \rput(0,0){\pscharpath{\fontsize{2\BaseUnit}{2\BaseUnit}\selectfont\LaTeX}}
%%    \psgrid
    }
  \end{pspicture}
\end{minipage}
\end{slide}
\mbox{}\vskip-2cm
The \texttt{pst-text} style provides the macro \verb=\pstextpath=.
This macro serves to set text along a curve. The first argument (given
in parenthesis) is the position of the first text from the start of
the curve the second argument defines the curve and the third one is
the text to be set along the curve.

The package \texttt{pst-char} provides the macro \verb=\pscharpath=.
With the help of \verb=\pscharpath= one can transform the outline of a
letter into an ordinary Postscript path. This Postscript path can then
be used in the same way as a postscript path created by commands like
\verb=\psframe= or \verb=\pspolygon=. In the example it has been used
to dye the string \LaTeX{} with \texttt{fillstyle=gradient}.

The path of characters can only be extracted for outline fonts.
Therefore, you have to load some package which provides an outline
font. In the example on the slide the package \texttt{ae} is used for
that reason.
\\[0.5cm]
That is it for today. Hope you had some fun,\\
Tobias N\"{a}hring\\[0.5cm]
PS: My english not so good. If you find some errors please let me know.
My email-address is:
%% A bit encryption for robots:
\psset{fillcolor=black,fillstyle=solid,linewidth=0.1pt}\texttt{i\pscharpath{@}tn\pscharpath{-}home.de}.\\[1ex]
Thanks to Dominic Hughes (Stanford University) for correcting some spellings.
\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% write-contents-hooks: nil
%%% after-save-local-hook: nil
%%% End: 

