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!
\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}
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 thanProcessBlue
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.
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.
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 usealign=center
oralign=right
, for example.To create this tree, add
align=left
to the definition of the styleselected
:And then define the relevant node with line breaks where required:
Alternatively, you could add
text width=<some width>
to the definition ofselected
and then the lines will be broken automatically. However, in this case, I think that manual line breaks provide the best result.