I understand that there are some questions here regarding the block diagrams. However, I am strongly interested in one particular style shown as below:

enter image description here

This is a picture from a paper. As can be seen, the text can be selected there. So it is not an attached picture. I suppose it is done by LaTeX.

Could anyone point me to the right direction to achieve this?

(I specially LOVE the colored "thin grid"! It is much more beautiful than the fully filled color!)

3 Answers 3


This is a start of an answer: later I will come back with more details.

First of all, for element positioning you can refer to High level digital design in TikZ and Replicate this chart using LaTeX.

The code:



\begin{tikzpicture}[block/.style={draw,fill=white,rectangle,minimum width=4cm,anchor=south},

% = = = = = = =
% First part

\node[block,text width=3.85cm,align=center](net) at (0,0){Reading of network\\ interfaces and sensors};
\draw[-stealth]($(net.north west)!0.45!(net.north)$)--++(0,0.75)
node[block,minimum width=1.5cm](rec){Recognition};
\draw[-stealth]($(net.north east)!0.45!(net.north)$)--++(0,0.75)
node[block,minimum width=1.5cm](loc){Localization};
node[block,minimum width=1.5cm](sens){Driving Sensing};
node[block](lctr){Location and trajectories}; % just for positioning
node[block](mb){Mobility model};

% grid
\begin{scope}[on background layer]
\draw[yellow!90!red]($(net.south west)-(0.4,0.2)$)
grid[step=1.75pt]($(mb.north east)+(0.4,0.2)$);
\draw($(net.south west)-(0.4,0.2)$)rectangle($(mb.north east)+(0.4,0.2)$);
\node[below of=net] {Private Phone};

% = = = = = = =
% Second part
\node[block] (carr) at (6.5,0){Carpooling request};
\draw[stealth-]($(math.north west)!0.45!(math.north)$)--++(0,0.75)
node[block,minimum width=1.65cm,text width=1.55cm,align=center](tp){Trajectory\\ Prediction};
\draw[stealth-]($(math.north east)!0.45!(math.north)$)--++(0,0.75)
node[block,minimum width=1.65cm,text width=1.55cm,align=center](pe){Position\\ Estimation};
node[block](avm){Available vehicle mobility}; % just for positioning
node[block](vmd){Vehicle mobility database};
% grid
\begin{scope}[on background layer]
\draw[blue!60!cyan]($(carr.south west)-(0.4,0.2)$)
grid[step=1.75pt]($(vmd.north east)+(0.4,0.2)$);
\draw($(carr.south west)-(0.4,0.2)$)rectangle($(vmd.north east)+(0.4,0.2)$);
\node[below of=carr] {Carpooling Server};
% = = = = = = =
% Second part
% 1:
\draw[red,-stealth](mb)--(vmd)node[midway,above,text width=2cm,align=center]{(1) Crowd Sourcing};
% 2: solution that might be improved with the orthopath library
\draw[red,-stealth](sens.east)--++(2,0)|-(avm)node[pos=0.75,below,text width=2cm,align=center]{(2)\\ Activating};
% 3: 
\draw[dashed,red,-stealth](loc.east)--++(1,0)|-(math)node[pos=0.55,below,text width=2cm,align=center]{(3)\\ Correcting};


The result:

enter image description here

  • OMG, beautiful! It would be the best if you can show me the inter-block red connections there. Thank you so much! Wait for your updates! :) Sep 12, 2013 at 7:10
  • 1
    There is a missing indent at \end{document}. Unfortunately this can not be fixed with an simple edit, because inserting 4 spaces does not full fill the criterion on "at least 6 characters" to be able to edit it Sep 12, 2013 at 15:58
  • @samcarter: right, thanks. It's at the end, but I forgot to apply the markdown. :) Sep 12, 2013 at 17:15
  • May I ask you a follow-up question? Say if I have it in my paper, as you can see the code may be quite long, so it may not be very good to just insert the whole block into the words. So is it possible to put it at the the end of the .tex file and give it a label and call it between the words like calling a function in C? Thanks! Sep 26, 2013 at 8:07
  • @perfectionm1ng: there's a number of ways to make it. The simplest one I see is to put the code of the diagram in a separate .tex file, say diagram.tex. Then in you main .tex file you will say \input{diagram.tex}. Sep 26, 2013 at 8:35

