8

Following the answer to this question, I'm now at a point where I have very unsatisfying looking arrows.

If I use the double option in the \draw command the spacing is too small, and when I increase it, the arrow heads look awful. As it stands, the arrows look weeny and out of place; I'd like wide arrows (double) with thin arrow heads.

How can I modify the arrows - preferably in global manner - so that they are in keeping with the drawing?

And, How can modify the arrows so that they are perpendicular to the surfaces they point to?

enter image description here

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,fit}
\pgfdeclarelayer{container}
\pgfsetlayers{container,main}

\tikzset{>=stealth}
\tikzset{
    narrow/.style={draw, fill=blue!20, text width=2cm, text centered, minimum height=1cm},
    small/.style={draw, fill=blue!10, text width=1.2cm, text centered, minimum height=0.625cm, draw=black!60, font=\scriptsize},
    wide/.style={draw, fill=orange!20, text width=8.5cm, text centered, minimum height=1.75cm, rounded corners},
    tall/.style={draw, fill=green!20, text width=1.75cm, text centered, minimum height=8cm, rounded corners},
    squar/.style={draw, fill=yellow!10, text width=5.25cm, text centered, minimum height=3.5cm, rounded corners, draw=black!60, dashed}
}

\def\blockdist{5}
\def\edgedist{5}
\begin{document}
\begin{tikzpicture}
  \node                 (lib)     [tall]   {Library};
  \node at (3,-1)       (tman)    [narrow] {tmon};
  \node                 (ksman)   [narrow] [right=.75cm of tman]   {ksmon};
  \node                 (stsp)    [narrow] [right=.75cm of ksman]  {stosp};
  \node                 (daemon)  [wide]   [below=.75cm of ksman]  {Daemon};
  \node                 (imgan)   [narrow] [above=1.375cm of tman] {img-analysis};
  \node                 (thrman)  [narrow] [above=.75cm of imgan]  {thermal-analysis};
  \begin{pgfonlayer}{container}
     \node              (dio)     [fill=red!10, inner sep=.35cm, fit=(tman)(stsp),  rounded corners, draw=black!60, dashed] {};
     \node              (manufac) [fill=red!25, inner sep=.1cm, fit=(ksman)(stsp), rounded corners, draw=black!60, dashed] {};
  \end{pgfonlayer}
  \node                 (scrpts)  [squar]  [above=1.5cm of manufac.center] {};

  \node                 (scrr2c2) [small]  [above=0.1cm of scrpts.center] {shell};
  \node                 (scrr1c2) [small]  [above=0.2cm of scrr2c2]       {shell};
  \node                 (scrr3c2) [small]  [below=0.1cm of scrpts.center] {shell};
  \node                 (scrr4c2) [small]  [below=0.2cm of scrr3c2]       {shell};

  \node                     (scrr1c1) [small]  [left=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c1) [small]  [left=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c1) [small]  [left=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c1) [small]  [left=0.2cm of scrr4c2] {shell};

  \node                     (scrr1c3) [small]  [right=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c3) [small]  [right=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c3) [small]  [right=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c3) [small]  [right=0.2cm of scrr4c2] {shell};

  \draw[<->] (manufac.north) -- (scrpts.south);
  \draw[<->] (imgan.east) -- (scrpts);
  \draw[<->] (thrman.east) -- (scrpts);
  \draw[<->] (thrman.west) -- (lib);
  \draw[<->] (imgan.west) -- (lib);
  \draw[<->] (dio.west) -- (lib);
  \draw[<->] (daemon.west) -- (lib);
  \draw[<->] (daemon.north) -- (dio.south);
\end{tikzpicture}
\end{document}
1
  • I should mention that I'm Latex newb of 2 weeks; this is great stuff. – Jamie Nov 16 '12 at 3:51
4

For modifying the arrows and their heads see this answer in a somewhat related question.

For perpendicular arrows zhe only way I know is to save the proper (x,y) coordinates, and connect the arrows to those.

Perpendicular Arrows

Declare some new dimensions to save coordinates.

\newdimen{\myxdimone}
\newdimen{\myydimone}
\newdimen{\myxdimtwo}
\newdimen{\myydimtwo}

Create the paths you need, and get their x,y coordinates with \pgfgetlastxy{x}{y}, e.g.

\path (thrman.west);
\pgfgetlastxy{\myxdimone}{\myydimone};
\path (lib.east);
\pgfgetlastxy{\myxdimtwo}{\myydimtwo};

Now create a coordinate based on the saved dimensions and draw the arrow.

\coordinate (dummy1) at (\myxdimtwo, \myydimone);
\draw[<->] (thrman.west) -- (dummy1);

There may be a simpler solution, but this is what I use in cases like yours. See the full code below.

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,fit}
\pgfdeclarelayer{container}
\pgfsetlayers{container,main}

\tikzset{>=stealth}
\tikzset{
    narrow/.style={draw, fill=blue!20, text width=2cm, text centered, minimum height=1cm},
    small/.style={draw, fill=blue!10, text width=1.2cm, text centered, minimum height=0.625cm, draw=black!60, font=\scriptsize},
    wide/.style={draw, fill=orange!20, text width=8.5cm, text centered, minimum height=1.75cm, rounded corners},
    tall/.style={draw, fill=green!20, text width=1.75cm, text centered, minimum height=8cm, rounded corners},
    squar/.style={draw, fill=yellow!10, text width=5.25cm, text centered, minimum height=3.5cm, rounded corners, draw=black!60, dashed}
}

