I created a flowchart with tikz. While I am happy with the result it bothers me that I create the size of the boxes through manually applied linebreaks. Is there a way to tell the program to adjust the size of the boxes to the amount of text they contain? It would be ideal to define a maximum width for each box. Here is my example:
\documentclass[border=10pt,
tikz]{standalone}
\usetikzlibrary{trees}% <-- new
\usepackage[osf]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\begin{document}
\begin{tikzpicture}[
every node/.style = {shape=rectangle, rounded corners,
draw, align=center, fill=white}, level distance=4cm,
level 1/.style = {sibling distance = 60em},% <-- new
level 2/.style = {sibling distance = 24em},% <-- new
level 3/.style = {sibling distance = 13em},% <-- new
level 4/.style = {sibling distance = 11em},% <-- new
level 5/.style = {sibling distance = 21em},% <-- new
]
\node {Aristoteles’ Einteilung \\menschlichen Handelns\\ (Rhetorik, 1368b 33)}
[edge from parent fork down]
child {node{was man nicht\\ von sich aus tut}
child {node{Aus Zufall}
child {node{Zufall und Schicksalsfügung\\ gehören zu den Ursachen\\ Physik, 195b4\\ Zufall im Bereich menschlichen \\Handelns im Ggs. zum Vorsatz.\\Bewegursache }child{node {Unbestimmte,\\ akzidentelle Ursachen}}
}}child{node {Aus Notwendigkeit}child{node {durch Gewalt (Zwang?)}}child{node {von Natur aus}child{node {Ursache in den Dingen selbst}child{node {Weder freiwillig noch unfreiwillige \textit{Vorgänge}\\z.\,B. Altern und Sterben}}child{node {Nichtfreiwillige Bewegungen\\z.\,B. Schlaf, Erwachen Atmung}}}}}}
child{node {was man von\\ sich aus tut}child{node {Tun aus Gewohnheit}child{node {Kein Habitus \\im Sinne der Tugend}child{node {Problem: ist ein Tun aus\\ Gewohnheit freiwillig\\ im eigentlichen Sinne? }}}}child{node {aus Streben}child{node {vernünftiges Streben}child{node {Wollen\\ d.\,i. Streben nach Gutem}}}child{node {vernunftloses Streben}child{node {Zorn und Begierde}}}}}
;
\end{tikzpicture}
\end{document}
Best Answer
This shows two potential options for making a node where
text width
is set relative to the length of the text in the node.And the macro version implemented for your tree. Note that I set the
text width
to whichever is larger of 30% the text length or 3cm, otherwise it wouldn't work well for shorter nodes. Note also that this method did not work for the node that had\textit
in it, so for that one the text width is set manually.