# Summarize a set of equations with arrows, boxes and circled numbers

I have a set of equations summarized in this way:

The code that produces this is the following:

\documentclass[12pt]{article}
\usepackage{empheq}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{amsmath}

\begin{document}

\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\begin{subequations}
\begin{empheq}[box=\widefbox]{align}
%
\Aboxed{a = & b + c + d}
\nonumber \\
& d = f + g
\nonumber \\
f = m/4
\nonumber \\
&
d = j + k
\nonumber \\
j = n\cdot3/4
\nonumber \\
& d = l + o
\nonumber \\
\Aboxed{& d = m/4 + q + n\cdot 3/4 + k + l + 0 }
\nonumber \\
\Aboxed{&c = p + q}
\nonumber \\
p = h/2 + h/2
\nonumber \\
\Aboxed{&b = r + s}
\nonumber \\
\Aboxed{&t = u + w}
\nonumber \\  \nonumber\\
\Aboxed{a = & b + c + d}
\nonumber \\ \nonumber\\
\Aboxed{a = & zz + z'}
\nonumber \\ \nonumber\\
\end{empheq}
\end{subequations}

\end{document}


I would like to produce something similar to this:

Is there a way to achieve those arrows, red boxes and circled numbers 1, 2 and 3 ?

Update:

Following @Ignasi's approach, when I try to apply this to the real example, I encounter quite a lot of difficulties, this is the nearest result I could achieve:

where:

1) The circled numbers and the arrows appear in the following page, instead of next to the equations (see image)

2) I could not manage to align the J[p] equations.

3) I could not manage to box the last equation,

4) Is there a way to caption this scheme?

This is the code to where I reached so far:

\documentclass[12pt]{article}
\usepackage{empheq}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark, positioning}

\begin{document}

\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}

