[Tex/LaTex] Latex Tree Diagram: Inserting Arrows

tikz-arrowstikz-trees

I’m having an issue formatting my LaTeX Tree Diagram. It’s in the correct order but I don’t know how to have an arrow at the end of each path to show the direction flow (test – Start) (Start – Do) (Do – Make) etc …

If people know how to have the path travel from each nodes parent only, rather than the overall 'latex' parent, that would be great!

Current situation

\documentclass{tufte-handout}

% Set up the images/graphics package
\usepackage{graphicx}
\setkeys{Gin}{width=\paperwidth,totalheight=\textheight,keepaspectratio}
\graphicspath{{graphics/}}
\DeclareGraphicsExtensions{.pdf,.png}

\title{test}
\date{}  % if the \date{} command is left out, the current date will be used
% The fancyvrb package lets us customize the formatting of verbatim
% environments.  We use a slightly smaller font.
\usepackage{fancyvrb}
\fvset{fontsize=\normalsize}

% Small sections of multiple columns
\usepackage{multicol}

%colour package
\usepackage{color}

%Hyperlink package
\usepackage{hyperref}

%file package
\usepackage{tikz}

%URL package
\usepackage{url}

% These commands are used to pretty-print LaTeX commands
\newcommand{\doccmd}[1]{\texttt{\textbackslash#1}}% command name -- adds backslash     automatically
\newcommand{\docopt}[1]{\ensuremath{\langle}\textrm{\textit{#1}}\ensuremath    {\rangle}}% optional command argument
\newcommand{\docarg}[1]{\textrm{\textit{#1}}}% (required) command argument
\newenvironment{docspec}{\begin{quote}\noindent}{\end{quote}}% command specification     environment
\newcommand{\docenv}[1]{\textsf{#1}}% environment name
\newcommand{\docpkg}[1]{\texttt{#1}}% package name
\newcommand{\doccls}[1]{\texttt{#1}}% document class name
\newcommand{\docclsopt}[1]{\texttt{#1}}% document class option name

\begin{document}
\begin{figure}[t]
\includegraphics[width=6cm, height=8cm]{testlogo}
\centering
\end{figure}

{\color{RoyalBlue}\maketitle}% this prints the handout title, author, and date


\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=ProcessBlue,fill=ProcessBlue!35]

\begin{tikzpicture}[%
grow via three points={one child at (0.5,-0.7) and
two children at (0.5,-0.7) and (2.2,-1.4)},
edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]

\node [selected] {LaTeX}
child { node [selected] {1. test}}  
child { node [selected] {2. start}} 
child { node [selected] {3. Do}}
child { node [selected] {4. Make}}
child { node [selected] {5. test}};
\end{tikzpicture}

\end{document}

Code

Output

Best Answer

Since it is a tree, I would use forest since the code is much more compact and flexible, and allows the numbering to be handled automatically.

I've used blue rather than ProcessBlue as I don't know how the latter should be defined.

I'm guessing you want something like this although it is not very clear from your question.

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows,arrows.meta}
\standaloneenv{forest}% delete this line if using another class
\begin{document}
\tikzset{
  selected/.style={draw=blue, thick, fill=blue!35, drop shadow}
}
\begin{forest}
  for tree={
    parent anchor=south,
    child anchor=west,
    anchor=west,
    selected,
    grow=-45,
    edge path={
      \noexpand\path [draw, thick, -{Stealth[]}, \forestoption{edge}] (!u.parent anchor) |- (.child anchor)\forestoption{edge label};
    },
  },
  before typesetting nodes={
    for tree={
      if level=0{}{
        content/.wrap 2 pgfmath args={#1. #2}{level()}{content()},
      },
    },
  }
  [\LaTeX
    [Test
      [Start
        [Do
          [Make
            [Test
            ]
          ]
        ]
      ]
    ]
  ]
\end{forest}

\end{document}

stepped tree

EDIT

Here's a slightly enhanced version (well - you may not think so!), with a colour a little closer to that in the picture you posted.

A very subtle shading is applied to each node to give a little more depth, and the corners are rounded off.

'enhanced' version

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows,arrows.meta}
\standaloneenv{forest}% delete this line if using another class
\begin{document}
\colorlet{ProcessBlue}{blue!50!cyan}
\tikzset{
  selected/.style={draw=ProcessBlue, thick, rounded corners=2pt, inner color=ProcessBlue!25, outer color=ProcessBlue!35, drop shadow,}
}
\begin{forest}
  for tree={
    parent anchor=south,
    child anchor=west,
    anchor=west,
    selected,
    grow=-45,
    font=\sffamily,
    edge path={
      \noexpand\path [draw, thick, -{Stealth[]}, \forestoption{edge}] (!u.parent anchor) |- (.child anchor)\forestoption{edge label};
    },
  },
  before typesetting nodes={
    for tree={
      if level=0{}{
        content/.wrap 2 pgfmath args={#1. #2}{level()}{content()},
      },
    },
  }
  [\LaTeX
    [Test
      [Start
        [Do
          [Make
            [Test
            ]
          ]
        ]
      ]
    ]
  ]
\end{forest}
\end{document}

EDIT

In response to your comment about handling long labels, there are several possibilities. One is to use multiline nodes with explicit line breaks. This example uses align=left but you could use align=center or align=right, for example.

long label with left alignment

To create this tree, add align=left to the definition of the style selected:

\tikzset{
  selected/.style={draw=ProcessBlue, thick, rounded corners=2pt, inner color=ProcessBlue!25, outer color=ProcessBlue!35, drop shadow, align=left,}
}

And then define the relevant node with line breaks where required:

            [Test a very\\loooooonnnnnnnnnggggggg\\label with line breaks
            ]

Alternatively, you could add text width=<some width> to the definition of selected and then the lines will be broken automatically. However, in this case, I think that manual line breaks provide the best result.

Related Question