3

I want to draw this figure:

enter image description here

I tried:

\documentclass{memoir}

\usepackage{tikz}
\usetikzlibrary{shapes.misc, positioning}

\begin{document}

\begin{tikzpicture}
    \node[rounded rectangle, rounded rectangle right arc=none, draw,minimum height=1cm,minimum width=2cm] (part1) at (0,0) {123};
    \node[rounded rectangle, rounded rectangle left arc=none, draw,minimum height=1cm,minimum width=2cm] (part2) at (2.5,0) {456};
    \node[draw=none] [above=0.5ex of part1] {Label on top};
    \node[draw=none] [below=0.5ex of part1] {Label at bottom};
    
    \node[draw=none] [above=0.5ex of part2] {Label on top};
    \node[draw=none] [below=0.5ex of part2] {Label at bottom};
    
    \node[draw=none] (add) at (1,-2){Add togerher};
    \draw (part1) to [bend right=45] (add);
    \draw (part2) to [bend left=45] (add);
\end{tikzpicture}

\end{document}
7

A possibility is to create a \pic for the cyan 'half ellipses' or 'rectangles'. This way you can rotate one of them and both will have the same style. You can put parameters in them for the labels above or below each one.

For example:

\documentclass[border=2mm,tikz]{standalone}

\tikzset
{%
  pics/half/.style 2 args={% #1: label below; #2: label above
    code={
      \path[pic actions] (-0.25,-0.75) -- (1.5,-0.75) arc (-90:90:1 and 0.75) -- (0.25,0.75);
      \node at (1,-1) {\strut#1};
      \node at (1, 1) {\strut#2};
      \coordinate (-center) at (1,0);
    }},
    my node/.style={draw,circle,inner sep=1pt},
  cyan fill/.style={draw,fill=cyan!30}
}

\begin{document}
\begin{tikzpicture}[line cap=round]
% pics
\pic[cyan fill,rotate=180] (L)  at (-0.5,0) {half={Label above}{Label below}};
\pic[cyan fill]            (R)  at  (0.5,0) {half={Label below}{Label above}};
% nodes inside
\node[my node] (123) at (L-center) {123};
\node           (23) at (R-center) {23};
\node[my node]   (4) at ([xshift=2pt]23.east) {4};
% other nodes
\node[inner sep=0] (this) at (-1.2,-2) {\strut Label for this};
\node[inner sep=0] (that) at (1.2,-2)  {\strut Label for that};
\node          (together) at (0,-3)    {Add together};
% arrows
\draw[-latex] (123)        to[out=180,in=180,looseness=2] (this.west);
\draw[-latex] (4)          to[out=0  ,in=0  ,looseness=2] (that.east);
\draw[-latex] (this.south) to[out=300,in=150] (together.150);
\draw[-latex] (that.south) to[out=240,in=30]  (together.30);
\end{tikzpicture}
\end{document}

enter image description here

Edit: I curved the last two arrows as requested.

2
  • Impressive! --> What if I want the last arrows to be curved to look better?
    – topu
    Dec 9 '21 at 8:17
  • 1
    @mmr, see my edit. Of course, you can play with the in and out angles, or the end positions if you want. Dec 9 '21 at 8:26

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.