PSTricks

From TechWiki

PSTricks allows you to generate sophisticated graphics within LaTeX.

Include the following packages

\usepackage[dvipsnames]{pstricks}
\usepackage{pstricks-add}


---

Note: ktikz (more below) is also cool...
sudo apt-get install ktikz 

---

Don't use pdflatex, as it will create a whole page with page numbering. Instead, put this in a bash script:

#!/bin/bash
latex my.tex
dvips -o my.ps my.dvi
ps2pdf my.ps
pdf2ps my.pdf


Contents

Example 0a

Schematic illustration of bow-tie topology: Image:Bowtie.jpg

\documentclass[a4paper]{article}
\usepackage{a4wide}
\usepackage{pst-pdf}
\usepackage{pst-node}
\usepackage{xcolor}
\begin{document}

\begin{center}
\psset{unit=0.6cm,nodesep=1pt , linewidth=0.3pt}
\begin{pspicture}(-6.7,-5.1)(6.7,1.1)

\pscustom[linestyle=dotted, linewidth=1pt]{ 
\psline(6.5,1)(6.5,-5)
\psline(-6.5,1)(-6.5,-5)
\psline(-6.5,-5)(6.5,1)
}

\pscircle[linestyle=dotted, linewidth=1pt,fillcolor=gray](0,-2){2.5}
\pscircle*[linecolor=white](0,-2){2.5}
\pscircle[linestyle=dotted, linewidth=1pt,fillcolor=gray](0,-2){2.5}

\cnode*(0,0){0.075cm}{s1}
\cnode*(-1,-1){0.075cm}{s2}
\cnode*(1,-1){0.075cm}{s3}
\cnode*(-2,-2){0.075cm}{s4}
\cnode*(0,-2){0.075cm}{s5}
\cnode*(2,-2){0.075cm}{s6}
\cnode*(-1,-3){0.075cm}{s7}
\cnode*(1,-3){0.075cm}{s8}
\cnode*(0,-4){0.075cm}{s9}

\cnode*(-6,0.2){0.075cm}{i1}
\cnode*(-4.5,-0.5){0.075cm}{i2}
\cnode*(-3,-1.2){0.075cm}{i3}
\cnode*(-6,-2){0.075cm}{i4}
\cnode*(-4.5,-2){0.075cm}{i5}
\cnode*(-3,-2){0.075cm}{i6}
\cnode*(-6,-4.2){0.075cm}{i7}
\cnode*(-4.5,-3.5){0.075cm}{i8}
\cnode*(-3,-2.8){0.075cm}{i9}

\cnode*(6,0.2){0.075cm}{o1}
\cnode*(4.5,-0.5){0.075cm}{o2}
\cnode*(3,-1.2){0.075cm}{o3}
\cnode*(6,-2){0.075cm}{o4}
\cnode*(4.5,-2){0.075cm}{o5}
\cnode*(3,-2){0.075cm}{o6}
\cnode*(6,-4.2){0.075cm}{o7}
\cnode*(4.5,-3.5){0.075cm}{o8}
\cnode*(3,-2.8){0.075cm}{o9}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i2}{i3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i4}{i5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i5}{i6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i1}{i5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i7}{i8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i8}{i9}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i3}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i6}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i9}{s4}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o2}{o1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o3}{o2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o6}{o5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o5}{o4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o9}{o8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o5}{o7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s3}{o3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s6}{o6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s8}{o9}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s2}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s1}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s3}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s4}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s2}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s6}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s5}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s5}{s9}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s7}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s9}{s8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s8}{s6}

\end{pspicture}
\end{center}

\end{document}


Example 0b

Alternative bow-tie topology: Image:Bowtie-tt.pdf

\documentclass[a4paper]{article}
\usepackage{a4wide}
\usepackage{pst-pdf}
\usepackage{pst-node}
\usepackage{xcolor}
\begin{document}

\begin{center}
\psset{unit=0.6cm,nodesep=1pt , linewidth=0.3pt}
\begin{pspicture}(-6.7,-8.2)(6.7,2.5)

\pscustom[linewidth=0.5pt,linecolor=gray]{ 
\psline(6.5,1)(6.5,-5)
\psline(-6.5,1)(-6.5,-5)
\psline(-6.5,-5)(6.5,1)
}

\pscircle*[linecolor=white](0,-2){2.5}
\pscircle[linewidth=0.5pt,linecolor=gray](0,-2){2.5}

\psset{linecolor=red}
\cnode*(0,0){0.075cm}{s1}
\cnode*(-1,-1){0.075cm}{s2}
\cnode*(1,-1){0.075cm}{s3}
\cnode*(-2,-2){0.075cm}{s4}
\cnode*(0,-2){0.075cm}{s5}
\cnode*(2,-2){0.075cm}{s6}
\cnode*(-1,-3){0.075cm}{s7}
\cnode*(1,-3){0.075cm}{s8}
\cnode*(0,-4){0.075cm}{s9}

\cnode*(-6,0.2){0.075cm}{i1}
\cnode*(-4.5,-0.5){0.075cm}{i2}
\cnode*(-3,-1.2){0.075cm}{i3}
\cnode*(-6,-2){0.075cm}{i4}
\cnode*(-4.5,-2){0.075cm}{i5}
\cnode*(-3,-2){0.075cm}{i6}
\cnode*(-6,-4.2){0.075cm}{i7}
\cnode*(-4.5,-3.5){0.075cm}{i8}
\cnode*(-3,-2.8){0.075cm}{i9}

