sasozivanovic / forest

a PGF/TikZ-based LaTeX package for drawing (linguistic) trees
LaTeX Project Public License v1.3c
64 stars 4 forks source link

[doc] Please provide basic forestset usage to apply style to all nodes #2

Closed ysalmon closed 7 years ago

ysalmon commented 7 years ago

Hello, I have been using forest for one year (and I am glad it exists ; thanks a lot for this !), albeit in a very basic way : I mostly typeset trees whose nodes are circles labeled by integers. I use to define the default style of the nodes in a \forestset command, but as stated page 85 of the documentation (changelog for v 2.0.0), the "old way" of doing this was removed but a "drop in" replacement is not given.

The documentation provides examples to do very complicated things using the several stages of the typesetting process, but I cannot understand how to apply a style to all nodes. What I currently do is, after fumbling with different versions,

\forestset{%
before typesetting nodes={for tree={circle,
    draw,
    inner sep=0pt,
    minimum size=.5cm}}
}

but it seems to be completely ignored when typesetting the tree as follows

\begin{forest}
[8 [7 [6] [9]] [13 [12] [15]]]
\end{forest}

I also would like to change the font size of the node labels. What should I do ?

sasozivanovic commented 7 years ago

Hi! Glad you like the package!

Since v2.0, toks register default preamble can be used to set the "instructions" which apply to all trees:

\forestset{%
  default preamble={
    for tree={
      circle,
      draw,
      inner sep=0pt,
      minimum size=.5cm,
      font=\Huge\bf,
    }
  }
}

To change the size (or other parameters) of the node font, use key font. This is a TikZ key, so it is not documented in the Forest manual. Rather, see section 17 of PGF(3) manual.

You're right: in would be useful to have an example of default preamble in the documentation. I'll add it to the tutorial.

By the way, your code above is not an example of the "old way", and I will intentionally not provide an example of it either ;-). As far as I can see (and I did some tests), your example doesn't work in any version. Here's why: before typesetting nodes is a node option and must therefore be used when some node is current, which is not the case when within \forestset outside a tree (unless some form of spatial propagation is used, which is not the case in your code).

ysalmon commented 7 years ago

Thank you so much for this (quick !) reply. The forestset I provided was not what I used (and worked) in earlier versions but my feeble attempt at porting the old code to the new version.