Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to improve the visual appearance of the following diagram.

\documentclass{standalone}

\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,shapes.multipart}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\usetikzlibrary{decorations.pathmorphing}

\tikzset{every fit/.append style = text badly centered} % removes underfull warnings while using fit
\tikzset{%
    default/.style = {draw, thick, align = center, shape = rectangle, minimum height = 10mm, minimum width = 20mm, text width = 15mm},
    back1/.style = {draw = none, align = center, shape = rectangle, minimum height = 15mm, minimum width = 25mm, inner sep = 2mm},
    back2/.style = {back1, draw, dashed, thick, minimum width = 30mm, inner sep = 4mm},
    terminal/.style = {draw, thick, align = center, shape = circle, text width = 10mm},
}


\begin{document}
\begin{tikzpicture}

% 
\node [default] (AAA) {AAA};
\node [default] (PPP) [right = of AAA] {NNN};
\node [default] (ZZZ) [right = of PPP] {ZZZ};
\draw [thick] (AAA) -- (PPP) -- (ZZZ);
\begin{pgfonlayer}{background}
    \node [back1, fit = (AAA) (PPP) (ZZZ) ] (FFF) {};
\end{pgfonlayer}
\node [rotate = 90, anchor = south] at (FFF.west) {\textbf{FFF}};

% 
\node [default] (QQQ1) at ($(AAA)!0.5!(PPP)$) [yshift = -20mm] {CCC};
\node [default] (QQQ2) at ($(PPP)!0.5!(ZZZ)$) [yshift = -20mm] {CCC};
\draw node [left = 1em of QQQ1] (DOTS1) {\dots};
\draw node [right = 1em of QQQ2] (DOTS2) {\dots};
\draw [thick] (QQQ1) -- (QQQ2);
\begin{pgfonlayer}{background}
    \node [back1, fit = (DOTS1) (QQQ1) (QQQ2) (DOTS2) ] (DDD) {};
\end{pgfonlayer}
\node [rotate = 90, anchor = south] at (DDD.west) {\textbf{III}};

\begin{pgfonlayer}{background}
    \node [back2, fit = (FFF) (DDD) ] (HHH) {};
\end{pgfonlayer}
%\node [rotate = 90, anchor = south] at (HHH.west) {\textbf{Network}};

%
\node [terminal] (BB1) at (AAA.west) [yshift = -60mm, xshift = 5mm] {BB};
\node [terminal] (BB2) [right = of BB1] {BB};
%\node [terminal] (BB2) at (BB1.east) [xshift = 15mm] {BB};
\draw[<->, thick] (BB1) -- (BB2);
%
\node [terminal] (BB4) at (ZZZ.east) [yshift = -60mm, xshift = -5mm] {BB};
\node [terminal] (BB3) [left = of BB4] {BB};
%\path [draw, thick, out = 295, in = 90] (HHH) edge (BB3);
%\path [draw, thick, out = 325, in = 90] (HHH) edge (BB4);

\begin{pgfonlayer}{background}
    \node [back2, fit = (BB1) (BB2) ] (CCC) {};
    \node [back2, fit = (BB3) (BB4) ] (DDD) {};
\end{pgfonlayer}
\draw[<->, thick] (BB3) .. controls +(up:40mm) and +(up:40mm) .. (BB4);

\node [anchor = north] at (CCC.south) {\textbf{CCC Mode}};
\node [anchor = north] at (DDD.south) {\textbf{XXX Mode}};
\draw [<->, thick] (HHH.south) -- (CCC.north) node [midway, left, align = center] {Assistance};

\end{tikzpicture}
\end{document}

Namely,

  1. Improve layout to be more flexibility in the nodes distance: vertical and horizontal;
  2. Text 'III' and 'FFF' shall be align at left
  3. Vertical line (that has label of Assistance), put it straight.
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted
  1. You only need to change \xnodedist and \ynodedist
  2. Position them with below=. I used rotatebox due to strange interactions.
  3. You can use the "the intersection of a vertical line through p and a horizontal line through q." notation (see PGF Manual, p. 32)