\cnode*(6,0.2){0.075cm}{o1}
\cnode*(4.5,-0.5){0.075cm}{o2}
\cnode*(3,-1.2){0.075cm}{o3}
\cnode*(6,-2){0.075cm}{o4}
\cnode*(4.5,-2){0.075cm}{o5}
\cnode*(3,-2){0.075cm}{o6}
\cnode*(6,-4.2){0.075cm}{o7}
\cnode*(4.5,-3.5){0.075cm}{o8}
\cnode*(3,-2.8){0.075cm}{o9}

\psset{linecolor=green}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i2}{i3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i4}{i5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i5}{i6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i1}{i5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i7}{i8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i8}{i9}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i3}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i6}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i9}{s4}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o2}{o1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o3}{o2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o6}{o5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o5}{o4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o9}{o8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{o5}{o7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s3}{o3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s6}{o6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s8}{o9}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s2}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s1}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s3}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s4}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s2}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s6}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s5}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s5}{s9}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s7}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s9}{s8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{s8}{s6}

\psset{linecolor=red}

\cnode*(-3,0.8){0.075cm}{t1}
\cnode*(3,0.8){0.075cm}{t2}

\cnode*(-3,-4.8){0.075cm}{tt1}
\cnode*(-1,-5.8){0.075cm}{tt2}
\cnode*(1,-5.8){0.075cm}{tt3}
\cnode*(3,-4.8){0.075cm}{tt4}

\psset{linecolor=green}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i2}{t1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{t2}{o2}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{i8}{tt1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{tt1}{tt2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{tt2}{tt3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{tt3}{tt4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{tt4}{o8}

\psset{linecolor=black}

\psarcn[linewidth=0.5pt,linecolor=gray]{-}(0,-0.9){4.4}{322}{218}
\psarcn[linewidth=0.5pt,linecolor=gray]{-}(0,-1){5.4}{325.5}{214.5}

\pscustom[linewidth=0.5pt,linecolor=gray]{ 
\psline(-4.585,0.085)(-2.9,1.5)
\psline(-2.9,1.5)(-2,1)
\psline(-2,1)(-3.6,-0.36)
}

\pscustom[linewidth=0.5pt,linecolor=gray]{ 
\psline(4.585,0.085)(2.9,1.5)
\psline(2.9,1.5)(2,1)
\psline(2,1)(3.6,-0.36)
}

\rput(-5.75,1.25){\normalsize \textsf{IN}}
\rput(0,1){\normalsize \textsf{SCC}}
\rput(5.5,1.25){\normalsize \textsf{OUT}}
\rput(-3.75,-6){\normalsize \textsf{Tubes}}
\rput(-2.75,2){\normalsize \textsf{IN-Tendrils}}
\rput(2.75,2){\normalsize \textsf{OUT-Tendrils}}


\psline[linewidth=2pt]{<-}(-5,-7.3)(5,-7.3)
\rput(0,-7.75){\normalsize \textsf{Flow of control}}

\end{pspicture}
\end{center}

\end{document}

Example 1

\begin{figure}[!hb]
\begin{center}
\begin{pspicture}(-1,-2.5)(6.5,2.5)
%\psgrid
\cnodeput(0,0){USD}{\small USD}
\cnodeput(2,2){GBP}{\small GBP}
\cnodeput(4,2){JPY}{\small JPY}
\cnodeput(6,0){EUR}{\small EUR}
\cnodeput(2,-2){CHF}{\small CHF}
\cnodeput(4,-2){AUD}{\small AUD}
\ncline{-}{EUR}{USD}
\ncline{-}{AUD}{JPY}
\ncline{-}{AUD}{USD}
\ncline{-}{CHF}{JPY}
\ncline{-}{GBP}{CHF}
\ncline{-}{GBP}{JPY}
\ncline{-}{GBP}{USD}
\ncline{-}{EUR}{AUD}
\ncline{-}{EUR}{GBP}
\ncline{-}{EUR}{CHF}
\ncline{-}{EUR}{JPY}
\ncline{-}{EUR}{USD}
\ncline{-}{USD}{CHF}
\ncline{-}{USD}{JPY}
\end{pspicture}
\end{center}
\caption{some text here}
\end{figure}

Image:pstricks-ccyeg.png

Example 2

Including the package

\usepackage[final]{ps4pdf}

and compiling with

ps4pdf

you need to put the pspicture in a

\PSforPDF

environment.

\PSforPDF{
\begin{center}
\begin{tiny}
%\psset{xunit=1cm,yunit=1cm,runit=1cm,nodesep=1pt}
\psset{unit=0.6cm,nodesep=1pt , linewidth=0.3pt}
\begin{pspicture}(-0.4,-5)(4.3,1.5)
\cnodeput(0,0){i1}{\makebox(0, 0.4){\bf $i$}}
\cnodeput(4,0){i2}{\makebox(0, 0.4){}}
\cnodeput(6,0){i3}{\makebox(0, 0.4){}}
\cnodeput(6,-2){i5}{\makebox(0, 0.4){}}
\cnodeput(-2,-4){i4}{\makebox(0, 0.4){}}

\cnodeput(-2,-2){j1}{\makebox(0, 0.4){}}
\cnodeput(0,-2){j2}{\makebox(0, 0.4){}}
\cnodeput(2,-2){j3}{\makebox(0, 0.4){\bf $j$}}
\ncline{->}{i3}{i5}
\ncline{->}{j1}{i4}
\ncline{->}{i2}{j3}
\ncline{->}{i1}{j1}
\ncline{->}{i1}{j2}
\ncline{->}{i1}{j3}\lput{:U}{\rput[r]{N}(0.2,.4){\bf $w_{ij}$}}
\rput[r]{N}(2.7,-2.6){\footnotesize $v_j$}
\end{pspicture}
\end{tiny}
\end{center}
}

Image:Net.png

Example 3

\PSforPDF{
\begin{center}
\begin{tiny}
%\psset{xunit=1cm,yunit=1cm,runit=1cm,nodesep=1pt}
\psset{unit=0.65cm,nodesep=1pt , linewidth=0.3pt}
\begin{pspicture}(-0.4,-2.8)(4.3,0.5)
\cnodeput(0,0){i1}{\makebox(0, 0.4){$i_1$}}
\cnodeput(2,0){i2}{\makebox(0, 0.4){$i_2$}}
\cnodeput(4,0){i3}{\makebox(0, 0.4){$i_3$}}
\cnodeput[fillstyle=solid,fillcolor=lightgray](2,-2){j}{\makebox(0, 0.4){$j$}}
\rput[r]{N}(2.7,-2.6){\footnotesize $S_j$}
\ncline{->}{i1}{j}\Bput{$w_{i_1j}$}
\ncline{->}{i2}{j}\lput{:U}{\rput[r]{N}(-.35,-.15){$w_{i_2j}$}}
\ncline{->}{i3}{j}\Aput{$w_{i_3j}$}
\end{pspicture}
\end{tiny}
\end{center}
}

Image:Snw.png

Example 4

\PSforPDF{
\begin{center}
\begin{tiny}
%\psset{xunit=1cm,yunit=1cm,runit=1cm,nodesep=1pt}
\psset{unit=0.65cm,nodesep=1pt , linewidth=0.3pt}
%\begin{pspicture}(3,-5)(0,0.5)
\begin{pspicture}(-0.4,-2.4)(7.3,0.6)
\cnodeput[fillstyle=solid,fillcolor=lightgray](2,-1){i1}{\makebox(0, 0.4){$i_1$}}
\cnodeput(0,0){j1}{\makebox(0, 0.4){$j_1$}}
\cnodeput(0,-2){j2}{\makebox(0, 0.4){$j_2$}}
\cnodeput(4,-1){j3}{\makebox(0, 0.4){$j_3$}}
\cnodeput(7,0){i2}{\makebox(0, 0.4){$i_2$}}
\cnodeput(7,-2){i3}{\makebox(0, 0.4){$i_3$}}
\ncline{->}{i1}{j1}\Bput{$h_{i_1j_1}$}
\ncline{->}{i1}{j2}\Aput{$h_{i_1j_2}$}
\ncline{->}{i1}{j3}\Aput{$h_{i_1j_3}$}
\ncline{->}{i2}{j3}\Bput{$h_{i_2j_3}$}
\ncline{->}{i3}{j3}\Aput{$h_{i_3j_3}$}
\rput[r]{N}(2.6,-1.7){{\footnotesize $H_i$}}
\end{pspicture}
\end{tiny}
\end{center}
}

Image:Hnw.png

Example 5

Image:Map.jpg

\documentclass{article}
\usepackage{a4wide}
\usepackage{pst-pdf}
\usepackage{pst-node}
\usepackage{pst-grad}
\usepackage{pst-plot}
\usepackage{xcolor}
\begin{document}

\begin{center}
\psset{unit=0.6cm,nodesep=1pt , linewidth=0.3pt}
\begin{pspicture}(-18.5,-20.5)(4.5,2.5)


%%%
\pscustom[fillstyle=gradient,gradbegin=gray,linestyle=none,gradangle=-50,gradend=white,gradmidpoint=0.5]{
        \psline[linewidth=2pt,linecolor=gray]{-}(-16.5,-18.5)(-16.5,-8)(-8,-18.5)
}

%%%axis
\pscustom[linewidth=1pt, arrowscale=2.5]{
%x
\psline{->}(-16.5,-18.5)(4.5,-18.5)
%y
\psline{->}(-16.5,-18.5)(-16.5,2.5)
}

\rput{90}(-18.1,-8){\large $\overline H$ \textrm{(global concentration of control)}}
\rput(-6,-20){\large $\overline S$ \textrm{(local concentration of control)}}


\rput(-13,-19){\large 1.0}
\psline[linewidth=1pt]{-}(-13,-18.5)(-13,-18.3)
\rput(0,-19){\large 4.0}
\psline[linewidth=1pt]{-}(0,-18.5)(0,-18.3)

\rput(-17.1,-2){\large 2.0}
\psline[linewidth=1pt]{-}(-16.5,-2)(-16.3,-2)
\rput(-17.1,-8){\large 1.0}
\psline[linewidth=1pt]{-}(-16.5,-8)(-16.3,-8)
\rput(-17.1,-13){\large $0. \bar6$}
\psline[linewidth=1pt]{-}(-16.5,-13)(-16.3,-13)


%%%
\rput(-15,-17){\Large E}
\rput(-10.4,-8){\Large D}
\rput(-11,0){\Large C}
\rput(-2,0){\Large B}
\rput(-2.5,-10.5){\Large A}

%%%B
%sh
\cnode(0,2){0.1cm}{h1}
\cnode(-4,-2){0.1cm}{h2}
\cnode(0,-6){0.1cm}{h3}
\cnode(4,-2){0.1cm}{h4}
%st
\cnode*(0,0){0.075cm}{s1}
\cnode*(-1,-1){0.075cm}{s2}
\cnode*(1,-1){0.075cm}{s3}
\cnode*(-2,-2){0.075cm}{s4}
\cnode*(2,-2){0.075cm}{s5}
\cnode*(-1,-3){0.075cm}{s6}
\cnode*(1,-3){0.075cm}{s7}
\cnode*(0,-4){0.075cm}{s8}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s8}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s8}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s8}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s8}


%%%A
%sh
\cnode(0,-9){0.1cm}{h1}
\cnode(-1.33,-10.33){0.1cm}{h12}
\cnode(-2.66,-11.66){0.1cm}{h13}
\cnode(-4,-13){0.1cm}{h2}
\cnode(-2.66,-14.33){0.1cm}{h22}
\cnode(-1.33,-15.66){0.1cm}{h23}
\cnode(0,-17){0.1cm}{h3}
\cnode(2.66,-14.33){0.1cm}{h32}
\cnode(1.33,-15.66){0.1cm}{h33}
\cnode(4,-13){0.1cm}{h4}
\cnode(1.33,-10.33){0.1cm}{h42}
\cnode(2.66,-11.66){0.1cm}{h43}
%st
\cnode*(0,-11){0.075cm}{s1}
\cnode*(-1,-12){0.075cm}{s2}
\cnode*(1,-12){0.075cm}{s3}
\cnode*(-2,-13){0.075cm}{s4}
\cnode*(2,-13){0.075cm}{s5}
\cnode*(-1,-14){0.075cm}{s6}
\cnode*(1,-14){0.075cm}{s7}
\cnode*(0,-15){0.075cm}{s8}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h12}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h13}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h42}{s1}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h12}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h13}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s2}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h43}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h42}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s3}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h12}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h13}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h22}{s4}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h23}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h22}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s6}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h33}{s8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h23}{s8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h22}{s8}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s8}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h33}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h32}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s7}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h43}{s5}
%\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h33}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h32}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h42}{s5}


