I'm using simple y/n macros as flags in my document to include or exclude certain parts of the overall document (these normally are in a separate "config.tex" file for ease of use). With the forest package, I get strange results when using this approach (using pdftex). The inserted texts seem to be interpreted as text instead of added or non-added leaves.
What am I doing wrong? Thanks in advance for your help.
Minimum working example:
\documentclass[]{scrreprt}
\usepackage{ifthen}
\usepackage[edges]{forest}
\newcommand{\AddIf}[3]{\ifthenelse{\equal{#1}{y}}{#2}{#3}}
\newcommand{\hasOptionOne}{y}
\newcommand{\hasOptionFour}{y}
\begin{document}
The user has the following options:
\begin{itemize}
\AddIf{\hasOptionOne}{\item Option One}{}
\item Option Two
\item Option Three
\AddIf{\hasOptionFour}{\item Option Four}{}
\end{itemize}
\begin{figure}
\centering
\caption{Available Options}
\label{fig-available-options}
\begin{forest}
for tree={draw,align=center},
forked edges,
[Main item
\AddIf{\hasOptionOne}{[Option One]}{}
[Option Two]
[Option Three]
\AddIf{\hasOptionFour}{[Option Four]}{}
]
\end{forest}
\end{figure}
\end{document}
Result:


foresthas a highly sophisticated and powerful parser. I believe it is practically hopeless to try to trick it this way, You would have to makes sure thatforestsees the expanded version of these\AddIfs, but the way you construct this command, already\edef\temp{\AddIf{\hasOptionOne}{\item Option One}{}}fails. So I would like to argue that you should resort to pureforestmethods to achieve what you want. – Jan 29 '19 at 17:52ifthenpackage because of such issues.) – Jan 30 '19 at 13:59