5

I would like to add a title to the block, placing the title on top of the block.

\documentclass[border=5mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{backgrounds, fit, positioning}

\begin{document}

\tikzstyle{block} = [draw, rectangle, 
                 text width=3cm, 
                 minimum height=1.7cm,
                 minimum width=3cm, 
                 fill=blue!20]

\begin{tikzpicture}[every text node part/.style={align=center}]

\node [block] (SparseRec) {Sparse \\ Reconstruction};
\node [block, below=1cm of SparseRec] (DenseRec) {Dense \\  Reconstruction};
\node [block, below=1cm of DenseRec] (MultiText) {Multi-texturing};     

\begin{scope}[on background layer]
\node [draw, double=black, dashed, distance = 3pt, fit=(SparseRec) (MultiText), fill=red, rounded corners, inner sep=.5cm] {r};
\end{scope}        

% Once the nodes are placed, connecting them is easy. 
\draw [->, line width=0.7mm] (SparseRec) -- (DenseRec);
\draw [->, line width=0.7mm] (DenseRec) -- (MultiText);

\end{tikzpicture}

\end{document}
3

Title you can write as label of red block:

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{arrows, backgrounds, fit, positioning}

\begin{document}
    \begin{tikzpicture}[%every text node part/.style={align=center}
node distance = 5mm,
 block/.style = {draw, rectangle,
                 text width=3cm,
                 minimum height=1.7cm, minimum width=3cm,
                 fill=blue!20,
                 align=center},
                    ]
\node [block] (SparseRec) {Sparse \\ Reconstruction};
\node [block, below=1cm of SparseRec] (DenseRec) {Dense \\  Reconstruction};
\node [block, below=1cm of DenseRec] (MultiText) {Multi-texturing};

\scoped[on background layer]
\node [draw, ultra thick, dashed, rounded corners, fill=red, 
       inner sep=.5cm,
       label=r,
       fit=(SparseRec) (MultiText)] {r};

% Once the nodes are placed, connecting them is easy.
\draw [->, line width=0.7mm] (SparseRec) -- (DenseRec);
\draw [->, line width=0.7mm] (DenseRec) -- (MultiText);
    \end{tikzpicture}
\end{document}

enter image description here

Addendum: with use of TikZ libraries chains the above code can become more concise:

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{arrows.meta, backgrounds, 
                chains, % added
                fit, positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 10mm,
  start chain = going below,
 block/.style = {rectangle, draw, 
                 text width=3cm, align=center,
                 minimum height=1.7cm, minimum width=3cm,
                 fill=blue!20,
                 on chain, join=by {-Triangle, line width=0.7mm}% added
                 },
                    ]
\node [block] (SparseRec) {Sparse \\ Reconstruction};
\node [block] (DenseRec)  {Dense \\  Reconstruction}; % changed (simplified)
\node [block] (MultiText) {Multi-texturing};          % changed (simplified)  

\scoped[on background layer]
\node [draw, ultra thick, dashed, rounded corners, fill=red,
       inner sep=5mm,
       label={[font=\Large\bfseries]r},
       fit=(SparseRec) (MultiText)] {};
% connecting lines are drawn by macro "join"
    \end{tikzpicture}
\end{document}

Resulted image is almost the same as obtained by the first MWE.

3

Using \path :

\begin{scope}[on background layer]
\node [draw, double=black, dashed, distance = 3pt, fit=(SparseRec) (MultiText), fill=red, rounded corners, inner sep=.5cm] {r};
\path (0,2) node[text=black] {r};
\end{scope}   

Or with \node:

\begin{scope}[on background layer]
\node [draw, double=black, dashed, distance = 3pt, fit=(SparseRec) (MultiText), fill=red, rounded corners, inner sep=.5cm] {r};
\node[text=black] at (0,2) {r};
\end{scope} 

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.