3

I've been trying to figure out how to draw a reliability block diagram and I've run into several good examples on how to draw diagrams. Here are a bunch: http://www.texample.net/tikz/examples/tag/block-diagrams/

Unfortunately, I am very new to LaTex and I have problems trying to understand which command does what. One example that I've specifically looked at is this one: http://www.texample.net/tikz/examples/nav1d/.

I would like to add parallell blocks at some places to create a diagram like the one below but I have no idea how. Any help is greatly appreciated.

enter image description here

2 Answers 2

3

For a start, this may serve some help.

enter image description here

Here is the code that generates it.

  1. Two types of node are defined with a given style.
  2. For each node an internal (Arabic, from left to right, up and down) name is assigned followed by displayed English names. Within brackets are the [relative location]
  3. Connected the lines by \draw (A)--(B) or \draw (C) |- (D) for sharp angle.

Code:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[-,auto,node distance=2cm]
\tikzstyle{point}=[coordinate]
\tikzstyle{block}=[draw, rectangle, minimum height=2em, minimum width=4em]
\node[point]  (0)                     {};
\node[point]  (1) [right of=0]        {};
\node[block]  (2) [above right of=1]  {C1};
\node[block]  (3) [right of=2]        {M1};
\node[block]  (4) [right of=3]        {S1};
\node[block]  (5) [right of=4]        {A1};
\node[point]  (6) [below right of=5]  {};
\node[block]  (7) [below right of=1]  {C2};
\node[block]  (8) [right of=7]        {M2};
\node[block]  (9) [right of=8]        {S2};
\node[block] (10) [right of=9]        {A2};
\node[point] (11) [right of=6]        {};
\draw [thick]   (7) -|  (1)   (2) -|  (1)   (0) --  (1)   (2) --  (3);
\draw [thick]   (4) --  (5)   (7) --  (8)   (9) -- (10)  (11) --  (6);
\draw [thick]  (10) -|  (6)   (6) -- (11)   (5) -|  (6);
\draw [thick]   (3) -- node  [name=sm1]{} (4);
\draw [thick]   (4) -- node  [name=sa1]{} (5);
\draw [thick]   (8) -- node  [yshift=-0.22cm, name=sm2]{} (9);
\draw [thick]   (9) -- node  [yshift=-0.22cm, name=sa2]{} (10);
\draw [thick] (sm1) -- (sm2) (sa1)--(sa2);
\end{tikzpicture}
\end{document}
3
  • @SeanAllred -- Thank you for the edits.
    – Jesse
    Commented Oct 8, 2013 at 13:53
  • No worries—something is wrong with the Markdown parser I guess. Commented Oct 8, 2013 at 16:01
  • Awesome, you are my hero \o/
    – span
    Commented Oct 8, 2013 at 17:28
2

Depending on how many and how complex the diagrams are, you may be able to construct them as a stack, as in

\documentclass{article}
\usepackage{stackengine}
\strutshortanchors{F}
\begin{document}
\def\thk{.2ex}
\def\hfht{.4cm}
\def\leadrule{\rule{1cm}{\thk}}
\def\fbx#1{\framebox[1cm][c]{#1}}
\def\readybottom{%
  \def\hrl{\rule[.5\ht\strutbox-.3\dp\strutbox]{.1cm}{\thk}}%
  \def\vrl{\rule[.5\ht\strutbox-.3\dp\strutbox]{\thk}{\hfht}}%
}
\def\readytop{%
  \def\hrl{\rule[.5\ht\strutbox-.3\dp\strutbox]{.1cm}{\thk}}%
  \def\vrl{\rule[.5\ht\strutbox-.3\dp\strutbox-\hfht+\thk]{\thk}{\hfht}}%
}
\def\bottomrow{\sffamily\small\readybottom%
  \vrl\hrl\fbx{C2}\hrl\hrl\fbx{M2}\hrl\vrl\hrl\fbx{S2}\hrl\vrl\hrl\fbx{A2}\hrl\vrl}
\def\toprow{\sffamily\small\readytop%
  \vrl\hrl\fbx{C1}\hrl\hrl\fbx{M1}\hrl\vrl\hrl\fbx{S1}\hrl\vrl\hrl\fbx{A1}\hrl\vrl}
\leadrule\stackanchor[0pt]{\toprow}{\bottomrow}\leadrule
\end{document}

enter image description here

1
  • Nice, will look into this.
    – span
    Commented Oct 8, 2013 at 17:29

You must log in to answer this question.

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