%%%C
%sh
\cnode(-13,2){0.1cm}{h1}

%st
\cnode*(-13,0){0.075cm}{s1}
\cnode*(-14,-1){0.075cm}{s2}
\cnode*(-12,-1){0.075cm}{s3}
\cnode*(-15,-2){0.075cm}{s4}
\cnode*(-11,-2){0.075cm}{s5}
\cnode*(-14,-3){0.075cm}{s6}
\cnode*(-12,-3){0.075cm}{s7}
\cnode*(-13,-4){0.075cm}{s8}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s5}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s6}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s7}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s8}


%%%D
%sh
\cnode(-15,-6.5){0.1cm}{h1}
\cnode(-14,-6.5){0.1cm}{h2}
\cnode(-13,-6.5){0.1cm}{h3}
\cnode(-12,-6.5){0.1cm}{h4}
\cnode(-11,-6.5){0.1cm}{h5}

%st
\cnode*(-15,-9.5){0.075cm}{s1}
\cnode*(-14,-9.5){0.075cm}{s2}
\cnode*(-13,-9.5){0.075cm}{s3}
\cnode*(-12,-9.5){0.075cm}{s4}
\cnode*(-11,-9.5){0.075cm}{s5}

\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h1}{s1}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h2}{s2}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h3}{s3}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h4}{s4}
\ncline[arrowscale=1.5,linewidth=0.7pt]{->}{h5}{s5}