\def\blockdist{5}
\def\edgedist{5}
\begin{document}
\begin{tikzpicture}

  \newdimen{\myxdimone}
  \newdimen{\myydimone}
  \newdimen{\myxdimtwo}
  \newdimen{\myydimtwo}

  \node                 (lib)     [tall]   {Library};
  \node at (3,-1)       (tman)    [narrow] {tmon};
  \node                 (ksman)   [narrow] [right=.75cm of tman]   {ksmon};
  \node                 (stsp)    [narrow] [right=.75cm of ksman]  {stosp};
  \node                 (daemon)  [wide]   [below=.75cm of ksman]  {Daemon};
  \node                 (imgan)   [narrow] [above=1.375cm of tman] {img-analysis};
  \node                 (thrman)  [narrow] [above=.75cm of imgan]  {thermal-analysis};
  \begin{pgfonlayer}{container}
     \node              (dio)     [fill=red!10, inner sep=.35cm, fit=(tman)(stsp),  rounded corners, draw=black!60, dashed] {};
     \node              (manufac) [fill=red!25, inner sep=.1cm, fit=(ksman)(stsp), rounded corners, draw=black!60, dashed] {};
  \end{pgfonlayer}
  \node                 (scrpts)  [squar]  [above=1.5cm of manufac.center] {};

  \node                 (scrr2c2) [small]  [above=0.1cm of scrpts.center] {shell};
  \node                 (scrr1c2) [small]  [above=0.2cm of scrr2c2]       {shell};
  \node                 (scrr3c2) [small]  [below=0.1cm of scrpts.center] {shell};
  \node                 (scrr4c2) [small]  [below=0.2cm of scrr3c2]       {shell};

  \node                     (scrr1c1) [small]  [left=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c1) [small]  [left=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c1) [small]  [left=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c1) [small]  [left=0.2cm of scrr4c2] {shell};

  \node                     (scrr1c3) [small]  [right=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c3) [small]  [right=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c3) [small]  [right=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c3) [small]  [right=0.2cm of scrr4c2] {shell};

  \draw[<->] (manufac.north) -- (scrpts.south);

  \path (thrman.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \path (lib.east);
  \pgfgetlastxy{\myxdimtwo}{\myydimtwo};
  \coordinate (dummy1) at (\myxdimtwo, \myydimone);
  \draw[<->] (thrman.west) -- (dummy1);

  \path (imgan.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \coordinate (dummy2) at (\myxdimtwo, \myydimone);
  \draw[<->] (imgan.west) -- (dummy2);

  \path (dio.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \coordinate (dummy3) at (\myxdimtwo, \myydimone);
  \draw[<->] (dio.west) -- (dummy3);

  \path (daemon.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \coordinate (dummy4) at (\myxdimtwo, \myydimone);
  \draw[<->] (daemon.west) -- (dummy4);
  \draw[<->] (daemon.north) -- (dio.south);

  \path (scrpts.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \path (imgan.east);
  \pgfgetlastxy{\myxdimtwo}{\myydimtwo};
  \coordinate (dummy5) at (\myxdimone, \myydimtwo);
  \draw[<->] (imgan.east) -- (dummy5);

  \path (thrman.east);
  \pgfgetlastxy{\myxdimtwo}{\myydimtwo};
  \coordinate (dummy6) at (\myxdimone, \myydimtwo);
  \draw[<->] (thrman.east) -- (dummy6);
\end{tikzpicture}
\end{document}
1
  • If you read my previous (deleted) comment, sorry: I didn't see it was a stealth-shaped arrow. – Luigi Nov 16 '12 at 10:16
4

When you say

\draw[<->] (imgan.east)--(scrpts);

your are drawing an arrow from coordinate imgan.east to coordinate scrpts.center but the arrow will stop at scrpts border.

If you want to draw an arrow from imgan.east to the intersection point between an horizontal line through imgan.east and a vertical line through scrpts.west you can use the special syntax

\draw[<->] (imgan.east) -- (imgan.east-|scrpts.west);

And because scrpts.west and scrpts.center are on the same horizontal line, you can avoid some typing with (imgan.east-|scrpts).

Changing

\draw[<->] (imgan.east) -- (scrpts);
\draw[<->] (thrman.east) -- (scrpts);
\draw[<->] (thrman.west) -- (lib);
\draw[<->] (imgan.west) -- (lib);
\draw[<->] (dio.west) -- (lib);
\draw[<->] (daemon.west) -- (lib);

to

\draw[<->] (thrman.east) -- (thrman.east-|scrpts.west);
\draw[<->] (thrman.west) -- (lib.east|-thrman);
\draw[<->] (imgan.west) -- (lib.east|-imgan);
\draw[<->] (dio.west) -- (lib.east|-dio);
\draw[<->] (daemon.west) -- (lib.east|-daemon);

you will get the desired result.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.