Using the following code which produces the following drawing as a part of a more complicated drawing.

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\begin{document}
\begin{minipage}{\textwidth}
\begin{tikzpicture}[scale=.5, transform shape]
\node [thin, black] (0,0) (origin){}
 ([shift={(0.:1.2)}]origin.center) node (txtu){}
 ([shift={(-65.:4.)}]origin.center) node (txtd){}
 ([shift={(180.:7.)}]txtd.center) node (txtds){}
 ([shift={(180.:5.8)}]txtds.center) node (txtdt){}
 ([shift={(-90.:.4)}]origin.center) node (od){}
 ([shift={(180.:5.)}]od.center) node (odsens){}
 ([shift={(-90.:9.8)}]odsens.center) node (odsensd){}
 ([shift={(0.:.12)}]od.center) node (odr){}
 ([shift={(0.:3.)}]od.center) node (odrr){}
 ([shift={(180.:.12)}]od.center) node (odl){}
 ([shift={(180.:1.)}]od.center) node (odll){}
 ([shift={(-90.:.26)}]odrr.center) node (odrrd){}
 ([shift={(-90.:.12)}]odll.center) node (odllc){}
 ([shift={(-90.:.24)}]odll.center) node (odlld){}
;
 \draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] (odr.center) -- ([shift={(90.:.4)}]odr.center) .. controls (40:1.2) and (140:1.2) .. ([shift={(90.:.4)}]odl.center) -- (odl.center);
 \draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] ([shift={(180.:.02)}]odr.center) -- (odrr.center) -- (odrrd.center) -- (odlld.center) -- (odll.center) --  ([shift={(0.:.02)}]odl.center);
\end{tikzpicture}
\end{minipage}
\end{document}

enter image description here

Is it possible to repeat this drawing 2 times downwards and connect them together to form one unit, to look like the following drawing.

enter image description here

up vote 2 down vote accepted

One way to do it to define a macro, \MyComponents to do the drawing of the components and then draw the line connecting them.

enter image description here

Code:

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}

\newcommand*{\MyComponents}[2][]{%
    %% #1 = drawing options
    %% #2 = name of node
    \begin{scope}[scale=.5, transform shape, #1]
        \node [thin, black] (0,0) (origin) {}
         ([shift={(0.:1.2)}]origin.center) node (txtu){}
         ([shift={(-65.:4.)}]origin.center) node (txtd){}
         ([shift={(180.:7.)}]txtd.center) node (txtds){}
         ([shift={(180.:5.8)}]txtds.center) node (txtdt){}
         ([shift={(-90.:.4)}]origin.center) node (od){}
         ([shift={(180.:5.)}]od.center) node (odsens){}
         ([shift={(-90.:9.8)}]odsens.center) node (odsensd){}
         ([shift={(0.:.12)}]od.center) node (odr){}
         ([shift={(0.:3.)}]od.center) node (odrr){}
         ([shift={(180.:.12)}]od.center) node (odl){}
         ([shift={(180.:1.)}]od.center) node (odll){}
         ([shift={(-90.:.26)}]odrr.center) node (odrrd){}
         ([shift={(-90.:.12)}]odll.center) node (odllc){}
         ([shift={(-90.:.24)}]odll.center) node (odlld){}
        ;
         \draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] (odr.center) -- ([shift={(90.:.4)}]odr.center) .. controls (40:1.2) and (140:1.2) .. ([shift={(90.:.4)}]odl.center) -- (odl.center);
         \draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] ([shift={(180.:.02)}]odr.center) -- (odrr.center) -- (odrrd.center) -- (odlld.center) -- (odll.center) --  ([shift={(0.:.02)}]odl.center);

         \coordinate (#2 Top) at (odll.center);
         \coordinate (#2 Bot) at (odlld.center);
    \end{scope}
}

\begin{document}
\begin{tikzpicture}
    \MyComponents{Node 1}
    \MyComponents[yshift=-1.5cm]{Node 2}
    \MyComponents[yshift=-3.0cm]{Node 3}

    \draw [blue, line width=3pt] ([yshift=0.5pt]Node 1 Top) -- ([yshift=-0.5pt]Node 3 Bot);
\end{tikzpicture}%
\end{document}
  • Thank you very much. I want to connect the drawings with a filled rectangle, not a line. So, to do this later, I added some nodes, and I tried the solution I posted in the following question (tex.stackexchange.com/questions/456100/…); but I got an error of elongated rounded objects, that I could not solve. Can you help me. – Hany Oct 21 at 11:29

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.