\end{pspicture}
\end{center}

\end{document}

Example 6

Image:Mce.png

\begin{center}
\begin{tiny}
\psset{unit=0.7cm,nodesep=4pt , linewidth=0.5pt}
\begin{pspicture}(8,7)(4,0)
\cnodeput(0,3){1}{\makebox(0, 0.4){\bf $1$}}
\cnodeput(3,3){2}{\makebox(0, 0.4){\bf $2$}}
\cnodeput(6,1){3}{\makebox(0, 0.4){\bf $3$}}
\cnodeput(6,5){4}{\makebox(0, 0.4){\bf $4$}}
\cnodeput(9,3){5}{\makebox(0, 0.4){\bf $5$}}
\cnodeput(12,3){6}{\makebox(0, 0.4){\bf $6$}}

\ncline[arrowscale=2]{->}{1}{2}\rput[r]{N}(1.75,3.4){$0.1$}
\ncline[arrowscale=2]{->}{5}{6}\rput[r]{N}(10.75,3.4){$1.0$}
\ncarc[arrowscale=2,arcangle=25]{->}{2}{3}\rput[r]{N}(4.8,2.1){$0.5$}
\ncarc[arrowscale=2,arcangle=25]{->}{2}{4}\rput[r]{N}(4,4.8){$0.5$}
\ncarc[arrowscale=2,arcangle=25]{->}{3}{2}\rput[r]{N}(4,1.2){$0.3$}
\ncarc[arrowscale=2,arcangle=25]{->}{4}{2}\rput[r]{N}(4.8,3.9){$0.3$}
\ncarc[arrowscale=2,arcangle=25]{->}{4}{5}\rput[r]{N}(8.5,4.8){$0.6$}
\ncarc[arrowscale=2,arcangle=25]{->}{3}{5}\rput[r]{N}(7.8,2.1){$0.2$}
\ncarc[arrowscale=2,arcangle=25]{->}{5}{4}\rput[r]{N}(7.8,3.9){$0.5$}
\ncarc[arrowscale=2,arcangle=25]{->}{5}{3}\rput[r]{N}(8.5,1.2){$0.5$}
\ncarc[arrowscale=2,arcangle=11]{->}{2}{5}\rput[r]{N}(6.25,3.75){$0.2$}
\ncarc[arrowscale=2,arcangle=11]{->}{5}{2}\rput[r]{N}(6.25,2.25){$0.3$}

