5

I refer to web and found some good examples to add fancy arrow, I show my code

\documentclass[a4paper,11pt]{book}

\usepackage{color}
\usepackage{xcolor,colortbl}
\definecolor{ForestGreen}{rgb}{0.13, 0.55, 0.13}
\definecolor{OrangeRed}{rgb}{1.0, 0.27, 0.0}
\definecolor{FireBrick}{rgb}{0.7, 0.13, 0.13}
\definecolor{Gold}{rgb}{1.0, 0.84, 0.0}
\definecolor{DodgerBlue}{rgb}{0.12, 0.56, 1.0}
\definecolor{Tomato}{rgb}{1.0, 0.39, 0.28}

\usepackage{tikz}
\usetikzlibrary{calc,fadings,shapes.arrows,shadows,backgrounds, positioning}
\tikzset{bubble/.style={rectangle, draw=gray,rounded corners,fill=#1,align = flush center,minimum height=1cm,minimum width=1.75cm}}
\tikzfading [name=arrowfading, top color=transparent!0, bottom color=transparent!95]
\tikzset{arrowfill/.style={top color=OrangeRed!20, bottom color=red, general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}
\tikzset{arrowstyle/.style={draw=FireBrick,arrowfill, single arrow,minimum height=#1, single arrow, single arrow head extend=.4cm,}}

\begin{document}
\begin{figure}[htbp]
\begin{tikzpicture}
    % Bubbles
    \node[bubble=ForestGreen!40] (ba) at (0,0) {Bubble A};
    \node[bubble=Gold!40] (bb) at (2.6,0) {Bubble B};
    \node[bubble=DodgerBlue!40] (bc) at (5.5,0) {Bubble C};
    \node[bubble=Tomato!40] (bd) at (8.5,0) {Bubble\\with long\\name};

    \node[above= 0.5 cm of bb,font={\bf}]{Part 1};
    \node[above= 0.5 cm of bd,font={\bf}]{Part 2};

    % Lines
    \foreach \bubble in {ba,bb,bc,bd}
    \draw[ultra thick, gray] ($(\bubble.south)-(0,0.1)$)--($(\bubble.south)-(0,5)$);

    % Arrows
    \node [arrowstyle=2.9cm,xshift=-0.1cm,yshift=-1cm] at ($(ba.south)!0.5!(bb.south)$) {test sting 1};
    \node [arrowstyle=3cm,xshift=-0.1cm,yshift=-2cm] at ($(bb.south)!0.5!(bc.south)$) {test sting 2, test sting 2.1, test sting 2.2};
    \node [arrowstyle=3.1cm,xshift=-0.1cm,yshift=-3cm] at ($(bc.south)!0.5!(bd.south)$) {test sting 3};
    \node [arrowstyle=6cm,xshift=-0.1cm,yshift=-4.5cm] at ($(bb.south)!0.5!(bd.south)$) {test sting 4};
    \node [arrowstyle=3.3cm,yshift=-1cm,shape border rotate=180] at ($(bc.south)!0.55!(bd.south)$) {test sting 5};

    % Background
    \begin{pgfonlayer}{background}
    \fill[gray!10]($(bc.north)!0.5!(bd.north)+(0,0.5)$)rectangle($(bc.south)!0.5!(bd.south)+(4,-5.1)$) ;
    \draw[dashed, shorten <=-1.5cm] ($(bc.south)!0.5!(bd.south)$)--($(bc.south)!0.5!(bd.south)-(0,5.1)$);
    \end{pgfonlayer}
\end{tikzpicture}
\end{figure}
\end{document}

this will give good output, but my question is, how to wrap the string in arrow from bubble bb to bc?

My output shows: enter image description here

4
  • Add a line into the code \node [arrowstyle=2.9cm,xshift=-0.1cm,yshift=-3cm] at ($(bb.south)!0.5!(bc.south)$) {aaaaaa};
    – Jesse
    May 23, 2014 at 10:01
  • 1
    Fix some text width=... and (optional) align=... in node options: \node [arrowstyle=3cm,xshift=-0.1cm,yshift=-2cm, text width=3cm, align=center] at ($(bb.south)!0.5!(bc.south)$) {test sting 2, test sting 2.1, test sting 2.2};
    – Ignasi
    May 23, 2014 at 10:04
  • Just a comment: instead of hardcoded positioning (xshift=-0.1cm,yshift=-2cm,) I'd suggest applying some name to \node[arrowstyle] and use relative positioning (below = of).
    – Ignasi
    May 23, 2014 at 10:07
  • @Ignasi perhaps you could turn your comments into an answer? May 23, 2014 at 12:53

1 Answer 1

2

You can wrap node contents if some text width is fixed. Optionally an alignment option (align=left|center|right) can also be applied. With this options it's not necessary to use linebreaks (\\) as you did it in bubble bd.

Next code also shows how to use relative positioning instead of hard coded coordinates. You can fix reference points with intersection coordinate system (|- or -|), {x|y}shift them, etc. I cannot explain all of them now, but you will find a lot of explained examples not far away.

Last think I've also moved drawing vertical lines to background scope in order to set their length using also bottom most arrow.

Of course this is just an example to show you some of multiple options that TikZ offer to get similar results.

\documentclass[a4paper,11pt]{book}

\usepackage{color}
\usepackage{xcolor,colortbl}
\definecolor{ForestGreen}{rgb}{0.13, 0.55, 0.13}
\definecolor{OrangeRed}{rgb}{1.0, 0.27, 0.0}
\definecolor{FireBrick}{rgb}{0.7, 0.13, 0.13}
\definecolor{Gold}{rgb}{1.0, 0.84, 0.0}
\definecolor{DodgerBlue}{rgb}{0.12, 0.56, 1.0}
\definecolor{Tomato}{rgb}{1.0, 0.39, 0.28}

\usepackage{tikz}
\usetikzlibrary{calc,fadings,shapes.arrows,shadows,backgrounds, positioning}
\tikzset{bubble/.style={rectangle, draw=gray,rounded corners,fill=#1,align = flush center,minimum height=1cm,minimum width=1.75cm, text width=1.5cm, align=center}}
\tikzfading [name=arrowfading, top color=transparent!0, bottom color=transparent!95]
\tikzset{arrowfill/.style={top color=OrangeRed!20, bottom color=red, general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}
\tikzset{arrowstyle/.style={draw=FireBrick,arrowfill, single arrow,minimum height=#1, single arrow, single arrow head extend=.4cm,text width=3cm, align=center}}

\begin{document}
\begin{figure}[htbp]
\begin{tikzpicture}
    % Bubbles
    \node[bubble=ForestGreen!40] (ba) at (0,0) {Bubble A};
    \node[bubble=Gold!40] (bb) at (2.6,0) {Bubble B};
    \node[bubble=DodgerBlue!40] (bc) at (5.5,0) {Bubble C};
    \node[bubble=Tomato!40] (bd) at (8.5,0) {Bubble with long name};

    \node[above= 0.5 cm of bd,font={\bf}] (part2){Part 2};
    \node at (part2-|bb) (part1) {Part 1};


    % Arrows
    \node [arrowstyle=2.9cm,below = 1cm of ba, anchor=tail] (sting1) {test sting 1};
    \node [arrowstyle=3.3cm,below = 1cm of bd, shape border rotate=180, anchor=tail] (sting5) {test sting 5};
    \node [arrowstyle=3cm, text width=3cm, align=center, anchor=tail] at ([yshift=-10mm]bb|-sting5.before tip) (sting2) {test sting 2, test sting 2.1, test sting 2.2};
    \node [arrowstyle=3.1cm,below=5mm of sting2.after tip,anchor=tail, ] (sting3) {test sting 3};
    \node [arrowstyle=6cm,below=3mm of {bb.south|-sting3.before tail}, anchor=tail] (sting4) {test sting 4};

    % Background
    \begin{pgfonlayer}{background}
    \fill[gray!10]($(bc.north)!0.5!(bd.north)+(0,0.5)$) rectangle ([shift={(3mm,-3mm)}]sting4.after tip-|bd.east) ;

\draw[dashed, shorten <=-1.5cm] ($(bc.south)!0.5!(bd.south)$)--($(bc.south)!0.5!(bd.south)-(0,5.1)$);

    % Lines
    \foreach \bubble in {ba,bb,bc,bd}
    \draw[ultra thick, gray] (\bubble.south)--([yshift=-3mm]\bubble.south|-sting4.after tip);
    \end{pgfonlayer}
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .