I am having trouble getting a forest
tree to fit on the page. I was wondering what techniques there are to squash the tree below so it doesn't take up so much horizontal space. Ideas I had (but have been unable to execute) were:
1) Forcing nodes to be a maximum width (so the text flows to multi lines)
2) Allowing nodes at the same level in the tree to have different vertical positions on the page (so that they can overlap).
Any suggestions would be appreciated! If I am using completely the wrong package for this situation, please let me know.
\documentclass[a4paper,12pt]{article}
\usepackage{forest}
\begin{document}
\begin{forest}
[What could prevent a transaction?
[Customer can't top up
[Customer has insufficient funds
[Seasonal/short term issue]
[Poor customer selection]
[Change in circumstances]
]
[Can't execute top up
[Customer doesn't know where to go]
[Top up process unclear to customer]
[Top up merchant does not know the process]
[Merchant fraud]
[Agent fraud]
]
]
[Customer doesn't want to top up
[Dissatisfied with unit
[Performance below expectations
[Unit degradation]
[Poor installation]
]
[Unresolved maintenance issue]
[Unit stolen or vandalised]
]
]
]
\end{forest}
\end{document}
EDIT: For those who come across this question in future, here are the elements of the answers that I found most useful. These may be obvious to experienced forest users, apologies...
1) Growing a tree horizontally, rather than vertically, use this code after \begin{forest}
:
for tree={
child anchor=west,
parent anchor=east,
grow'=east}
2) Controlling text width, simply add text width=
inside the for tree={}
mentioned above.
3) Creating individual styles for nodes: name/.style={}
(see cfr's answer)
4) Altering the alignment of an individual node so that it sits equivalent to a different level in the tree: Put in a blank row (ie. nest within [ ]
).
Thanks for the very helpful responses.
text width
helps with the maximum width. The optionalign
can be used to set the vertical alignment of the lines. For example:for tree={node options={text width=2.5cm, align=left}}
.forest
specifically, but they all involvetikz
-based trees/graphs, so the principles would apply here too.