\end{pspicture}
\end{tiny}
\end{center}


Example 7

Image:vis.jpg

\documentclass{article}
\usepackage{a4wide}
\usepackage{pst-pdf}
\usepackage{pst-node}
\usepackage{pst-grad}
\usepackage{pst-plot}
\usepackage{xcolor}
\begin{document}

\begin{center}
%\psset{unit=0.6cm,nodesep=1pt , linewidth=0.3pt}
\psset{nodesep=1pt}
\begin{pspicture}(-0.2,-2.5)(9,2.5)

\rput[l](0,0){\rnode{z}{PhD}}
%\cnode(0,0){4pt}{a}
\rput[l](6,2){\rnode{a}{Methodology}}
\rput[l](6,-2){\rnode{d}{Model}}
\ncdiagg[angleA=180,armA=4cm,nodesepA=3pt,nodesepB=3pt]{a}{z}
\ncdiagg[angleA=180,armA=4cm,nodesepA=3pt,nodesepB=3pt]{d}{z}

\rput[l](2,0){\rnode{m}{Empirical Analysis}}
\psline(0.81,0)(1.8,0)

\rput[l](6,1){\rnode{b}{Country networks}}
\rput[l](6,-1){\rnode{c}{Global network}}
\ncdiagg[angleA=180,armA=2cm,nodesepA=3pt,nodesepB=3pt]{b}{m}
\ncdiagg[angleA=180,armA=2cm,nodesepA=3pt,nodesepB=3pt]{c}{m}

\end{pspicture}
\end{center}

\end{document}

Example 8

Image:Ind.jpg

\begin{center}
\begin{small}
\psset{nodesep=1pt, linewidth=1pt}
\begin{pspicture}(0.5,-0.5)(5.5,1.5)

  \cnodeput(1,0){A}{\makebox(0, 0.4){$i$}}
  \cnodeput(3,0){B}{\makebox(0, 0.4){$j$}} 
  \cnodeput(5,0){C}{\makebox(0, 0.4){$k$}}
  \ncline{->}{A}{B} 
  \ncline{->}{B}{C}
  \psarcn[linestyle=dotted]{->}(3,-1){2.3}{145}{37}


\end{pspicture}
\end{small}
\end{center}


Example 9

Image:Int.jpg

\begin{center}
\begin{small}
\psset{nodesep=1pt, linewidth=1pt}
\begin{pspicture}(-1.5,-1.5)(5.5,1.5)

  \cnodeput(-1,0){i}{\makebox(0, 0.4){$i$}} 

  \cnodeput(1,0){k}{\makebox(0, 0.4){$k$}}
  \cnodeput(5,0){j}{\makebox(0, 0.4){$j$}}
  \ncline{->}{i}{k} 

 \psarcn[linestyle=dotted]{->}(3,-1){2.3}{145}{37}
 \psarc[linestyle=dotted]{->}(3,1){2.3}{216}{322}

%\psframebox[boxsep=false]{stuff}
\rput[0,0]{0}(3,-0.1){$\vdots$}

\end{pspicture}
\end{small}
\end{center}


Example 10

Image:Overview.jpg

\begin{center}

\psset{nodesep=1pt}

\begin{pspicture}(-6.1,-2)(8.8,2)

\rput[l](1,0){\rnode{z}{}}
\rput[l](3,1.5){\rnode{a}{}}
\rput[l](3,-1.5){\rnode{d}{}}
\ncdiagg[angleA=180,armA=1.0cm,nodesepA=0pt,nodesepB=0pt]{a}{z}
\ncdiagg[angleA=180,armA=1.0cm,nodesepA=0pt,nodesepB=0pt]{d}{z}

\psline(-0.1,0)(1,0)

\psframe(-6.1,-0.4)(-3.1,0.3)
\rput[l](-6,0){\rnode{p}{\color{red} $c^{\textrm{int}}= \tilde{\mathcal{C}} v =  \mathcal{C}v^{\textrm{net}}$}}

\rput[l](-2.9,0.3){\rnode{p}{\color{blue} $v^{\textrm{net}} =  \tilde{\mathcal{C}} v + v$}}
\rput[l](-2.9,-0.3){\rnode{p}{\color{blue} $\phantom{v^{\textrm{net}}} = \mathcal{C}v^{\textrm{net}} + v $}}

\psframe(1.4,-0.3)(3.5,0.3)
\rput[l](1.6,0){\rnode{p}{\color{red} $\hat{\mathcal{C}} v \neq  \mathcal{C} \hat v^{\textrm{net}}$}}

\rput[l](3.2,1.75){\rnode{q}{\color{blue} $\hat v^{\textrm{net}} =  \hat{\mathcal{C}} v +  \mathcal{D} v
=  \hat c^{\textrm{int}} + \mathcal{D} v$}}
\rput[l](3.2,1.25){\rnode{w}{\color{blue} $\phantom{\hat v^{\textrm{net}}} = \mathcal{D} \tilde \mathcal{C} v
+ \mathcal{D} v =  \mathcal{D} \mathcal{C} v^{\textrm{net}} +  \mathcal{D} v$ }}

