I would like to easily create tree-like structures like
D─┬───────────┬───A
R─┬───A─┬─A R─┐
R─┐ R R
R
D is the top root node. It starts a horizontal line to the right, which stands for the "same level". This horizontal line can have more letters A
threaded at any position, which do not have additional semantic meaning. These letters A
always have a line incoming from the left.
The more interesting feature is that a horizontal line can split downwards to a child (base) node R
which always have a line incoming from the top. This split can happen at multiple positions on the horizontal baseline. The child nodes recursively start a new virtual block and hence are usually continued by an outgoing horizontal line to the right.- Hence, the R
next to the D
effectively starts the whole thing again in its own "bounding box" (here marked with +
).
D─┬───────────────┬───A
+++++++++++ R─┐
+R─┬───A─┬─A+ R
+ R─┐ R +
+ R +
+++++++++++
If for a node there are no more nodes connected to the right, then the horizontal outgoing line is not shown. And of course tree/text overlap needs to be avoided, i.e. some horizontal lines need to stretch far enough before starting a new child node. A type A
node also should only appear after all previous child blocks have completed to the left of them.
What would be the best way to create such a tree-like drawing in LaTeX?
I've found \usetikzlibrary{trees}
which goes in this direction, but I'm not sure how to flip the example, how to make multiple letters on a horizontal line, how to control text overlap, etc...
Any good suggestion how to recreate that diagram?
There is a working answer with manually positioning everything, but I hope there is another solution like tikz-tree which can calculate the positioning automatically for me, so that I only specify the child-node relations.
With arbitrary and longer labels:
D─┬───────────────────────G─┬─────C
Cc─┬─────────Aa─┬──Aaaa Eee─┐
Bbb─┐ Dd A
Aaaaa