\begin{subequations}
\begin{empheq}[box=\widefbox]{align}
%
%
\tikzmark{1}\Aboxed{
E [\rho ] = & \underbrace{ T[\rho ] + V_{ee}[\rho ] }_{=\,\, F[\rho ]} + V_{ne}[\rho]
}
\nonumber \\
& %
\tikzmark{2}
V_{ne}[\rho ] = \int \rho \left ( \mathbf{r} \right ) v_{\text{ext}} \left ( \mathbf{r} \right ) \mathrm{d}\mathbf {r}
\nonumber \\
v_{\text{ext}}\left ( \mathbf{r}_{i} \right ) = - \sum_{A=1}^{M} \frac{Z_{A}}{r_{iA}}
\nonumber \\
&
\tikzmark{3}
V_{ne}[\rho ] =  \int -  \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}} \rho \left ( \mathbf{r}_{1} \right )  \mathrm{d}\mathbf {r}_{1}
\nonumber \\
\rho (\mathbf{r}) \equiv \rho_{\text{S}}(\mathbf{r}) = \sum_{i=1}^{N} \left | \varphi_{i} \left ( \mathbf{x} \right ) \right |^{2} = \rho_{0}(\mathbf{r})
\nonumber \\
& %
\tikzmark{4}
V_{ne}[\rho ] =  \int -  \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}}  \sum_{i=1}^{N} \left | \varphi_{i} \left ( \mathbf{x}_{1} \right ) \right |^{2}  \mathrm{d}\mathbf {r}_{1}
\nonumber \\
\tikzmark{5}
\Aboxed{
&V_{ne}[\rho ] =  - \sum_{i=1}^{N} \int   \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}}  \left | \varphi_{i} \left ( \mathbf{x}_{1} \right ) \right |^{2}  \mathrm{d}\mathbf {r}_{1}
}
\nonumber \\
\tikzmark{6}
\Aboxed{
&V_{ee}[\rho ] = J[\rho ] + V_{\text{non-classical}}[\rho ]
}
\nonumber \\
& \qquad \qquad J[\rho]  = \frac{1}{2} \int \int \frac{\rho(\mathbf{r}_{1})\rho(\mathbf{r}_{2})}{r_{12}} \mathrm{d}\mathbf {r}_{1} \mathrm{d}\mathbf {r}_{2}  \nonumber \\
& \qquad \qquad \qquad  \rho (\mathbf{r}) \equiv \rho_{\text{S}}(\mathbf{r}) = \sum_{i=1}^{N} \left | \varphi_{i} \left ( \mathbf{x} \right ) \right |^{2} = \rho_{0}(\mathbf{r})  \nonumber \\
&
\Aboxed{
J[\rho]  = \frac{1}{2} \sum_{i=1}^{N} \sum_{j=1}^{N} \int \int \left | \varphi_{i} (\mathbf{r}_{1}) \right |^{2} \frac{1}{r_{12}} \left | \varphi_{j} (\mathbf{r}_{2}) \right |^{2} \mathrm{d}\mathbf {r}_{1}  \mathrm{d}\mathbf {r}_{2}  }
\nonumber \\
\tikzmark{7}
\Aboxed{
&T[\rho ]  = T_{\text{S}}[\rho ] + T_{\text{C}}[\rho ]
}
\nonumber \\
\nonumber \\
\tikzmark{8}
\Aboxed{
E_{\text{XC}} [\rho] &= \left ( T[\rho] - T_{\text{S}}[\rho] \right ) + \left ( E_{ee}[\rho] - J[\rho] \right ) = T_{\text{C}}[\rho] + V_{\text{non-classsical}}[\rho]
}
\nonumber \\
\tikzmark{9}
\Aboxed{
E [\rho ] = & T_{\text{S}}[\rho ] + J[\rho] +  V_{ne}[\rho ] + E_{\text{XC}} [\rho]
}
\nonumber \\
%\begin{empheq}[box=\fbox]{align}
%\end{subequations}
%
\tikzmark{10}
E [\rho ] = &  -\frac{1}{2}\sum_{i=1}^{N} \expval{\nabla^{2}}{\varphi _{i}} +  \frac{1}{2} \sum_{i=1}^{N} \sum_{j=1}^{N} \int \int \left | \varphi_{i} (\mathbf{r}_{1}) \right |^{2} \frac{1}{r_{12}} \left | \varphi_{j} (\mathbf{r}_{2}) \right |^{2} \mathrm{d}\mathbf {r}_{1}  \mathrm{d}\mathbf {r}_{2}
\nonumber \\
&  + E_{\text{XC}} [\rho] - \sum_{i=1}^{N} \int   \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}}  \left | \varphi_{i} \left ( \mathbf{x}_{1} \right ) \right |^{2}  \mathrm{d}\mathbf {r}_{1}\\
%}
%\end{empheq}
\end{empheq}
\end{subequations}

\begin{tikzpicture}[remember picture, overlay]
\foreach \i [count=\ni] in {1,9,10}
\node[draw, circle, inner sep=2pt, left=2mm of pic cs:\i, yshift=.5ex] (c\ni) {\ni};

\foreach \i in {2,...,4}
\draw[->] ([shift={(2mm,-4.pt)}]pic cs:1) |- ([shift={(-4pt,.5ex)}]pic cs:\i);
\foreach \i in {5,...,8}
\draw[->] ([shift={(2mm,-4.pt)}]pic cs:1) |- ([yshift=.5ex]pic cs:\i);
\end{tikzpicture}