Code

\documentclass[tikz,birder=2mm]{standalone}
\usetikzlibrary{%
    shapes.geometric,%
    shapes.multipart,%
    positioning,%
    calc,%
    fit,%
    backgrounds,%
    decorations.pathmorphing}
\usepackage{lmodern}
\usepackage{mathtools}

\tikzset{every fit/.append style = text badly centered} % removes underfull warnings while using fit
\tikzset{%
    default/.style = {draw, thick, align = center, shape = rectangle, minimum height = 10mm, minimum width = 20mm, text width = 15mm},
    back1/.style = {draw = none, align = center, shape = rectangle, minimum height = 15mm, minimum width = 25mm, inner sep = 2mm},
    back2/.style = {back1, draw, dashed, thick, minimum width = 30mm, inner sep = 4mm},
    terminal/.style = {draw, thick, align = center, shape = circle, text width = 10mm},
}
\pgfmathsetmacro{\xnodedist}{2}% in cm
\pgfmathsetmacro{\ynodedist}{1.5}% in cm

\begin{document}

\begin{tikzpicture}
    \node [default] (AAA) {AAA};
    \node [default] (PPP) [right=\xnodedist of AAA] {NNN};
    \node [default] (ZZZ) [right=\xnodedist of PPP] {ZZZ};
    \node (FFF_label) [left=0.2*\xnodedist of AAA.west] {\rotatebox{90}{\textbf{FFF}}};
    \draw [thick] (AAA) -- (PPP) -- (ZZZ);
    \node [back1, fit=(AAA)(PPP)(ZZZ)(FFF_label)] (FFF) {};

    \node [default] (QQQ1) [below=\ynodedist of $(AAA)!0.5!(PPP)$] {CCC};
    \node [default] (QQQ2) [right=\xnodedist of QQQ1] {CCC};
    \node (III_label) [below=\ynodedist of FFF_label.center] {\rotatebox{90}{\textbf{III}}};
    \node [left=1em of QQQ1] (DOTS1) {\dots};
    \node [right=1em of QQQ2] (DOTS2) {\dots};
    \draw [thick] (QQQ1) -- (QQQ2);
    \node [back1, fit= (DOTS1)(QQQ1)(QQQ2)(DOTS2)(III_label)] (DDD) {};

    \node [back2, fit= (FFF)(DDD)] (HHH) {};

    \node [terminal] (BB1) [below=1.5*\ynodedist of HHH.south west, xshift=0.5*\xnodedist*1cm] {BB};
    \node [terminal] (BB2) [right=0.5*\xnodedist of BB1] {BB};

    \draw[<->, thick] (BB1) -- (BB2);

    \node [terminal] (BB4) [below=1.5*\ynodedist of HHH.south east, xshift=-0.5*\xnodedist*1cm] {BB};
    \node [terminal] (BB3) [left=0.5*\xnodedist of BB4] {BB};

    \node [back2, fit = (BB1) (BB2) ] (CCC) {};
    \node [back2, fit = (BB3) (BB4) ] (DDD) {};
    \draw[<->, thick] (BB3) to[out=90,in=180] ($(DDD.north |- HHH.south)+(0,0.3)$) to[out=0,in=90] (BB4);

    \node [below] at (CCC.south) {\textbf{CCC Mode}};
    \node [below] at (DDD.south) {\textbf{XXX Mode}};
    \draw [<->, thick] (CCC.north) -- (CCC.north |- HHH.south) node [midway, left, align = center] {Assistance};
\end{tikzpicture}
\end{document}

Output (\xnodedist{2} & \ynodedist{1.5})

enter image description here

Output (\xnodedist{3} & \ynodedist{3})

enter image description here

share|improve this answer
    
For the first part, one could simply set node distance=\ynodedist and \xnodedist and drop the \?nodedist part in the options of the nodes. –  Qrrbrbirlbel Jun 4 '13 at 19:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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