\rput[l](3.2,-1.25){\rnode{e}{\color{blue} $\bar  v^{\textrm{net}} :=  \mathcal{C} \hat v^{\textrm{net}} +
 \mathcal{D} v = \mathcal{C}  \mathcal{D} v^{\textrm{net}} +  \mathcal{D} v$}}
\rput[l](3.2,-1.75){\rnode{r}{\color{blue} $\phantom{\bar  v^{\textrm{net}}} =: \bar  \mathcal{C} v 
+ \mathcal{D} v =: \bar c^{\textrm{int}} + \mathcal{D} v$}}

\end{pspicture}
\end{center}


Example 11

Image:Toe.png

\documentclass[a4paper]{article}
\usepackage{a4wide}
\usepackage{pst-pdf}
\usepackage{pst-node}
\usepackage{pstricks-add}

\begin{document}

\begin{center}

\psset{unit=0.8cm,nodesep=1pt , linewidth=1.25pt}

\begin{pspicture}(-0.5,0.6)(20.5,-10.5)

\rput[c](5.375,0){\huge {\bf Fermions} (spin-$\frac{1}{2}$)}
\rput[uc]{90}(0,-3.25){\huge Quarks}

%top
\psbrace[](9.25,-1.25)(1.5,-1.25){}
%left
\psbrace[](1.35,-1.5)(1.35,-5){}

%%
 \psline[linestyle=dashed,linewidth=0.25pt ](3.95,-1.5)(3.95,-9.05)
 \psline[linestyle=dashed,linewidth=0.25pt ](6.7,-1.5)(6.7,-9.05)
%%

%%%%
\cnodeput(2.25,-2.25){u}{\makebox(0.9, 0.9){\Huge $u$}}
\rput[r](3.75,-1.75){{\large $+$}{\Large $\frac{2}{3}$}}

\cnodeput(5,-2.25){u}{\makebox(0.9, 0.9){\Huge $c$}}
\rput[r](6.5,-1.75){{\large $+$}{\Large $\frac{2}{3}$}}

\cnodeput(7.75,-2.25){u}{\makebox(0.9, 0.9){\Huge $t$}}
\rput[r](9.25,-1.75){{\large $+$}{\Large $\frac{2}{3}$}}

%
\cnodeput(2.25,-4.25){u}{\makebox(0.9, 0.9){\Huge $d$}}
\rput[r](3.75,-3.75){{\large $-$}{\Large $\frac{1}{3}$}}

\cnodeput(5,-4.25){u}{\makebox(0.9, 0.9){\Huge $s$}}
\rput[r](6.5,-3.75){{\large $-$}{\Large $\frac{1}{3}$}}

\cnodeput(7.75,-4.25){u}{\makebox(0.9, 0.9){\Huge $b$}}
\rput[r](9.25,-3.75){{\large $-$}{\Large $\frac{1}{3}$}}


%%%%%

%left
\psbrace[](1.35,-5.5)(1.35,-9.0){}

\rput[uc]{90}(0,-7.25){\huge Leptons}

%%%%
\cnodeput(2.25,-6.25){u}{\makebox(0.9, 0.9){\Huge $e$}}
\rput[r](3.75,-5.75){{\large $-$}{\Large $1$}}

\cnodeput(5,-6.25){u}{\makebox(0.9, 0.9){\Huge $\mu$}}
\rput[r](6.5,-5.75){{\large $-$}{\Large $1$}}

\cnodeput(7.75,-6.25){u}{\makebox(0.9, 0.9){\Huge $\tau$}}
\rput[r](9.25,-5.75){{\large $-$}{\Large $1$}}

%
\cnodeput(2.25,-8.25){u}{\makebox(0.9, 0.9){\Huge $\nu_e$}}
\rput[r](3.75,-7.75){{\Large 0}}

\cnodeput(5,-8.25){u}{\makebox(0.9, 0.9){\Huge $\nu_\mu$}}
\rput[r](6.5,-7.75){\Large 0}

\cnodeput(7.75,-8.25){u}{\makebox(0.9, 0.9){\Huge $\nu_\tau$}}
\rput[r](9.25,-7.75){\Large 0}

%%%%%%%%


\rput[c](15.0875,0.09){\huge \bf Bosons}
\psbrace[](20,-1.25)(10.175,-1.25){}

%%%
\cnodeput[fillstyle=solid,fillcolor=lightgray](11,-2.25){u}{\makebox(0.9, 0.9){\Huge $\gamma$}}
\rput[r](12.5,-1.75){\Large 0}

\cnodeput[fillstyle=solid,fillcolor=lightgray](11,-4.25){u}{\makebox(0.9, 0.9){\Huge $g$}}
\rput[r](12.5,-3.75){{\Large 0}}

\cnodeput(11,-6.25){u}{\makebox(0.9, 0.9){\Huge $Z$}}
\rput[r](12.5,-5.75){\Large $0$}

\cnodeput(11,-8.25){u}{\makebox(0.9, 0.9){\Huge $W$}}
\rput[r](12.5,-7.75){{\large $\pm$}{\Large $1$}}

%right
\psbrace[](12.5,-9)(12.5,-1.5){}

\rput[uc]{90}(13.85,-5.25){\huge Gauge bosons (spin-1) }