• 1. Circled numbers in next page because your equations doesn't fit in one page. Reduce top and bottom margins. 2. \Aboxed needs one and only one & inside. Change \Aboxed by \fbox{$\displaymath.... 3. Same problem with \Aboxed, it's only valid for one line equations. I don't know if a nested boxed empheq will work. 4. Use \captionof command to caption non floating environments. – Ignasi Oct 3 '17 at 10:27 ## 2 Answers A simple solution with pstricks. I define an \Acolorboxed command, mimicked on the \Aboxed command from mathtools: \documentclass[12pt]{article} \usepackage{empheq} \usepackage[margin=2.5cm]{geometry} \usepackage[svgnames]{xcolor} \usepackage{pst-node, multido} \usepackage{auto-pst-pdf} % to compile with pdflatex \makeatletter \colorlet{framecolor}{Tomato} \colorlet{bgcolor}{white} \newcommand{\fcolorboxed}[3]{\fcolorbox{#1}{#2}{\m@th$\displaystyle#3$}} \newcommand\Acolorboxed[1]{\let\bgroup{\romannumeral-}\@Acolorboxed#1&&\ENDDNE} \def\@Acolorboxed#1&#2&#3\ENDDNE{% \ifnum0={}\fi \setbox \z@ \hbox{$\displaystyle#1{}\m@th\kern\fboxsep \kern\fboxrule }% \edef\@tempa {\kern \wd\z@ &\kern -\the\wd\z@ \fboxsep \the\fboxsep \fboxrule \the\fboxrule }\@tempa \fcolorboxed{framecolor}{bgcolor}{#1#2}% } \makeatother \def\ma-ht{\fontdimen22\textfont2} \newcommand{\myeqlabel}[1]{\cput[linecolor=Tomato](-2em,0.7ex){\color{Tomato}#1}} \begin{document} \newcommand*\widefbox[1]{\hspace{2em}#1\hspace{2em}} \begin{postscript} \begin{subequations} \begin{empheq}[box=\widefbox]{align} \myeqlabel{1}\Acolorboxed{\rnode[b]{I}{a} = & b + c + d} \nonumber \\ \pnode[0,\ma-ht]{E1}& d = \begin{aligned}[t] & f + g \\ & f = m/4 \end{aligned} \nonumber\\ \pnode[0,\ma-ht]{E2}& d = \begin{aligned}[t] & j + kr \\ & j = n\cdot3/4 \end{aligned} \nonumber \\ \pnode[0,\ma-ht]{E3} & d = l + o \nonumber \\ \pnode[0,\ma-ht]{E4}\Aboxed{& d = m/4 + q + n\cdot 3/4 + k + l + 0 } \nonumber \\ \pnode[0,\ma-ht]{E5}\Aboxed{&c = p + q} \nonumber \\ & \phantom{c ={}} p = h/2 + h/2 \nonumber \\ \pnode[0,\ma-ht]{E6}\Aboxed{&b = r + s} \nonumber \\ \pnode[0,\ma-ht]{E7}\Aboxed{&t = u + w} \nonumber \\[\baselineskip] \myeqlabel{2}\Acolorboxed{a = & b + c + d} \nonumber \\[\baselineskip] \myeqlabel{3}\Acolorboxed{a = & zz + z'} \nonumber \\ \nonumber\\ \end{empheq} \end{subequations} \psset{linewidth =0.4pt, linejoin=1, arrowinset=0.12, angleA=-90, angleB =-180, arrows=->, nodesepB=0.4em, nodesepA=1.44\fboxsep} \multido{\i =1 + 1}{7}{\ncangle{I}{E\i}} \end{postscript} \end{document}  Edit: A code for the real situation. Note double integrals are not obtained with two \int commands (which results in a very bad spacing), but with \iint. We have a tighter spacing loading the esint package. I also simplified the code for the maths part defining \dd for the differential symbol in integrals (with a better spacing), an \abs command for the absolute value and had to define \expval (which is not a standard LaTeX command) with the \DeclarePairedDelimiterX command from mathtools. Final remark: you don't have to load amsmath when you load empheq since it loads mathtools, which loads the former. \documentclass[11pt]{article} \usepackage{empheq, nccmath} \usepackage[margin=2.5cm]{geometry} \usepackage{caption} \usepackage[svgnames]{xcolor} \usepackage{pst-node, multido} \usepackage{auto-pst-pdf} % to compile with pdflatex \makeatletter \colorlet{framecolor}{Tomato} \colorlet{bgcolor}{white} \newcommand{\fcolorboxed}[3]{\fcolorbox{#1}{#2}{\m@th\displaystyle#3$}} \newcommand\Acolorboxed[1]{\setlength{\fboxrule}{0.8pt}\let\bgroup{\romannumeral-}\@Acolorboxed#1&&\ENDDNE} \def\@Acolorboxed#1&#2&#3\ENDDNE{% \ifnum0={}\fi \setbox \z@ \hbox{$\displaystyle#1{}\m@th\kern\fboxsep \kern\fboxrule }% \edef\@tempa {\kern \wd\z@ &\kern -\the\wd\z@ \fboxsep \the\fboxsep \fboxrule \the\fboxrule }\@tempa \fcolorboxed{framecolor}{bgcolor}{#1#2}% } \makeatother \def\ma-ht{\fontdimen22\textfont2} \newcommand{\myeqlabel}[1]{\cput[linecolor=Tomato](-1.5em,0.7ex){\color{Tomato}#1}} \newcommand*{\dd}{\mathop{}\!\mathrm{d}} % \usepackage{esint} \DeclarePairedDelimiter\abs{\lvert}{\rvert} \DeclarePairedDelimiterX\expval[2]{\langle}{\rangle}% {#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#1} \usepackage{tikz} \usetikzlibrary{tikzmark, positioning} \begin{document} \newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}} \begin{postscript} \begin{subequations} \begin{empheq}[box=\widefbox]{align} % \myeqlabel{1}\Acolorboxed{\pnode[1em, -4.27ex]{I}% E [\rho ]= & \underbrace{T[\rho ] + V_{ee}[\rho ] }_{=\,\, F[\rho ]} + V_{ne}[\rho] } \nonumber \\ & \begin{alignedat}{2} \pnode[0,\ma-ht]{E1}V_{ne}[\rho ] & = & & \int \rho \left ( \mathbf{r} \right ) v_{\text{ext}} \left ( \mathbf{r} \right ) \dd\mathbf {r} \\ & & &\,v_{\text{ext}}\left ( \mathbf{r}_{i} \right ) = - \sum_{A=1}^{M} \frac{Z_{A}}{r_{iA}} \\[-1ex] \pnode[0,\ma-ht]{E2} V_{ne}[\rho ] & = & & \int - \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}} \rho \left ( \mathbf{r}_{1} \right ) \dd\mathbf {r}_{1} \\ & & & \, \rho (\mathbf{r}) \equiv \rho_{\text{S}}(\mathbf{r}) = \sum_{i=1}^{N}\abs{\varphi_{i} \left ( \mathbf{x} \right )}^{2} = \rho_{0}(\mathbf{r}) \\ \pnode[0,\ma-ht]{E3} V_{ne}[\rho ] & = & & \int - \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}} \sum_{i=1}^{N} \abs{\varphi_{i} \left (\mathbf{x}_{1} \right) }^{2} \mathrm{d}\mathbf {r}_{1} \end{alignedat}\nonumber \\ \pnode[0,\ma-ht]{E4} \Aboxed{ &V_{ne}[\rho ]= - \sum_{i=1}^{N} \int \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}} \abs{\varphi_{i} \left ( \mathbf{x}_{1} \right )}^{2} \dd\mathbf {r}_{1} } \nonumber\\ \pnode[0,\ma-ht]{E5} \Aboxed{% & V_{ee}[\rho ] = J[\rho ] + V_{\text{non-classical}}[\rho ] } \nonumber \\ & \begin{aligned}\phantom{V_{ee}[\rho ] ={}} J[\rho] = {} & \mfrac{1}{2} \iint \frac{\rho (\mathbf{r}_{1})\rho (\mathbf{r}_{2})}{r_{12}} \dd\mathbf {r}_{1} \dd\mathbf {r}_{2} \\ & \rho (\mathbf{r}) \equiv \rho_{\text{S}}(\mathbf{r}) = \sum_{i=1}^{N} \abs{\varphi_{i} \left ( \mathbf{x} \right )}^{2} = \rho_{0}(\mathbf{r}) r \\ \Aboxed{ J[\rho]= & \mfrac{1}{2} \sum_{i=1}^{N} \sum_{j=1}^{N} \iint \abs*{\varphi_{i} (\mathbf{r}_{1})}^{2} \frac{1}{r_{12}} \abs*{\varphi_{j} (\mathbf{r}_{2})}^{2} \dd\mathbf {r}_{1} \dd\mathbf {r}_{2}} \end{aligned} \nonumber \\ \pnode[0,\ma-ht]{E6} \Aboxed{ &T[\rho ] = T_{\text{S}}[\rho ] + T_{\text{C}}[\rho ] } \nonumber \\ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% &\phantom{T[\rho ] ={}} T_{\text{S}}[\rho ] = -\mfrac{1}{2}\sum_{i=1}^{N}\expval*{\nabla^{2}}{\varphi _{i}}% \nonumber \\ \pnode[0,\ma-ht]{E7} \Aboxed{ & E_{\text{XC}} [\rho] = \left ( T[\rho] - T_{\text{S}}[\rho] \right ) + \left ( E_{ee}[\rho] - J[\rho] \right ) = T_{\text{C}}[\rho] + V_{\text{non-classical}}[\rho] } \nonumber \\ \myeqlabel{2} \Acolorboxed{ E [\rho ] &= T_{\text{S}}[\rho ] + J[\rho] + V_{ne}[\rho ] + E_{\text{XC}} [\rho] } \nonumber \\ \myeqlabel{3} \Acolorboxed{E [\rho ] &=\begin{aligned}[t]-\mfrac{1}{2}\sum_{i=1}^{N} % \expval*{\nabla^{2}}{\varphi _{i}} + \mfrac{1}{2} \sum_{i=1}^{N} \sum_{j=1}^{N} \iint \abs{\varphi_{i} (\mathbf{r}_{1})}^{2} \frac{1}{r_{12}} \abs*{\varphi_{j} (\mathbf{r}_{2})}^{2} \dd\mathbf {r}_{1} \dd\mathbf {r}_{2} \\[-1.5ex] + E_{\text{XC}} [\rho] - \sum_{i=1}^{N} \int \sum_{A=1}^{M} \frac{Z_{A}}{r_{1A}} \abs{\varphi_{i} \left ( \mathbf{x}_{1} \right )}^{2} \dd\mathbf {r}_{1} \end{aligned}\nonumber} \\ \end{empheq} \end{subequations} % \psset{linewidth=0.6pt, linejoin=1, linecolor=LightSteelBlue, linearc=0.08, arrowinset=0, angleA=-90, angleB=-180, arrows=->, nodesepB=0.4em, nodesepA=1.44\fboxsep} \multido{\i=1+1}{3}{\ncangle{I}{E\i}} \psset{nodesepB=0em} \multido{\i=4+1}{4}{\ncangle{I}{E\i}} \captionof{figure}{Some nice equations} \end{postscript} \end{document}  • Thanks a lot for your approach. I am trying to apply this to the real example (see below), but I cannot manage to obtain the result. For the moment, we can forget about the coloured scheme, it is more important to get the scheme right. I would appreciate if you could have a look. Million Thanks – DavidC. Oct 2 '17 at 21:14 • Did you compile with pdflatex -shell-escape? – Bernard Oct 2 '17 at 21:20 • Yes, exactly, I compiled with pdflatex -shell-escape – DavidC. Oct 2 '17 at 21:29 • @DavidC.: I've added a code for your real situation. Please check if it compiles for you. – Bernard Oct 3 '17 at 13:09 You can use tikzmarks inside the empheq environments and later on, draw the numbers and connections: \documentclass[12pt]{article} \usepackage{empheq} \usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{tikzmark, positioning} \begin{document} \newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}} \begin{subequations} \begin{empheq}[box=\widefbox]{align} % \tikzmark{1}\Aboxed{a = & b + c + d} \nonumber \\ & \tikzmark{2} d = f + g \nonumber \\ & \qquad f = m/4 \nonumber \\ & \tikzmark{3} d = j + k \nonumber \\ & \qquad j = n\cdot3/4 \nonumber \\ &\tikzmark{4} d = l + o \nonumber \\ \tikzmark{5}\Aboxed{& d = m/4 + q + n\cdot 3/4 + k + l + 0 } \nonumber \\ \tikzmark{6}\Aboxed{&c = p + q} \nonumber \\ & \qquad p = h/2 + h/2 \nonumber \\ \tikzmark{7}\Aboxed{&b = r + s} \nonumber \\ \tikzmark{8}\Aboxed{&t = u + w} \nonumber \\ \nonumber\\ \tikzmark{9}\Aboxed{a = & b + c + d} \nonumber \\ \nonumber\\ \tikzmark{10}\Aboxed{a = & zz + z'} \nonumber \\ \nonumber \end{empheq} \end{subequations} \begin{tikzpicture}[remember picture, overlay] \foreach \i [count=\ni] in {1,9,10} \node[draw, circle, inner sep=2pt, left=2mm of pic cs:\i, yshift=.5ex] (c\ni) {\ni}; \foreach \i in {2,...,4} \draw[->] ([shift={(2mm,-4.pt)}]pic cs:1) |- ([shift={(-4pt,.5ex)}]pic cs:\i); \foreach \i in {5,...,8} \draw[->] ([shift={(2mm,-4.pt)}]pic cs:1) |- ([yshift=.5ex]pic cs:\i); \end{tikzpicture} \end{document}  Update: red color addition. With Bernard's Acolorboxed definition and a little change in round labels, it's easy to get the desired result: \documentclass[12pt]{article} \usepackage{empheq} \usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{tikzmark, positioning} \makeatletter \colorlet{framecolor}{red} \colorlet{bgcolor}{white} \newcommand{\fcolorboxed}[3]{\fcolorbox{#1}{#2}{\m@th\displaystyle#3$}} \newcommand\Acolorboxed[1]{\let\bgroup{\romannumeral-}\@Acolorboxed#1&&\ENDDNE} \def\@Acolorboxed#1&#2&#3\ENDDNE{% \ifnum0={}\fi \setbox \z@ \hbox{$\displaystyle#1{}\m@th\$\kern\fboxsep \kern\fboxrule }%
\edef\@tempa {\kern \wd\z@ &\kern -\the\wd\z@ \fboxsep
\the\fboxsep \fboxrule \the\fboxrule }\@tempa \fcolorboxed{framecolor}{bgcolor}{#1#2}%
}
\makeatother

