From the documentation, there is something called action character=@ to unfold macros. But if i try to use it with this code:
\newcommand{\hierarchy}[1]
{
\bracketset{action character=@}
\begin{forest}
forked edges,
for tree={
font=\sffamily\bfseries,
line width=1pt,
draw=linecol,
ellip=5,
align=center,
grow'=0,
edge+={color=linecol, line width=1pt, rounded corners=5pt, -Stealth},
drop shadow,
anchor=parent,
l sep'+=5pt,
},
where={isodd(n_children())}{%
for n/.wrap pgfmath arg={{#1}{calign with current edge}}{int((n_children()+1)/2)}
}{},
where level=2{tier=second}{}
@{#1}
\end{forest}
}
}
there is a error which says:
Package forest error: nodewalk stepped to the invalid node
I guess it has something to do with the second #1 expression in
where={isodd(n_children())}{%
for n/.wrap pgfmath arg={{#1}{calign with current edge}}
{int((n_children()+1)/2)}
}{},
Any suggestions how to handle this?
Here is an complete example document:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta,shapes.geometric,shadows}
\title{Tests}
\date{October 2017}
\tikzset{ellip/.append style={rounded rectangle, inner color=blue!30, outer color=blue!40}}
\newcommand{\hierarchy}[1]
{
{\footnotesize
\bracketset{action character=@}
\begin{forest}
forked edges,
for tree={
font=\sffamily\bfseries,
line width=1pt,
draw=black,
ellip=5,
align=center,
grow'=0,
edge+={line width=1pt, rounded corners=5pt, -Stealth},
drop shadow,
anchor=parent,
l sep'+=5pt,
},
where={isodd(n_children())}{%
for n/.wrap pgfmath arg={{#1}{calign with current edge}}{int((n_children()+1)/2)}
}{},
where level=2{tier=second}{}
@{#1}
\end{forest}
}
}
\begin{document}
\hierarchy{
[Test1[Test2][Test3[...]]]
}
\end{document}
\hierarchymacro is meant to be used. – diabonas Oct 08 '17 at 12:55! Package PGF Math Error: Unknown function \Test1' (in '[Test1[Test2][Test3[.... This is because as your'e in a macro definition,#1is replaced by the argument to\hierarchy, which is not what you want. Doubling the hash sign to##1` (only in line 35) solves this problem, and the document compiles with error for me. – diabonas Oct 08 '17 at 14:16