LaTeX forum ⇒ GeneralForest horizontal node alignement Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
Posts: 11
Joined: Tue Feb 07, 2017 1:56 pm

Forest horizontal node alignement

Postby cyanidebaby » Wed Aug 16, 2017 10:16 am


There are three, sharp-cornered, rectangular boxes at the top of the "forest table" which code I've pasted under. Let's call them the "Branch boxes".

The blank spaces between these "branch boxes" is not even, horizontally.
How do I make these spaces even?

Thank you.

  1. \documentclass{book}
  2. \usepackage{geometry}
  3. \usepackage[linguistics,edges]{forest}
  5. \begin{document}
  6. \begingroup
  7. \centering
  8. \begin{forest}
  9. for tree={
  10. l'=0pt,
  11. edge={->,>=latex},
  12. draw,
  13. fit=band,
  14. inner sep=2,
  15. },
  16. nice empty nodes,
  17. delay={
  18. where content={}{edge=-}{},
  19. },
  20. where level=2{}{rounded rectangle},
  21. forked edges,
  22. [Priest
  23. [Matador\\\textit{\small 1st Level}, tier=l1
  24. [\textbf{Green Branch},rounded corners=0pt
  25. [Junior Junior\\\textit{\small 2nd Level}, tier=l2,
  26. [Chief Eater Booster\\\textit{\small 8th Level}, tier=l8,
  27. [High Chief\\\textit{\small 10th Level}, tier=l10,
  28. [Grand Cookie Horsey\\\textit{\small 12th Level}, tier=l12,
  29. [Obvious Receptacle\\\textit{\small 15th Level}, tier=l15,]]]]]]
  30. [\textbf{Ecclesiastical Branch},rectangle,calign with current
  31. [Junior Driver\\\textit{\small 2nd Level}, tier=l2,
  32. [Library Leader\\\textit{\small 8th Level}, tier=l8,
  33. [Hotel Commandant\\\textit{\small 10th Level}, tier=l10,
  34. [Senior Ant-eater\\\textit{\small 12th Level}, tier=l12,
  35. [Administrative Daddy\\\textit{\small 15th Level}, tier=l15,
  36. [Mommy\\\textit{\small 16th-17th Level}, tier=l17,
  37. [, tier=l18 [Grand Lord\\\textit{\small 19th-20th Level}, tier=l19
  38. [Grand Grandiose\\\textit{\small 20th Level \& up}, tier=l20]]]]]]]]]]
  39. [\textbf{Military Branch},rectangle
  40. [Walker\\\textit{\small 2nd Level}, tier=l2,
  41. [, tier=l3 [, tier=l4 [Senior Walker\\\textit{\small 5th Level}, tier=l5,
  42. [, tier=l6 [Ranking Interviewer\\\textit{\small 7th Level}, tier=l7,
  43. [, tier=l8
  44. [Astronaut\\\textit{\small 9th Level}, tier=l9,
  45. [,tier=l10 [Doctor\\\textit{\small 11th Level}, tier=l11,
  46. [,tier=l12 [,tier=l13 [,tier=l14 [,tier=l15 [Great Doctor\\\textit{\small 16th Level}, tier=l16,]]]]]]]]]]]]]]]]
  47. ]
  48. ]
  49. \end{forest}
  50. \par
  51. \endgroup
  52. \end{document}


User avatar
Stefan Kottwitz
Site Admin
Posts: 8523
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany

Postby Stefan Kottwitz » Wed Aug 16, 2017 2:30 pm


that's for symmetry: if you would make the spaces even, the whole branches would have a different distance to the middle. I thing an overall asymmetry is more bad than a single internal distance.

But there's another solution other than to change the spacing itself: make the width of the boxes equal, such as

  1. [\textbf{Green Branch},rounded corners=0pt,minimum width=4cm
  2. ...
  3. [\textbf{Ecclesiastical Branch},rectangle,minimum width=4cm,
  4. ...
  5. [\textbf{Military Branch},rectangle,minimum width=4cm
  6. ...

Just choose the minimum width so that the widest text fits. It can be automatically measured though, such as by using \settowidth. For repeating things, such as rectangle style with the same width, I would introduce a style.

Site admin

Posts: 11
Joined: Tue Feb 07, 2017 1:56 pm

Postby cyanidebaby » Wed Aug 16, 2017 4:58 pm

Thanks very much, Stefan.
That works.

I guess I'm just going to have to figure out which look I prefer!

Thanks again.

Return to “General”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 guests