7

I am newbie in this TEX world and I would like to draw something like this: alt text

But I don't know where to start. I tried using: \usepackage{pstricks,pst-node,pst-tree} but when I try to use it I got many errors, am I in the right way?

1
  • there are various solutions to this problem. I guess what happened when you used pstricks is that you still tried to compile with pdflatex. this is with pstricks not sirectly possible. try to compile to PS or use a package such as tikz that works directly with pdflatex
    – Martin H
    Jan 13, 2011 at 12:03

2 Answers 2

18

This is a solution with tikz that looks like your screenshot given above

\documentclass[]{article}

%load tikz
\usepackage{tikz}
%load additional library
\usetikzlibrary{positioning}

\begin{document}

%start tikzpicture,define a node style
\begin{tikzpicture}[mystyle/.style={draw,rectangle,fill=blue!30,thick,minimum
width=3cm,minimum height=1cm}]
%start to define nodes relative to each other
\node[mystyle] (A) {A};
\node[mystyle] (B) [below=of A] {B};
\node[mystyle] (C) [below=of B] {C}; 
\node[mystyle] (D) [below=of C] {D};

%second column with a bit of a distance
\node[mystyle,node distance=2cm] (E) [right=of A] {E};  
\node[mystyle,node distance=2cm] (F) [right=of B] {F};
\node[mystyle,node distance=2cm] (G) [right=of D] {G};       

\node[mystyle,node distance=2cm] (H) [right=of E] {H};  

%empty node for the gap in column 2 row 3
\node[minimum width =3cm,node distance=2cm] (J) [right=of C] {};  
\node[mystyle,node distance=2cm] (K) [right=of J] {K};       

%connect the nodes
\draw[->] (A) -- (B);
\draw[->] (B) -- (C);
\draw[->] (C) -- (D);
\draw[->] (G) -- (G);
\draw[->] (E) -- (F);
\draw[->] (F) -- (G);
\draw[->] (G) -| (K);
\draw[->] (K) -- (H);
\draw[->] (C) -- (K);

\end{tikzpicture}

\end{document}

alt text

5
  • I forgot to connect D and G put that is an easy task for you I guess :)
    – Martin H
    Jan 13, 2011 at 12:33
  • @Martin: I removed those additional indentations in your code block. OK? Jan 13, 2011 at 12:48
  • I have adjusted the size, color, but how can I adjust the end of the arrow, is too small.
    – nacho4d
    Jan 13, 2011 at 13:21
  • 2
    nevermind I just found it out \begin{scope}[very thick]\draw[]...\end{scope}
    – nacho4d
    Jan 13, 2011 at 13:25
  • 2
    @nacho4d: if you just want to change the arrows (and not the thickness of the lines), take a look at the arrows library in TikZ which defines a lot of different arrowheads. Jan 13, 2011 at 13:37
11

a solution with symbolix names for cells.

\documentclass[twoside]{article}
\usepackage{pst-node}

\def\psFBox#1{\psframebox[shadow,fillcolor=red!30,
  fillstyle=solid]{\makebox[2.5cm]{\strut#1}}}
\begin{document}

\begin{psmatrix}[colsep=7mm]
[name=A]\psFBox{A} &  [name=B]\psFBox{B} & [name=C]\psFBox{whatever}\\
[name=a]\psFBox{a} &  [name=b]\psFBox{me}& [name=c]\psFBox{c}\\
[name=Aa]\psFBox{Aa}&                    & [name=cC]\psFBox{c} 
\end{psmatrix}
\psset{arrowscale=1.7}
\ncline{->}{A}{B} \ncline{->}{B}{C}
\ncangle[angleB=-90]{->}{Aa}{b}
\ncangles[angleA=180,angleB=-90,armB=7mm]{->}{cC}{B}

\end{document}

if ayou want to run it with pdflatex then have a look here: http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput#autopstpdf

alt text

4
  • 1
    didn't work;( I got this: ./Chapters/Chapter2.tex:37: Undefined control sequence. <recently read> \c@lor@to@ps l.37 [name=A]\psFBox{A} & [name=B]\psFBox{B} & [name=C]\psFBox{whatever}\?
    – nacho4d
    Jan 13, 2011 at 12:14
  • 1
    @nacho4d: see link above. use package auto-pst-pdf and run pdflatex -shell-escape file
    – user2478
    Jan 13, 2011 at 12:20
  • Thanks @Herbert I suppose I need more experience to realize that in the future.
    – nacho4d
    Jan 13, 2011 at 13:06
  • 1
    @nacho: use the usual latex-dvips-ps2pdf road to get the result. Do not use pdflatex.
    – pluton
    Jan 13, 2011 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .