tikz.dev / forest Manual

Forest

Reference

3.12 Handlers

Handlers are a powerful mechanism of pgfkeys, documented in [Tantau 2013, §82.3.5]. Handlers defined by Forest perform a computation and invoke the handled key with its result. The simple handlers are documented in this section: for .process, see §3.13; for aggregate function handlers, see §3.14.

  • .option=⟨option⟩(handler)

  • The result is the value of ⟨option⟩ at the current node.

  • .register=⟨register⟩(handler)

  • The result is the value of ⟨register⟩.

  • .pgfmath=⟨pgfmath expression⟩(handler)

  • The result is the evaluation of ⟨pgfmath expression⟩ in the context of the current node.

    • If you only need to access an option or register value, using .option or .register is much faster than using .pgfmath.

  • .wrap value=⟨macro definition⟩(handler)

  • The result is the (single) expansion of the given ⟨macro definition⟩. The defined macro takes one parameter. The current value of the handled option will be passed as that parameter.

  • .wrap \(n\) pgfmath args=⟨macro definition⟩⟨arg \(1\)⟩…⟨arg \(n\)⟩(handler)

  • The result is the (single) expansion of the given ⟨macro definition⟩. The defined macro takes \(n\) parameters, where \(n\in\{2,\dots,8\}\). Expressions ⟨arg \(1\)⟩ to ⟨arg \(n\)⟩ are evaluated using pgfmath and passed as arguments to the defined macro.