\begin{document}

\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}

\begin{subequations}
\begin{empheq}[box=\widefbox]{align}
%
\tikzmark{1}\Acolorboxed{a = & b + c + d}
\nonumber \\
& \tikzmark{2} d = f + g
\nonumber \\
f = m/4
\nonumber \\
&
\tikzmark{3} d = j + k
\nonumber \\
j = n\cdot3/4
\nonumber \\
&\tikzmark{4} d = l + o
\nonumber \\
\tikzmark{5}\Aboxed{& d = m/4 + q + n\cdot 3/4 + k + l + 0 }
\nonumber \\
\tikzmark{6}\Aboxed{&c = p + q}
\nonumber \\
p = h/2 + h/2
\nonumber \\
\tikzmark{7}\Aboxed{&b = r + s}
\nonumber \\
\tikzmark{8}\Aboxed{&t = u + w}
\nonumber \\  \nonumber\\
\tikzmark{9}\Acolorboxed{a = & b + c + d}
\nonumber \\ \nonumber\\
\tikzmark{10}\Acolorboxed{a = & zz + z'}
\nonumber \\ \nonumber
\end{empheq}
\end{subequations}

\begin{tikzpicture}[remember picture, overlay]
\foreach \i [count=\ni] in {1,9,10}
\node[draw, red, circle, inner sep=2pt, left=2mm of pic cs:\i, yshift=.5ex] (c\ni) {\ni};

\foreach \i in {2,...,4}
\draw[->] ([shift={(2mm,-4.pt)}]pic cs:1) |- ([shift={(-4pt,.5ex)}]pic cs:\i);
\foreach \i in {5,...,8}
\draw[->] ([shift={(2mm,-4.pt)}]pic cs:1) |- ([yshift=.5ex]pic cs:\i);
\end{tikzpicture}

\end{document}

• Thanks a lot for all your effort. I have been quite a long time trying to apply this to the real example, but I have encountered the difficulties explained below. Could you please help me to achieve this? Again, thank you very much – DavidC. Oct 2 '17 at 21:10
• @DavidC. Answer updated with red labels and boxes. – Ignasi Oct 3 '17 at 7:32
• Thank you for your update. Please see updated post: I am finding difficulties to apply this code to the real example. Thanks again – DavidC. Oct 3 '17 at 9:16