2

I am trying to recreate the image below, with the small modification of making it vertically.

enter image description here

However, I ran into some small problems with the lengths of the arrows and

enter image description here

Any idea how I can make the arrows the same length, and properly center the arrows? Is it possible to make all the boxes the same height / width as well?

\documentclass[svgnames]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,shadows}
\usetikzlibrary{shapes.geometric}

\usepackage{xparse}

\usepackage{lipsum}

\tikzfading[name=arrowfading, top color=transparent!0, bottom color=transparent!95]
\tikzset{arrowfill/.style={#1,general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}
\tikzset{arrowstyle/.style n args={3}{draw=#2,arrowfill={#3}, single arrow,minimum height=#1, single arrow,
single arrow head extend=.3cm,}}

\NewDocumentCommand{\tikzfancyarrow}{O{2cm} O{FireBrick} O{top color=OrangeRed!20, bottom color=Red} m}{
\tikz[baseline=-0.5ex]\node [arrowstyle={#1}{#2}{#3}] {#4};
}

\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]

\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]

\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]

\begin{document}

\begin{tikzpicture}[node distance=2cm]

\node (start) [startstop, align=left] {Your computer \\ \\ 3. Update \\ 4. Commit};

\node (push) [above right of=start, xshift=2cm, yshift=-1cm] {\tikzfancyarrow[2cm][FireBrick][top color=OrangeRed!20, bottom color=Red,shape border rotate=180]{2. Clone}};
\node (clone) [below right of=start, xshift=2cm, yshift=1cm] {\tikzfancyarrow{5. Push}};


\node (in1) [io, right of=clone, xshift=2cm, yshift=0.33cm, align=left] {Your GitHub-repo \\ \footnotesize github.com/you/coolproject};

\node (pull) [above right of=in1, xshift=2cm, yshift = -1cm] {\tikzfancyarrow[2cm][FireBrick][top color=OrangeRed!20, bottom color=Red,shape border rotate=180]{1. Fork}};
\node (fork) [below right of=in1, xshift=2cm, yshift = 1cm] {\tikzfancyarrow{6. Pull request}};

\node (pro1) [process, right of=fork, xshift=2cm, align=left, yshift=0.33cm] {Joe's GitHub-repo \\ \footnotesize github.com/joe/coolproject};

\end{tikzpicture}
\end{document}
Zarko
  • 296,517
N3buchadnezzar
  • 11,348
  • 7
  • 55
  • 114

2 Answers2

2

as starting point (since i went lost in your code :-( ):

edit: after reading your question again, i recognise, that you like to have all arrow shapes equal long and all block equal height (am i correct?). this can be obtained by prescribed text width for arrows and larger minimum height for other nodes. the corrected code:

\documentclass[svgnames, margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, shadows, shapes.arrows, shapes.geometric}

\tikzset{
   arrowstyle/.style n args = {3}{single arrow, single arrow head extend=3mm,
                        minimum width=12mm, text width=24mm,
                        draw=#1, top color=#2, bottom color=#3,
                        drop shadow={shadow xshift=0ex, shadow yshift=-0.8ex},
                        anchor=west
                                 },
 arrowstyle/.default = {red}{OrangeRed!20}{Red},
    startstop/.style = {rectangle, rounded corners, draw=black, fill=red!30,
                        minimum width=33mm, minimum height=22mm, align=left},
           io/.style = {trapezium,
                        trapezium left angle=70, trapezium right angle=110,
                        trapezium stretches body,
                        draw=black, fill=blue!30,
                        minimum width=33mm, minimum height=22mm, align=left},
      process/.style = {rectangle, draw=black, fill=orange!30,
                        minimum width=33mm, minimum height=22mm, align=left},
        }

\begin{document}
    \begin{tikzpicture}[
node distance = 6mm and 9mm]
\node (start)   [startstop]                             {Your computer\\ \\ 3. Update \\ 4. Commit};
\node (push)    [above right=of start.east,
                 arrowstyle, shape border rotate=180]   {2. Clone};
\node (clone)   [below right=of start.east,
                 arrowstyle]                            {5. Push};
%
\node (in1)     [io, right=of clone.east |- start]      {Your GitHub-repo \\
                                            \footnotesize github.com/you/coolproject};
\node (pull)    [above right=of in1.east,
                 arrowstyle, shape border rotate=180]   {1. Fork};
\node (fork)    [below right=of in1.east,
                 arrowstyle]                            {6. Pull request};
%
\node (pro1)    [process, right=of fork.east |- start]  {Joe's GitHub-repo \\
                                \footnotesize github.com/joe/coolproject};
\end{tikzpicture}
\end{document}
  • in my code remove all your nested tikz picture, redesign nodes styles and unified their way of defining (used only tikzset), use the tikz library positioning for node positioning
  • observe the new sequence of options at arrowstyle nodes: first positioning, than style of nodes. this is necessary that nodes anchor is not overwritten by positioning

enter image description here

  • in the case, that you like to replicated the image shown in question, it is relatively simple to rearrange above code to it:

    \documentclass[svgnames, margin=3mm]{standalone}
    \usepackage{tikz}
    \usetikzlibrary{positioning, shadows, shapes.arrows, shapes.geometric}
    
    \tikzset{
       arrowstyle/.style n args = {3}{single arrow, single arrow head extend=3mm,
                            minimum width=12mm, text width=24mm, align=center,
                            draw=#1, top color=#2, bottom color=#3,
                            drop shadow={shadow xshift=0ex, shadow yshift=-0.8ex},
                            anchor=west
                                     },
       arrowstyle/.default = {red}{OrangeRed!20}{Red},
        startstop/.style = {rectangle, rounded corners, draw=black, fill=red!30,
                            minimum width=33mm, minimum height=22mm, align=left},
               io/.style = {trapezium,
                            trapezium left angle=70, trapezium right angle=110,
                            trapezium stretches body,
                            draw=black, fill=blue!30,
                            minimum width=33mm, minimum height=22mm, align=left},
          process/.style = {rectangle, draw=black, fill=orange!30,
                            minimum width=33mm, minimum height=22mm, align=left},
            }
    
    \begin{document}
    
        \begin{tikzpicture}[
    node distance = 6mm and 9mm]
    \node (in1)     [io]                                    {Your GitHub-repo \\
                                               \footnotesize github.com/you/coolproject};
    %
    \node (pull)    [above right=of in1.east,
                     arrowstyle, shape border rotate=180]   {1. Fork};
    \node (fork)    [below right=of in1.east,
                     arrowstyle]                            {6. Pull request};
    \node (pro1)    [process, right=of fork.east |- in1]    {Joe's GitHub-repo \\
                                               \footnotesize github.com/joe/coolproject};
    %
    \node (clone)   [below  left=of in1.south,
                     arrowstyle,rotate=90,anchor=east]                {5. Push};
    \node (push)    [below right=of in1.south,
                     arrowstyle, rotate=270,anchor=west]                 {2. Clone};
    \node (start)   [startstop,
                     below=of in1 |- clone.west]      {Your computer\\ \\ 3. Update \\ 4. Commit};
    \end{tikzpicture}
    
    \end{document}
    

enter image description here

Zarko
  • 296,517
1

If I understand correctly, your problem is controlling the length of the arrows and their directions. Both things can be addressed using Torbjørn T.'s nice answer, which I modified a bit for the present task. You should be able to do all these things with a simple edge command

\path
([xshift=7mm]in1.south) edge[fancy arrow={}{5.~Push}] 
([xshift=7mm]start.north);

where the coordinates refer to the start and end (and I shifted them because you want to have arrows in opposite directions), the first argument is an option which you may not need in most cases and the second one the text inside the arrow.

enter image description here

\documentclass[svgnames]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,shadows,positioning,calc}
\usetikzlibrary{shapes.geometric}

\usepackage{xparse}

\usepackage{lipsum}

\tikzfading[name=arrowfading, top color=transparent!0, bottom color=transparent!95]
\tikzset{arrowfill/.style={#1,general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}
\tikzset{arrowstyle/.style n args={3}{draw=#2,arrowfill={#3}, single arrow,minimum height=#1, single arrow,
single arrow head extend=.3cm,}}

\tikzset{fancy arrow/.style 2 args=%
{to path={let \p1 = ($(\tikztotarget)-(\tikztostart)$),
            \p2=($(\tikztotarget)!0.5!(\tikztostart)$),
            \n1 = {int(mod(scalar(atan2(\y1,\x1))+360, 360))}, % calculate angle in range [0,360)
            \n2 = {veclen(\x1,\y1)}
        in
         (\p2)
        node[draw,arrowstyle={1pt}{FireBrick}{top color=OrangeRed!20, bottom color=Red},
             minimum height=\n2-\pgflinewidth-5pt,
             single arrow,text=black,inner sep=1pt,
             rotate=\n1, % not shape border rotate, because that for some reason didn't work
             anchor=mid, % anchor=tip added, pos=0.5 removed
             #1
             ]{#2}
         }}}

\tikzset{startstop/.style={rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30},
}

\begin{document}

\begin{tikzpicture}

\node (start) [startstop, align=left] {Your computer \\ \\ 3. Update \\ 4. Commit};

\node (in1) [io, above=3cm of start, align=left] {Your GitHub-repo \\ \footnotesize github.com/you/coolproject};

\node (pro1) [process, right=3cm of in1,align=left] {Joe's GitHub-repo \\ \footnotesize github.com/joe/coolproject};
\path ([yshift=4mm]in1.east) edge[fancy arrow={shape border rotate=180}{1.~Fork}]
([yshift=4mm]pro1.west);
\path
([yshift=-4mm]in1.east) edge[fancy arrow={}{6.~Pull request}] ([yshift=-4mm]pro1.west);

\path
([xshift=-7mm]start.north) edge[fancy arrow={}{2.~Clone}] 
([xshift=-7mm]in1.south);
\path
([xshift=7mm]in1.south) edge[fancy arrow={}{5.~Push}] 
([xshift=7mm]start.north);

\end{tikzpicture}
\end{document}