%% -*-TeX-*-
 % ###################################################################
 % 
 %  FILE: "pgfmoreex.tex"
 %                                    created: 2004-03-05 09:39:03 
 %                                last update: 2004-03-17 17:15:22 
 %  Author: Frédéric Boulanger
 %  E-mail: Frederic.Boulanger@supelec.fr
 %    mail: Supélec - Service Informatique
 %          3 rue Joliot-Curie, 91192 Gif-sur-Yvette cedex, France
 %     www: http://wwwsi.supelec.fr/fb/
 %  
 %  Description: 
 % 
 %  History
 % 
 %  modified   by  rev reason
 %  ---------- --- --- -----------
 %  2004-03-05 FBO 1.0 original
 % ###################################################################
 %%
\documentclass[a4paper]{article}
\usepackage[nohead,top=1cm,bottom=1.5cm,left=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage[%
  pdfauthor={Fr\'ed\'eric Boulanger},
  pdftitle={pgfmore package}
]{hyperref}

\usepackage{pgfmore}
\usepackage{pgfarrows}

\setlength{\parindent}{0pt}

\newlength{\expiclength}
\setlength{\expiclength}{0.3\linewidth}

\newenvironment{verbatimbox}{%
  \minipage[b]{0.7\linewidth}%
  \verbatim
}{%
  \endverbatim
  \endminipage
}

\newcommand{\exampleskip}{%
  \par\smallskip
  \par\hrulefill
  \nopagebreak\par
  \nopagebreak\bigskip\nopagebreak\par
}

\newcommand{\cmd}[1]{\texttt{\textbackslash#1}}
\newcommand{\uarg}[1]{\textit{#1}}
\newcommand{\carg}[1]{\texttt{\{}\uarg{#1}\texttt{\}}}
\newcommand{\coarg}[1]{\texttt{[}\uarg{#1}\texttt{]}}
\newcommand{\farg}[1]{\uarg{<#1>}}

\newsavebox{\cmdbox}
\newenvironment{command}{%
  \par\smallskip
  \begin{lrbox}{\cmdbox}
    \addtolength{\linewidth}{-2\leftmargin}
    \begin{minipage}{\linewidth}
}{%
    \end{minipage}
  \end{lrbox}
  \hspace{\leftmargin}\fbox{\usebox{\cmdbox}}
  \par\smallskip
}

\title{The \textsf{pgfmore} package}
\author{Fr\'ed\'eric Boulanger\\
        \href{Frederic.Boulanger@supelec.fr}%
        {\textsf{\small Frederic.Boulanger@supelec.fr}}}

\begin{document}

\maketitle
\section{Introduction}
\textsf{pgfmore} is a \LaTeX{} package that adds support for distinct
fill, stroke and text colors to the excellent \textsf{pgf} package. It
also makes arguments between square brackets really optional and node
definitions global (even inside a pgfscope environment).

\textsf{pgfmore} defines new commands to ease the use of nodes: you
can draw bows between nodes or loops on a node, put labels on them and
so on. Everything in \textsf{pgfmore} relies on \textsf{pgf} only (and
on a standard \LaTeX{} installation).

This is not really a documentation (look at the comments in the source 
code for details), but a kind of ``show room'' for \textsf{pgfmore}.


\section{Unit length commands}

The three following commands allow to set the length unit for PGF 
pictures. \cmd{pgfsetxunit} sets the unit for the horizontal axis, 
\cmd{pgfsetyunit} sets the unit for the vertical axis, and 
\cmd{pgfsetunit} sets both PGF units.

\begin{command}
  \cmd{pgfsetunit}\carg{length}
  
  set both horizontal and vertical unit lengths to \uarg{length}
\end{command}
  
\begin{command}
  \cmd{pgfsetxunit}\carg{length}
  
  set the horizontal unit length to \uarg{length}
\end{command}
  
\begin{command}
  \cmd{pgfsetyunit}\carg{length}
  
  set the vertical unit length to \uarg{length}
\end{command}

\exampleskip
\begin{verbatimbox}
  \pgfsetxunit{1cm}
  \pgfsetyunit{2cm}
  \pgfrect{\pgfxy(0,0)}{\pgfxy(1,1)}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{0pt}{\expiclength}{2cm}
  \pgfsetxunit{1cm}
  \pgfsetyunit{2cm}
  \pgfrect{\pgfxy(0,0)}{\pgfxy(1,1)}
\end{pgfpicture}

\exampleskip

\begin{verbatimbox}
  \pgfsetxunit{2cm}
  \pgfsetyunit{1cm}
  \pgfrect{\pgfxy(0,0)}{\pgfxy(1,1)}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{0pt}{\expiclength}{2cm}
  \pgfsetxunit{2cm}
  \pgfsetyunit{1cm}
  \pgfrect{\pgfxy(0,0)}{\pgfxy(1,1)}
\end{pgfpicture}

\exampleskip

\begin{verbatimbox}
  \pgfsetunit{1cm}
  \pgfrect{\pgfxy(0,0)}{\pgfxy(2,2)}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{0pt}{\expiclength}{2cm}
  \pgfsetunit{1cm}
  \pgfrect{\pgfxy(0,0)}{\pgfxy(2,2)}
\end{pgfpicture}
\exampleskip

% \exampleskip
\section{Colors}
\textsf{pgfmore} defines four colors: the stroke color is used for 
the ``pen'' color when drawing paths, the fill color is used when 
filling figures, the text color is used for text strings, and the back 
colour is used for text background. \cmd{pgfsetcolor} allows to set 
one of these colors. After the name of the color to set, 
\cmd{pgfsetcolor} accepts any color specification that the \textsf{color} 
package accepts.

\begin{command}
  \cmd{pgfsetcolor}\carg{type}\farg{color spec}
  
  set \textsf{pgfmore}'s \uarg{type} color to \farg{color spec}.
\end{command}

\exampleskip
\pgfsetunit{1cm}
\begin{verbatimbox}
  \pgfsetcolor{stroke}{blue}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{red}
  \pgfsetcolor{back}{yellow}
  \pgfsetlinewidth{0.5mm}
  \pgfrect[fillstroke]{\pgfxy(0,0)}{\pgfxy(2,2)}
  \pgfputat{\pgfxy(1,1)}{\pgfbox{Test}[opaque]}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{0pt}{\expiclength}{2cm}
  \pgfsetcolor{stroke}{blue}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{red}
  \pgfsetcolor{back}{yellow}
  \pgfsetlinewidth{0.5mm}
  \pgfrect[fillstroke]{\pgfxy(0,0)}{\pgfxy(2,2)}
  \pgfputat{\pgfxy(1,1)}{\pgfbox{Test}[opaque]}
  %
  {\pgfsetcolor{fill}{green}\pgfcircle[fill]{\pgfxy(1,1)}{0.3mm}}%
  %
\end{pgfpicture}

\smallskip
where the green dot shows the postion of the \((1,1)\) point.

\exampleskip

\pgfsetunit{1cm}
\begin{verbatimbox}
  \pgfsetcolor{stroke}[rgb]{0.1,0.6,0.4}
  \pgfsetcolor{fill}[gray]{0.5}
  \pgfsetcolor{text}[cmyk]{0.1,0.2,0.6,0.0}
  \pgfsetlinewidth{0.5mm}
  \pgfrect[fillstroke]{\pgfxy(0,0)}{\pgfxy(2,2)}
  \pgfputat{\pgfxy(1,1)}{\pgfbox[center,center]{Test}}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{0pt}{\expiclength}{2cm}
  \pgfsetcolor{stroke}[rgb]{0.1,0.6,0.4}
  \pgfsetcolor{fill}[gray]{0.5}
  \pgfsetcolor{text}[cmyk]{0.1,0.2,0.6,0.0}
  \pgfsetlinewidth{0.5mm}
  \pgfrect[fillstroke]{\pgfxy(0,0)}{\pgfxy(2,2)}
  \pgfputat{\pgfxy(1,1)}{\pgfbox[center,center]{Test}}
  %
  {\pgfsetcolor{fill}{green}\pgfcircle[fill]{\pgfxy(1,1)}{0.3mm}}%
  %
\end{pgfpicture}

\smallskip
where the green dot shows the postion of the \((1,1)\) point.

\exampleskip

\section{Polygons}
\cmd{pgfxypolyline} builds a path that connects points with straight 
lines. According to the first optional argument, the line is just 
added to the current path (virtual), stroked (stroke), filled (after 
closing the current path, fill), or stroked and then filled (fillstroke).

\begin{command}
  \cmd{pgfxypolyline}\coarg{mode}\carg{coordinate list}
  
  build a broken line through all the points in \uarg{coordinate list} 
  and stroke and or fill it according to \uarg{mode}.
\end{command}

\exampleskip
\pgfsetunit{1cm}
\begin{verbatimbox}
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetlinewidth{0.5mm}
  \pgfxypolyline{(0,0)(0.5,1)(1,0.5)(1.5,2)(2,0.5)}
  \pgfxypolyline[fill]{(0,2)(0.2,1.6)(0.5,1.8)
                       (0.8,1.6)(1,2)(0.5,1.82)}
  \pgfxypolyline[virtual]{(1.2,0)(1.1,0.3)(1.2,0.5)
                          (1.5,0.5)(1.8,0.5)(1.9,0.3)(1.8,0)}
  \pgfclosepath\pgffillstroke
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{0pt}{\expiclength}{2cm}
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetlinewidth{0.5mm}
  \pgfxypolyline{(0,0)(0.5,1)(1,0.5)(1.5,2)(2,0.5)}
  \pgfxypolyline[fill]{(0,2)(0.2,1.6)(0.5,1.8)
                       (0.8,1.6)(1,2)(0.5,1.82)}
  \pgfxypolyline[virtual]{(1.2,0)(1.1,0.3)(1.2,0.5)
                          (1.5,0.5)(1.8,0.5)(1.9,0.3)(1.8,0)}
  \pgfclosepath\pgffillstroke
  %
  {%
    \pgfsetlinewidth{0.2mm}\pgfsetcolor{stroke}{green}
    \pgfsetendarrow{\pgfarrowsingle}
    \pgfxycurve(-3.8,2.2)(-2,2.2)(-0.5,1.3)(1,1.2)
    \pgfxycurve(-4.6,1.6)(-2,1.6)(-1.5,2.0)(-0.2,1.8)
    \pgfxycurve(-3.5,0.75)(-0.8,1.0)(-0.9,-0.7)(0.85,0.0)
  }%
\end{pgfpicture}

\smallskip
the green arrows show the result of the \cmd{pgfxypolyline} commands.

\exampleskip

\section{Node commands}
\textsf{pgfmore} redefines node commands so that their optional argument 
defaults to ``stroke''. A new \cmd{pgfnodetext} command associates 
text to a node. This text is drawn on a background rectangle (its 
color is the ``back'' PGF color) if the ``opaque'' parameter is present. 
The text is drawn in the ``text'' PGF color.

\begin{command}
  \cmd{pgfnodetext}\carg{node name}\carg{text}\coarg{\ttfamily opaque}
  
  associate \uarg{text} to node \uarg{node name}. Draw the text in an 
  opaque box if \coarg{\ttfamily opaque} is present.
\end{command}

\exampleskip
\pgfsetunit{4cm}
\begin{verbatimbox}
  \footnotesize\sffamily
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{blue}
  \pgfsetcolor{back}[gray]{0.9}
  \pgfsetlinewidth{0.25mm}
  \pgfnodecircle{00}[fillstroke]{\pgfxy(0,0)}{5mm}
  \pgfnodetext{00}{(0,0)}
  \pgfnodecircle{01}[virtual]{\pgfxy(0,1)}{5mm}
  \pgfnodetext{01}{(0,1)}
  \pgfnodecircle{10}[stroke]{\pgfxy(1,0)}{5mm}
  \pgfnodetext{10}{(1,0)}
  \pgfnoderect{11}[fill]{\pgfxy(1,1)}{\pgfpoint{1cm}{1cm}}
  \pgfnodetext{11}{(1,1)}[opaque]
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{-0.5cm}{\expiclength}{5cm}
  \footnotesize\sffamily
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{blue}
  \pgfsetcolor{back}[gray]{0.9}
  \pgfsetlinewidth{0.25mm}
  \pgfnodecircle{00}[fillstroke]{\pgfxy(0,0)}{5mm}
  \pgfnodetext{00}{(0,0)}
  \pgfnodecircle{01}[virtual]{\pgfxy(0,1)}{5mm}
  \pgfnodetext{01}{(0,1)}
  \pgfnodecircle{10}[stroke]{\pgfxy(1,0)}{5mm}
  \pgfnodetext{10}{(1,0)}
  \pgfnoderect{11}[fill]{\pgfxy(1,1)}{\pgfpoint{1cm}{1cm}}
  \pgfnodetext{11}{(1,1)}[opaque]
\end{pgfpicture}

\exampleskip

\cmd{pgfbordernodetext} puts text at the border of a node. The text 
position is specified as a geographical direction from the position of 
the node. The text is drawn on a rectangular box if the ``options'' 
parameter contains ``o''. The text is rotated to be perpendicular to 
the direction if the ``options'' parameter contains ``r''.

\begin{command}
  \cmd{pgfbordernodetext}\coarg{offset}\carg{node name}%
                         \carg{direction}\coarg{options}\carg{text}
  
  draw \uarg{text} at the \uarg{direction} border of node \uarg{node
  name}. A positive \uarg{offset} puts the text farther from the
  center of the node. The text in drawn over an opaque box if 
  \uarg{options} contains \texttt{o}, it is drawn perpendicularly to 
  \uarg{direction} if \uarg{options} contains \texttt{r}.
\end{command}

\exampleskip
\pgfsetunit{4cm}
\begin{verbatimbox}
  [...]
  \pgfbordernodetext{00}{north}[or]{N}
  \pgfbordernodetext[3mm]{00}{nw}[r]{NW}
  \pgfbordernodetext{00}{west}[or]{W}
  \pgfbordernodetext[3mm]{00}{sw}[r]{SW}
  [...]
  \pgfbordernodetext[-1mm]{01}{north}{N}
  \pgfbordernodetext[1mm]{01}{nw}{NW}
  \pgfbordernodetext[2mm]{01}{west}{W}
  \pgfbordernodetext[3mm]{01}{sw}{SW}
  \pgfbordernodetext[3.5mm]{01}{south}{S}
  \pgfbordernodetext[4mm]{01}{se}{SE}
  \pgfbordernodetext[5mm]{01}{east}{E}
  \pgfbordernodetext[6mm]{01}{ne}{NE}
  %
  \pgfbordernodetext[3mm]{10}{north}[r]{N}
  [...]
  \pgfbordernodetext[3mm]{10}{ne}[r]{NE}
  %
  \pgfbordernodetext[3mm]{11}{north}{N}
  [...]
  \pgfbordernodetext[3mm]{11}{ne}{NE}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{-1cm}{\expiclength}{6cm}
  \footnotesize\sffamily
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{blue}
  \pgfsetcolor{back}[gray]{0.9}
  \pgfsetlinewidth{0.25mm}
  \pgfnodecircle{00}[fillstroke]{\pgfxy(0,0)}{5mm}
  \pgfnodetext{00}{(0,0)}
  \pgfnodecircle{01}[virtual]{\pgfxy(0,1)}{5mm}
  \pgfnodetext{01}{(0,1)}
  \pgfnodecircle{10}[stroke]{\pgfxy(1,0)}{5mm}
  \pgfnodetext{10}{(1,0)}
  \pgfnoderect{11}[fill]{\pgfxy(1,1)}{\pgfpoint{1cm}{1cm}}
  \pgfnodetext{11}{(1,1)}[opaque]
  %
  \pgfbordernodetext{00}{north}[or]{N}
  \pgfbordernodetext[3mm]{00}{nw}[r]{NW}
  \pgfbordernodetext{00}{west}[or]{W}
  \pgfbordernodetext[3mm]{00}{sw}[r]{SW}
  \pgfbordernodetext{00}{south}[or]{S}
  \pgfbordernodetext[3mm]{00}{se}[r]{SE}
  \pgfbordernodetext{00}{east}[or]{E}
  \pgfbordernodetext[3mm]{00}{ne}[r]{NE}
  %
  \pgfbordernodetext[-1mm]{01}{north}{N}
  \pgfbordernodetext[1mm]{01}{nw}{NW}
  \pgfbordernodetext[2mm]{01}{west}{W}
  \pgfbordernodetext[3mm]{01}{sw}{SW}
  \pgfbordernodetext[3.5mm]{01}{south}{S}
  \pgfbordernodetext[4mm]{01}{se}{SE}
  \pgfbordernodetext[5mm]{01}{east}{E}
  \pgfbordernodetext[6mm]{01}{ne}{NE}
  %
  \pgfbordernodetext[3mm]{10}{north}[r]{N}
  \pgfbordernodetext[3mm]{10}{nw}[r]{NW}
  \pgfbordernodetext[3mm]{10}{west}[r]{W}
  \pgfbordernodetext[3mm]{10}{sw}[r]{SW}
  \pgfbordernodetext[3mm]{10}{south}[r]{S}
  \pgfbordernodetext[3mm]{10}{se}[r]{SE}
  \pgfbordernodetext[3mm]{10}{east}[r]{E}
  \pgfbordernodetext[3mm]{10}{ne}[r]{NE}
  %
  \pgfbordernodetext[3mm]{11}{north}{N}
  \pgfbordernodetext[3mm]{11}{nw}{NW}
  \pgfbordernodetext[3mm]{11}{west}{W}
  \pgfbordernodetext[3mm]{11}{sw}{SW}
  \pgfbordernodetext[3mm]{11}{south}{S}
  \pgfbordernodetext[3mm]{11}{se}{SE}
  \pgfbordernodetext[3mm]{11}{east}{E}
  \pgfbordernodetext[3mm]{11}{ne}{NE}
\end{pgfpicture}

\exampleskip

\section{Connection labels}
\cmd{pgfedgelabel} puts a label on a straight connexion between two 
nodes. With ``o'' in the ``options'' parameters, the text is drawn on a 
rectangle filled with the back PGF color. With the ``r'' option, the 
text is rotated to be aligned with the edge between the nodes. The 
second optional parameter (between the node names) gives the fraction 
of the way between the two nodes at which the label will be put.

\begin{command}
  \cmd{pgfedgelabel}\coarg{options}\carg{node 1}%
      \coarg{fraction}\carg{node 2}\coarg{offset}\carg{text}
  
  draw \uarg{text} as the label of an edge between nodes \uarg{node 1}
  and \uarg{node 2}. The center of the text is put halfway between the
  nodes unless \uarg{fraction} specifies another place. The text is
  drawn over an opaque box if \uarg{options} contains \texttt{o}, it
  is drawn in the direction of the edge if \uarg{options} contains
  \texttt{r}.
\end{command}

\exampleskip
\pgfsetunit{4cm}
\begin{verbatimbox}
  [...]
  \small
  \pgfsetcolor{back}{white}
  \pgfsetendarrow{\pgfarrowsingle}
  \pgfnodeconnline{00}{10}
  \pgfedgelabel{00}{10}[1.5ex]{\(a_{2}\)}
  \pgfedgelabel{00}[0.2]{10}{\(a_{1}\)}
  \pgfedgelabel[o]{00}[0.8]{10}{\(a_{3}\)}
  \pgfnodeconnline{00}{11}
  \pgfedgelabel[o]{00}{11}{\(b_{2}\)}
  \pgfedgelabel[r]{00}[0.2]{11}[-1.5ex]{\(b_{1}\)}
  \pgfedgelabel[or]{00}[0.8]{11}{\(b_{3}\)}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{-0.5cm}{\expiclength}{5cm}
  \footnotesize\sffamily
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{blue}
  \pgfsetcolor{back}[gray]{0.9}
  \pgfsetlinewidth{0.25mm}
  \pgfnodecircle{00}[fillstroke]{\pgfxy(0,0)}{5mm}
  \pgfnodetext{00}{(0,0)}
  \pgfnodecircle{01}[virtual]{\pgfxy(0,1)}{5mm}
  \pgfnodetext{01}{(0,1)}
  \pgfnodecircle{10}[stroke]{\pgfxy(1,0)}{5mm}
  \pgfnodetext{10}{(1,0)}
  \pgfnoderect{11}[fill]{\pgfxy(1,1)}{\pgfpoint{1cm}{1cm}}
  \pgfnodetext{11}{(1,1)}[opaque]
  %
  \small
  \pgfsetcolor{back}{white}
  \pgfsetendarrow{\pgfarrowsingle}
  \pgfnodeconnline{00}{10}
  \pgfedgelabel{00}{10}[1.5ex]{\(a_{2}\)}
  \pgfedgelabel{00}[0.2]{10}{\(a_{1}\)}
  \pgfedgelabel[o]{00}[0.8]{10}{\(a_{3}\)}
  \pgfnodeconnline{00}{11}
  \pgfedgelabel[o]{00}{11}{\(b_{2}\)}
  \pgfedgelabel[r]{00}[0.2]{11}[-1.5ex]{\(b_{1}\)}
  \pgfedgelabel[or]{00}[0.8]{11}{\(b_{3}\)}
\end{pgfpicture}

\exampleskip

\cmd{pgfnodebow} draws a bow between two node. The bow deviates 
according to the third argument: when the third argument is positive, 
the bow deviate to the left (when looking at the target node from the 
first node); when the third argument is negative, the bow deviates to 
the right. The absolute value of the third argument give the amount of 
the deviation with respect to the distance between the nodes.

\cmd{pgfnodebowlabel} puts a label (opaque and/or rotated) on a bow 
between two nodes.

\begin{command}
  \cmd{pgfnodebow}\coarg{pair of fractions}\carg{node 1}%
                  \carg{node 2}\carg{deviation}
  
  draw a bow from node \uarg{node 1} to \uarg{node 2}. Deviate as much 
  as \uarg{deviation} times the distance between the nodes, to the 
  left when \uarg{deviation} is positive. The control points of the 
  Bezier curve of the bow are placed at \(0.4\) and \(0.6\) times the 
  distance between the nodes. These fractions can be changed with the 
  first optional argument.
\end{command}
  
\begin{command}
  \cmd{pgfnodebow}\coarg{pair of fractions}\carg{node 1}%
                  \carg{node 2}\carg{deviation}%
                  \coarg{options}\carg{text}
  
  draw \uarg{text} as the label of a bow drawn by \cmd{pgfnodebow}.
  The text is drawn over an opaque box if \uarg{options} contains
  \texttt{o}, it is drawn in the direction of the edge if
  \uarg{options} contains \texttt{r}.
\end{command}

\exampleskip
\pgfsetunit{4cm}
\begin{verbatimbox}
  [...]
  \small
  \pgfsetcolor{back}{white}
  \pgfsetendarrow{\pgfarrowsingle}
  \pgfnodebow{00}{11}{0.2}
  \pgfnodebowlabel{00}{11}{0.2}[r]{\(\alpha_{2}\)}
  \pgfnodebowlabel[0.2,0.2]{00}{11}{0.15}{\(\alpha_{1}\)}
  \pgfnodebowlabel[0.8,0.8]{00}{11}{0.1}[o]{\(\alpha_{3}\)}
  \pgfnodebow[0.2,0.8]{00}{01}{0.7}
  \pgfnodebowlabel[0.2,0.8]{00}{01}{0.55}[o]{\(\beta_{1}\)}
  \pgfnodebow[0.7,0.8]{01}{00}{-0.3}
  \pgfnodebowlabel[0.7,0.8]{01}{00}{-0.3}{\(\beta_{2}\)}
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{-0.5cm}{\expiclength}{5cm}
  \footnotesize\sffamily
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{blue}
  \pgfsetcolor{back}[gray]{0.9}
  \pgfsetlinewidth{0.25mm}
  \pgfnodecircle{00}[fillstroke]{\pgfxy(0,0)}{5mm}
  \pgfnodetext{00}{(0,0)}
  \pgfnodecircle{01}[virtual]{\pgfxy(0,1)}{5mm}
  \pgfnodetext{01}{(0,1)}
  \pgfnodecircle{10}[stroke]{\pgfxy(1,0)}{5mm}
  \pgfnodetext{10}{(1,0)}
  \pgfnoderect{11}[fill]{\pgfxy(1,1)}{\pgfpoint{1cm}{1cm}}
  \pgfnodetext{11}{(1,1)}[opaque]
  %
  \small
  \pgfsetcolor{back}{white}
  \pgfsetendarrow{\pgfarrowsingle}
  \pgfnodebow{00}{10}{0.15}
  \pgfnodebow{10}{00}{0.15}
  \pgfnodebow{00}{11}{0.2}
  \pgfnodebowlabel{00}{11}{0.2}[r]{\(\alpha_{2}\)}
  \pgfnodebowlabel[0.2,0.2]{00}{11}{0.15}{\(\alpha_{1}\)}
  \pgfnodebowlabel[0.8,0.8]{00}{11}{0.1}[o]{\(\alpha_{3}\)}
  \pgfnodebow[0.2,0.8]{00}{01}{0.7}
  \pgfnodebowlabel[0.2,0.8]{00}{01}{0.55}[o]{\(\beta_{1}\)}
  \pgfnodebow[0.7,0.8]{01}{00}{-0.3}
  \pgfnodebowlabel[0.7,0.8]{01}{00}{-0.3}{\(\beta_{2}\)}
\end{pgfpicture}

\exampleskip

\section{Node loops}
\cmd{pgfnodeconnloop} connects a node to itself with a loop. A 
points gives the direction of the loop relative to the center of 
the node. An angle specifies the aperture of the loop.

\cmd{pgfnodelooplabel} puts a label on a node loop. The label is 
drawn on an opaque rectangle if ``options'' contains ``o''. It is 
rotated to be perpendicular to the direction of the loop unless the 
``options'' contains ``n''. 

\begin{command}
  \cmd{pgfnodeconnloop}\carg{node name}\carg{angle}%
                 \texttt{(}\uarg{x}\texttt{,}\uarg{y}\texttt{)}
  
  draw a loop on node \uarg{node name} in the \((x,y)\) direction. The 
  loop is opened by \uarg{angle} on each side.
\end{command}
\begin{command}
  \cmd{pgfnodelooplabel}\carg{node name}\coarg{fraction}%
           \texttt{(}\uarg{x}\texttt{,}\uarg{y}\texttt{)}%
           \coarg{options}\carg{text}
  
  draw \uarg{text} as the label of a loop drawn by
  \cmd{pgfnodeconnloop}. The text is drawn over an opaque box if
  \uarg{options} contains \texttt{o}, it is drawn horizontally only if
  \uarg{options} contains \texttt{n} (the default is \texttt{r}, a
  rotated label). \uarg{fraction} is the fraction of the distance 
  between the center of the node and the relative \((x,y)\) point at 
  which to put the center of the label.
\end{command}

\exampleskip
\pgfsetunit{4cm}
\begin{verbatimbox}
  [...]
  \small
  \pgfsetcolor{back}{white}
  \pgfsetendarrow{\pgfarrowsingle}
  \pgfnodeconnloop{00}{30}(-0.3,-0.3)
  \pgfnodelooplabel{00}(-0.3,-0.3){\(\lambda_{1}\)}
  \pgfnodeconnloop{00}{-30}(0.3,-0.3)
  \pgfnodelooplabel{00}[0.8](0.3,-0.3)[o]{\(\lambda_{2}\)}
  \pgfnodeconnloop{11}{15}(0.2,0.2)
  \pgfnodeconnloop{11}{60}(-0.2,-0.2)
  \pgfnodelooplabel{11}(-0.2,-0.2)[n]{\(\Omega_{1}\)}
  \pgfnodeconnloop{01}{40}(-0.4,0)
  \pgfnodeconnloop{10}{45}(-2.0,0)
  \pgfnodelooplabel{00}[0.25](-2.0,0)[on]{\(\kappa_{1}\)}
  \pgfnodeconnloop{10}{80}(0.25,0)
\end{verbatimbox}
\hfill
\begin{pgfpicture}{0pt}{-0.5cm}{\expiclength}{5cm}
  \footnotesize\sffamily
  \pgfsetcolor{stroke}{black}
  \pgfsetcolor{fill}{lightgray}
  \pgfsetcolor{text}{blue}
  \pgfsetcolor{back}[gray]{0.9}
  \pgfsetlinewidth{0.25mm}
  \begin{pgfscope}
    \pgfnodecircle{00}[fillstroke]{\pgfxy(0,0)}{5mm}
  \end{pgfscope}
  \pgfnodetext{00}{(0,0)}
  \pgfnodecircle{01}[virtual]{\pgfxy(0,1)}{5mm}
  \pgfnodetext{01}{(0,1)}
  \pgfnodecircle{10}[stroke]{\pgfxy(1,0)}{5mm}
  \pgfnodetext{10}{(1,0)}
  \pgfnoderect{11}[fill]{\pgfxy(1,1)}{\pgfpoint{1cm}{1cm}}
  \pgfnodetext{11}{(1,1)}[opaque]
  %
  \small
  \pgfsetcolor{back}{white}
  \pgfsetendarrow{\pgfarrowsingle}
  \pgfnodeconnloop{00}{30}(-0.3,-0.3)
  \pgfnodelooplabel{00}(-0.3,-0.3){\(\lambda_{1}\)}
  \pgfnodeconnloop{00}{-30}(0.3,-0.3)
  \pgfnodelooplabel{00}[0.8](0.3,-0.3)[o]{\(\lambda_{2}\)}
  \pgfnodeconnloop{11}{15}(0.2,0.2)
  \pgfnodeconnloop{11}{60}(-0.2,-0.2)
  \pgfnodelooplabel{11}(-0.2,-0.2)[n]{\(\Omega_{1}\)}
  \pgfnodeconnloop{01}{40}(-0.4,0)
  \pgfnodeconnloop{10}{45}(-2.0,0)
  \pgfnodelooplabel{00}[0.25](-2.0,0)[on]{\(\kappa_{1}\)}
  \pgfnodeconnloop{10}{80}(0.25,0)
\end{pgfpicture}

% \exampleskip

\end{document}