%%%%%
\cnodeput(15.75,-2.25){u}{\makebox(0.9, 0.9){\Huge $h$}}
\rput[r](17.25,-1.75){\Large 0}

\psbrace[](14.95,-3)(17.25,-3){}

\rput[uc]{90}(16.125,-6.5){\huge Higgs (spin-0) }


\cnodeput[fillstyle=solid,fillcolor=lightgray,hatchcolor=gray,fillstyle=vlines*](18.5,-2.25){u}{\makebox(0.9, 0.9){\Huge $\mathcal{G}$}}
\rput[r](20,-1.75){\Large 0}

\psbrace[](17.7,-3)(20,-3){}

\rput[uc]{90}(18.875,-7.25){\huge Graviton (spin-2)}


\end{pspicture}
\end{center}

\end{document}

Hacks

Problem with the Bounding Box for PS Figures When Nodes Contain No Text

A figure with the bounding box defined as

\begin{pspicture}(0,-6)(6,0)

and a node placed far down

\cnodeput(0,-6){k1}{\makebox(0, 0.4){}}

can lead to PS figures that have a messed up bounding box and can't be included correctly into LaTeX documents.

An ugly hack, and the only solution I found, is to place a white node over a node with text

\cnodeput(0,-6){k1}{\makebox(0, 0.4){w}}
\cnodeput[fillstyle=solid,fillcolor=white](0,-6){k1}{\makebox(0, 0.4){}}

ktikz

thx nico!

http://www.ctan.org/tex-archive/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf

http://www.texample.net/tikz/examples/author/pgf-manual/

Example 1

Image:Box1.png

This example makes use of the shadows package to add shadows to shapes (nodes), calc to define relative coordinates precisely, and backgrounds to add a node anchored to another node defined previously, so that the second node surrounds the first one without hiding it (it is part of the background). These packages have to be added to the TeX preamble (template) of the figure, as described in KTikZ. The location and presence/absence of the highlighting box can be adjusted by commenting and changing the anchor of the last block of code. It also defines a fixed bounding box using a path, so that regardless of what highlighting has been chosen for the boxes, the output will always have the same size (it makes the slide-to-slide transition seamless, for instance).


\begin{tikzpicture}

\definecolor{monred}{rgb}{0.79 0.0 0.1}
\definecolor{monblue}{rgb}{0.1 0.0 0.79}
\definecolor{mongreen}{rgb}{0 0.79 0.1}

\tikzstyle{rec} = [rectangle,rounded corners,ultra thick]

\path[use as bounding box] (7.6,4.9) rectangle (-7.6,-4.2);

\node at (0, 3) [rec,draw=monred!70, fill=monred!10, text=black!80,inner sep=5mm,drop shadow] (rec1)
	{\parbox{\textwidth}{ \textbf{
``A stochastic model of social interaction in wild house mice''} \\
System description and spatial modelling
}};
\node[rec,draw=monred!70, fill=monred!10, inner sep=2mm,
text=monred!200,anchor=south west, xshift=3mm,yshift=-0.5mm]
	at (rec1.north west)
{ECCS Track C};
\node[rec,draw=monred!70, fill=monred!10, inner sep=2mm,
text=monred!200,anchor=south east, xshift=-3mm,yshift=-0.5mm]
	at (rec1.north east)
{Sept. 14};

\node at (0, 0) [rec, draw=monblue!70, fill=monblue!10, text=black!80,inner sep=5mm,drop shadow] (rec2)
	{\parbox{\textwidth}{ \textbf{
``Long-term community evolution in an animal society''} \\
Investigation of the community structure and its implications
}};
\node[rec,draw=monblue!70, fill=monblue!10, inner sep=2mm, 
text=monblue!200,anchor=south west, xshift=3mm,yshift=-0.5mm]
	at (rec2.north west)
{SCNET 2010};
\node[rec,draw=monblue!70, fill=monblue!10, inner sep=2mm,
text=monblue!200,anchor=south east, xshift=-3mm,yshift=-0.5mm]
	at (rec2.north east)
{Sept. 15};

\node at (0, -3) [rec, draw=mongreen!70, fill=mongreen!10, text=black!80,inner sep=5mm,drop shadow] (rec3)
	{\parbox{\textwidth}{ \textbf{
``An agent-based approach to sociality in wild house mice''} \\
Multiagent model based on an underlying social network
}};
\node[rec,draw=mongreen!70, fill=mongreen!10, inner sep=2mm,
text=mongreen!200,anchor=south west, xshift=3mm,yshift=-0.5mm]
	at (rec3.north west)
{DOOCN IV};
\node[rec,draw=mongreen, fill=mongreen!10, inner sep=2mm,
text=mongreen!200,anchor=south east, xshift=-3mm,yshift=-0.5mm]
	at (rec3.north east)
{Sept. 16};

%% uncomment to uncover the background shape
% \begin{pgfonlayer}{background}
% \draw[draw=black,rounded corners=2mm,ultra thick,black!50, fill = black!10]
% ($(rec3.north west)+(-1ex,+5ex)$)
% rectangle
% ($(rec3.south east)+(+1ex,-1ex)$);
% \end{pgfonlayer}

\end{tikzpicture}

Example 2

This is a rather standard but fancy nonetheless example of what can be done in few lines of code using TikZ with the libraries {arrows,automata,shapes} and automatic routing of edges and placement of labels.

Image:Box2.png

