5

I would like to draw the following rectangle divided by two using tikzpicture environment:

What I want

However, what I achieved so far is:

What I have done so far

MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{decorations.text}

\begin{document}

% Bend curves from https://tex.stackexchange.com/a/22316/152550
\begin{tikzpicture}[delay rect/.style={rectangle split, rectangle split parts=2,draw,
minimum width=1.5cm,minimum height=1cm, 
text width=2cm,align=center,inner ysep=2cm,draw,inner ysep=3mm,inner
xsep=3mm}]  % From https://tex.stackexchange.com/a/452609/152550
    \node (start) at (0,0) {Start};
    \node (end) at (6,0) {End};
    \node[rotate=60,delay rect] (delay) at (3,0) {A1\nodepart{two}text here};
    \def\myshift#1{\scriptsize\raisebox{1ex}}
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|hello}}}] (start) to [bend left=10] (delay);
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|bye}}}] (delay) to [bend left=10] (end);
\end{tikzpicture}

\end{document}

Thanks!

manooooh
  • 3,203
  • 2
  • 21
  • 46

1 Answers1

4

to your style definition for delay rec you need to add the option rectangle split horizontal:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{decorations.text}

\begin{document}
% Bend curves from https://tex.stackexchange.com/a/22316/152550
    \begin{tikzpicture}[
delay rect/.style = {rectangle split,  % all double and not used options in style are removed
                     rectangle split horizontal,   % <---
                     rectangle split parts=2, draw,
                     minimum height=1cm,
                     align=center,
                     inner ysep=3mm,inner xsep=3mm}
                        ]  % From https://tex.stackexchange.com/a/452609/152550
    \node (start) at (0,0) {Start};
    \node (end) at (6,0) {End};
    \node[delay rect,rotate=60] (delay) at (3,0) {A1\nodepart{two}text here};
    \def\myshift#1{\scriptsize\raisebox{1ex}}
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|hello}}}] (start) to [bend left=10] (delay);
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|bye}}}] (delay) to [bend left=10] (end);
\end{tikzpicture}
\end{document}

enter image description here

edit:

regarding sub questions in your comment below:

1) reduce the font size of the rectangle (\scriptsize)?

in node style definition just define font size with `font=\scriptsize`

2) reduce a little more the height of the rectangle?

in height of a rectangles are defined by `minimum height = <desired height>`. you have selected 1cmm, if this is to much, reduce for example to 7mm

3) reduce a little more the width of each part of the rectangle so that there is not so much space between the text and the edges

space between node border lines and nodes content (text) is controlled by `inner sep` (equal for all direction) or `inner ysep` in vertical direction) and `inner xsep` for horizontal. default value is `3pt`. if this is to much to you, than to node's style option add for example `inner sep=2pt`.
Zarko
  • 296,517
  • Nice, thank you! Do you know how can we 1) reduce the font size of the rectangle (\scriptsize)?; 2) reduce a little more the height of the rectangle?; 3) reduce a little more the width of each part of the rectangle so that there is not so much space between the text and the edges? (the latter is not necessary) – manooooh Dec 08 '18 at 01:13
  • 1
    @manooooh, i belive that is now time to read tikz & pgf manual, at least part III :-). i will add some instruction to answer asap (however, this is not part of your question). – Zarko Dec 08 '18 at 01:16
  • Forget that.... That's perfect, I can solve the font size by using {\scriptsize A1\nodepart{two}\scriptsize text here} and adding minimum height=.1cm. – manooooh Dec 08 '18 at 01:17
  • 1
    @manooooh, don't doing this. you will destroy baseline distance of text. use approach described in explanation added to answer. – Zarko Dec 08 '18 at 01:26