4

I tried this code to generate the following figure.

\documentclass[statementpaper,11pt,twoside]{memoir}

\usepackage{tikz} \usetikzlibrary{fit,positioning}

\begin{document}

\begin{center} \begin{tikzpicture}[] \tikzstyle{vertex} = [rectangle, rounded corners, minimum width=2cm, minimum height=0.8cm, text centered, draw=green!60, fill=green!5, very thick] \tikzstyle{hidden} = [draw=none, minimum width=1cm, minimum height=0.8cm, text centered] \tikzstyle{arrow} = [->,thick]

\node[vertex, minimum width=2cm] (y) at (1,0) {p1};

\node[vertex] (y1) [below=0.7cm of y] {p1};
\node[vertex, minimum width=1.5cm] (y11) [right=0.7cm of y1] {p2}; 
\node[vertex, minimum width=1cm] (y12) [right=0.7cm of y11] {p3};
\draw[arrow] (y) to [out=270,in=100] (y1);
\draw[arrow] (y) to [out=270,in=150] (y11);
\draw[arrow] (y) to [out=270,in=140] node[above] {\footnotesize Text along arrow} (y12);

\end{tikzpicture} \end{center}

\end{document}

Produced output:

enter image description here

My expectation:

enter image description here

How can I get my desired output to bent the arrow correctly and set the text.

mmr
  • 2,249
  • 5
  • 22

2 Answers2

5

You can specify distance=0.75cm] which yields:

enter image description here

My recomemndation would be to actually add more vertical spacing so things are not so crowded.

You can also add sloped option to make the text follow the slop of the arrow, but since it is pretty flat I don't think that that is a good idea.

Notes:

Code:

\documentclass[statementpaper,11pt,twoside]{memoir}

\usepackage{tikz} \usetikzlibrary{fit,positioning}

\begin{document}

\begin{center} \begin{tikzpicture}[] \tikzstyle{vertex} = [rectangle, rounded corners, minimum width=2cm, minimum height=0.8cm, text centered, draw=green!60, fill=green!5, very thick] \tikzstyle{hidden} = [draw=none, minimum width=1cm, minimum height=0.8cm, text centered] \tikzstyle{arrow} = [->,thick]

\node[vertex, minimum width=2cm] (y) at (1,0) {p1};

\node[vertex] (y1) [below=0.7cm of y] {p1};
\node[vertex, minimum width=1.5cm] (y11) [right=0.7cm of y1] {p2}; 
\node[vertex, minimum width=1cm] (y12) [right=0.7cm of y11] {p3};
\draw[arrow] (y) to [out=270,in=100] (y1);
\draw[arrow] (y) to [out=270,in=150] (y11);
\draw[arrow, draw=red] (y) to [out=270,in=140,distance=0.75cm] node[above] {\footnotesize Text along arrow} (y12);

\end{tikzpicture} \end{center}

\end{document}

Peter Grill
  • 223,288
3

You may liked the following solution.

\documentclass[statementpaper,11pt,twoside]{memoir}

\usepackage{tikz} \usetikzlibrary{decorations.text, positioning,
quotes}

\begin{document} \begin{center} \begin{tikzpicture}[ node distance = 7mm, vertex/.style = {rectangle, rounded corners, thick, draw=green!60, fill=green!5, minimum width=#1, minimum height=0.8cm, align=center}, vertex/.default = 2cm, tap/.style args = {#1/#2}{decoration={raise=#1, text along path, text align={left indent=4em}, text={|\scriptsize| #2}, }, postaction={decorate} }, arrow/.style = {->,thick} ] \node[vertex] (y) {p1}; \node[vertex] (y1) [below=of y] {p1}; \node[vertex=1.5cm] (y11) [right=of y1] {p2}; \node[vertex=1.0cm] (y12) [right=of y11] {p3}; % \draw[arrow] (y) to [out=270,in=115] (y1); \draw[arrow] (y) to [out=270,in=155] (y11);

\draw[arrow, tap={4pt/text along path}] (y) to [out=270,in=135, looseness=0.5] (y12); % <--- \end{tikzpicture} \end{center} \end{document}

As you can see, for the "loos" of the last path is controlled by out looseness=0.5 which reduce distance of curve at its start.

enter image description here

Zarko
  • 296,517