\begin{tikzpicture}
[inner sep=0mm,
bend angle = 30,
auto, %automatic edge label placement
box/.style={rectangle,draw=blue!50,fill=blue!20, minimum size = 1.5cm},
vbox/.style={ellipse, minimum height = 1cm, minimum width = 1.5cm, draw=black!50,fill=black!20},
to/.style={->,shorten <=1pt,>=stealth',bend left},
from/.style={<-,shorten <=1pt,>=stealth',bend right},
]
\node at (-3,   0) [box] (B1)   {$b_1$};
\node at ( 3,   0) [box] (B2)   {$b_2$};
\node at (-6,   0) [vbox] (B11) {$b_{\{1,1\}}$}
      edge [from] node [swap]   {$\Pi_{1,1} \cdot \lambda_1$}  (B1)
      edge [to]   node          {$\Theta_{1,1}$} (B1);
\node at ( 0, 1.5) [vbox] (B12) {$b_{\{1,2\}}$}
      edge [from] node [swap]   {$\Pi_{1,2} \cdot \lambda_1$}  (B1)
      edge [to]   node          {$\Theta_{1,2}$} (B2);
\node at ( 0,-1.5) [vbox] (B21) {$b_{\{2,1\}}$}
      edge [from] node [swap]   {$\Pi_{2,1} \cdot \lambda_2$}  (B2)
      edge [to]   node          {$\Theta_{2,1}$} (B1);
\node at ( 6,   0) [vbox] (B22) {$b_{\{2,2\}}$}
      edge [from] node [swap]   {$\Pi_{2,2} \cdot \lambda_2$}  (B2)
      edge [to]   node          {$\Theta_{2,2}$} (B2);
\path (B1) edge [->,shorten <=1pt,>=stealth',in=250, out = 290, loop] node {$Pr_{(1|1)}$} (B1);
\path (B2) edge [->,shorten <=1pt,>=stealth',in=70, out = 110, loop] node {$Pr_{(2|2)}$} (B2);
\path (B12) edge [->,shorten <=1pt,>=stealth',in=70, out = 110, loop] node {$Pr_{(\{1,2\}| \{1,2\})}$} (B12);
\path (B21) edge [->,shorten <=1pt,>=stealth',in=250, out = 290, loop] node {$Pr_{(\{2,1\}| \{2,1\})}$} (B21);
\path (B11) edge [->,shorten <=1pt,>=stealth',in=160, out = 200, loop] node[above=0.5cm] {$Pr_{(\{1,1\}| \{1,1\})}$} (B11);
\path (B22) edge [->,shorten <=1pt,>=stealth',in=340, out = 20, loop] node[below=0.5cm] {$Pr_{(\{2,2\}| \{2,2\})}$} (B22);
\end{tikzpicture}

Example 3

Image:Box3.png

This example uses predefined styles, a predefined bounding box and the backgrounds environment to create the diagram of a social model. By commenting parts of the code, one may restrict the figure to show only a few of the nodes and edges (useful to describe the model in iterative steps, for example in a presentation). The predefined bounding box is used to ensure that the size of the output figure will not be changed regardless of what nodes are included.

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgf}
\usepackage[active,pdftex,tightpage]{preview}
\usetikzlibrary{arrows,positioning,backgrounds}
\PreviewEnvironment[]{tikzpicture}
\tikzset{
    %Define standard arrow tip
    >=stealth',
    %Define style for boxes
    punkt/.style={
           rectangle,
           rounded corners,
           draw=black, very thick,
           %text width=6.5em,
           text centered},
    % Define arrow style
    pil/.style={
           ->,
           thick,
           shorten <=2pt,
           shorten >=2pt,}
}

\definecolor{cbf}{RGB}{199,100,95}

\begin{document}
<>
\end{document}
</code>

Code for the figure:
<code latex>
\begin{tikzpicture}[node distance=1cm, auto]

\path[use as bounding box] (-2.1, -3.4) rectangle (12.1,3.4);

\node at (0,0) [punkt, minimum height=1.2cm, fill=cbf!80] (T) {Territory};
\node at (5,0) [punkt, minimum height=1.2cm, fill=cbf!80] (M) {Meeting}
	edge[pil, bend left=30] node[swap]{\small duration} (T)
	edge[pil, <-, bend right=30] node[auto]{\small overlap} (T);
\node at (10,0) [punkt, minimum height=1.2cm, fill=cbf!80] (W) {Social bond}
	edge[pil, bend left=30] (M)
	edge[pil, <-, bend right=30] (M);
\node at (10,2.5) [punkt, fill=black!20] (r) {Relatedness}
	edge[pil] (W);
\node at (0,2.5) [punkt, minimum height=1.2cm, fill=green!50] (D) {\textbf{Dominance}}
	(D.south) edge[pil, <-, bend right=30] (T.north)
	edge[pil, bend left=30] (T.north);
\node at (0,-2.5) [punkt, fill=black!20] (e) {Effort}
	edge[pil] (T);
\path
(W) edge[pil, in=250, out=290, loop] node[auto]{\small decay} (W);

\begin{pgfonlayer}{background}
\draw[draw=black!50, rounded corners=2mm, fill = blue!20]
(-2.1, -3.4) rectangle (5.1, 1.2);
\draw (3.5, -3) node{\Large \color{black!80}SPATIAL};
\draw[draw=black!50, rounded corners=2mm, fill = yellow!30]
(5.1, -1.2) rectangle (12.1, 3.4);
\draw (6.5, 3) node{\Large \color{black!80}SOCIAL};
\end{pgfonlayer}

\end{tikzpicture}