My solution uses:

  • the backgrounds library to place the grid node behind all other nodes,
  • the patterns library as well as a definition for a thinner grid pattern for the grid nodes (there is also a crosshatch pattern that would suit the diagram better),
  • my positioning-plus library for keys like west below and span vertical,
  • the fit library (loaded by positioning-plus?) and
  • my paths.ortho library (files/origin) which is updated including keys like |* and *| developed originally for TeXwelt.de.

I opted for a line-break in the Driving Sensing node and a higher Carpooling request node. I also wouldn’t use that grid background here but maybe just a whitened filling.


  @edges to/.code={{{% three braces to protect \pgfeov
    \pgfutil@ifnextchar[{\pgfkeysvalueof{/tikz/@@edges to/.@cmd}}
                        {\pgfkeysvalueof{/tikz/@@edges to/.@cmd}[]}#1\pgfeov}}},
  @@edges to/.style args={[#1]#2}{insert path={edge[#1] (#2) (#2)}},
  edges to/.style={@edges to/.list={#1}}}
\pgfdeclarepatternformonly{thinner grid}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{2pt}{2pt}}
  node distance=+.5cm and +2cm,
  block/.style={align=center, draw, thin, fill=white, shape=rectangle, text depth=+0pt},
  big block/.style={block, minimum width=+4.5cm},
  small block/.style={
    block, minimum width=width("Localization")+2*(\pgfkeysvalueof{/pgf/inner xsep})}

%% Positioning
% left
\node [big block]                       (Mm) {Mobility model};
\node [big block,   below=     of Mm]   (Lt) {Location and trajectories};
\node [small block, west below=of Lt]   (DS) {Driving\\Sensing};
\node [small block, west below=of DS]   (R)  {Recognition};
\node [big block,   west below=of R] (Rnis) {Readings of network\\interfaced and sensors};
\node [small block, east above=of Rnis] (L)  {Localization};
% right
\node [big block,   right=     of Mm]  (Vmd) {Vehicle mobility database};
\node [big block,   below=     of Vmd] (Avm) {Available vehicle mobility};
\node [small block, west below=of Avm] (TP)  {Trajectory\\Prediction};
\node [small block, east below=of Avm] (PE)  {Position\\estimation};
\node [big block,   west below=of TP]  (M)   {Matching};
\node [big block,   below=     of M,
                 span vertical=Rnis]   (Cr)  {Carpooling request};

%% Connection
% left
\path[->] (Rnis) [edges to={[*|] R, DS, [|*] Lt, Mm}]
          (Rnis) [edges to={[*|] L,     [|*] Lt}]
% right
\path[->] (Vmd) [edges to={Avm, [*|] TP, [|*] M, [<-] Cr}]
          (PE) edge (TP) edge[|*] (M);

  on background layer,
  nodes={draw, inner sep=+.6666em, pattern=thinner grid},
  label position=below,
  s/.style n args={3}{ pattern color=#1, fit=#2, label=#3}
]% \hfill\null is only to suppres an underful hbox warning
  \node[s={yellow!80!black}{(Mm)(Rnis)}            {Private phone}]     {\hfill\null};
  \node[s={blue!80!black}  {(Vmd)(Cr|- Rnis.south)}{Carpooling server}] {\hfill\null};

\path[red, ->, auto,
     nodes={font=\scriptsize, align=center}
  ] (Mm) edge node {(1) Crowd \\ Sourcing}                       (Vmd)
    (L)  edge[dashed] node {(3) \\ Correcting} coordinate (@aux) (M)
    (DS) edge[to path={-| (@aux|-\tikztotarget) -- (\tikztotarget) \tikztonodes}]
              node [at start] {(2) \\ Activating}                (Avm);


enter image description here


Instead of writing the latex code, I would recommend using latexdraw, an interactive tool in which you can draw your diagram and it will generate the code for you.


You must log in to answer this question.

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