I made a quick sketchup of what I want:

enter image description here

What would be a good way to generate a blockdiagram like this?


This can be done very easily with TikZ and the matrix library.

Even though the PGF/TikZ manual as well as How to insert a linebreak in a TikZ matrix node? say that it is possible to use a \\ linebreak inside a matrix of nodes as long it is enclosed in { } it did not work for me, instead I used a simple \node (with the \twoRows macro). Any options and settings are inherited by this manual node, too.

\foreach loops help to connect the nodes of the matrix without repeating the same code for many rows and/or columns.


\newcommand*{\twoRows}[2]{\node {$#1$\\$\scriptstyle #2$};}
  -|/.style={to path={-| (\tikztotarget) \tikztonodes}},
  |-/.style={to path={|- (\tikztotarget) \tikztonodes}},
  % auxiliary styles
  set row cells to/.style n args={3}{% #1 = row, #2 = columns, #3 = style
    @set row cells to/.style={row #1 column ##1/.append style={nodes={#3}}},
    @set row cells to/.list={#2}
  set rows to/.style 2 args={% #1 = rows, #2 = style
    @set rows to/.style={row ##1/.append style={#2}},
    @set rows to/.list={#1}
  shorten >=2\pgflinewidth,
    minimum width=5em,
    minimum size=1.5em,
    inner sep=+0pt,
    path picture={% the plus
      \draw[shorten >=+0pt]
            (path picture bounding box.west) -- (path picture bounding box.east)
            (path picture bounding box.north) -- (path picture bounding box.south);
  column sep=.5cm,
  row sep=.5cm,
  every node/.append style={anchor=center,text depth=+2pt},
  column 1/.style={nodes=rect},
  set row cells to={1}{2,...,5}{sqplus},
  set row cells to={4}{2,...,5,7}{sqplus},
  set rows to={2,3,5,6,7}{nodes=rect},
  row 4 column 6/.style={nodes=rect},
  row 6 column 5/.style={nodes=sqplus},
  matrix of nodes,
  ] (m) {
    0000\ldots 0 & {}    & {}    &[1cm] {} & {}                                \\
                 & \twoRows{E_{k,N}}{1000\ldots0} 
                         & \twoRows{E_{k,N}}{1000\ldots1}
                                 & \twoRows{E_{k,N}}{1000\ldots a-1} 
                                             & \twoRows{E_{k,N}}{1000\ldots a}   \\
                 & $A_1$ & $A_2$ & $A_{a-1}$ & $A_a$                             \\
    0000\ldots 0 & {}    & {}    & {}        & {}    & \twoRows{E_{k,N}}{m} & {} \\
                 & $M_1$ & $M_2$ & $M_{m-1}$ & $M_m$                             \\
                 & \twoRows{E_{k,N}}{0} 
                         & \twoRows{E_{k,N}}{1}
                                 & \twoRows{E_{k,N}}{m-2}
                                             & {}    & \twoRows{E_{k,N}}{m}      \\
                 & $C_1$ & $C_2$ & $C_{m-1}$ & $C_m$ &                      & $T$\\

  \foreach \Row in {2,6}
    \path (m-\Row-3) -- node {$\cdots$} (m-\Row-4);

  \foreach \Row in {1,4}
    \foreach \cellStart[evaluate={\cellEnd={int(\cellStart+1)}}] in {1,...,4}
      \path[->] (m-\Row-\cellStart) edge (m-\Row-\cellEnd);

  \foreach \Column in {2,...,5} 
    \path[->] (m-3-\Column) edge (m-2-\Column)
              (m-2-\Column) edge (m-1-\Column)
              (m-5-\Column) edge (m-4-\Column) edge (m-6-\Column)
              (m-6-\Column) edge (m-7-\Column)
  \path[->] (m-4-5) edge     (m-4-6)
            (m-4-6) edge     (m-4-7)
            (m-4-7) edge[|-] (m-6-6) edge (m-7-7)
            (m-6-6) edge     (m-6-5)
            (m-1-5) edge[-|] (m-4-7)


enter image description here

  • Astonishing! Thanks a lot, +1 and accepted. – orlp Jul 6 '13 at 9:33

Have you tried to draw this diagram using, for instance, Libreoffice draw and then exporting it to eps or pdf? You can easily insert PDF or EPS graphics in LaTeX. This is more of like a practical answer, rather than a technical one.

I tell you this because a lot of time to produce a diagram like this is required, especially when you don't know Tikz or Pstricks very well.

  • Could you please point out how exactly you draw the the cross on the circles? – Charlie Jul 7 '13 at 19:41

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.