I would like to be able to change the content of the nodes, from a home made parameter list to an actual text.
For example, I would like to create trees such as:
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[9;12;4
[31;21]
[3
[14]
[7;21;3]
]
]
\end{forest}
\end{document}
will be formatted this way:
Basically, depending on the number of parameters, separated by a semi-column, I would like to format the final content differently:
- with 1 parameter, format is "#1 is the one"
- with 2 parameters, format is "with #1[#2]"
- with 3 parameters, format is "$#2 \geq #1$ for #3 cases"
So far, I managed to split the content of each node with split option, but I did not succeed to know how many I actually have, and access each of them.
What I am looking for is something like:
before typesetting nodes={
for tree={
split option={content}{;}{params},
if {length(params) = 1}{content=params[1] is the one}{
if {length(params) = 2}{content=with params[1][params[2]]}{
if {length(params} = 3}{content=$params[2] \geq params[1]$ for params[3] cases}
{}
}
}
}
}
PS: The reason I am trying to do that in such way it's because I need to create a lot of big trees with the same node format. And from a writer perspective, it is much easier to just chose the parameters of each nodes and keep the formatting separated, especially if you have to change it later.


