1

I got a solution for my quoestion about Smaller roofs for forest but I want to pass a command instead of text to a procedure and this causes an error:

! Argument of \@rsbox has an extra }.
<inserted text> 
                \par 
l.45 \end{forest}

?

This is the code:

\documentclass{minimal}   

\usepackage{forest}



\forestset{
  with translation/.style={
    l sep=0,inner xsep=0,
    append translation/.expanded/.wrap pgfmath arg={\gettranslation{##1}}{content},
    content/.expanded/.wrap pgfmath arg={\gettext{##1}}{content},
  },  
  append translation/.style={append={[#1,no edge,l=0,inner xsep=0,inner ysep=0,outer ysep=0,before
        computing xy={l-=2pt}]}},
  sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top},
                           where n children=0{tier=word,delay=with translation}{} 
                          }
}


\def\gettext#1{\gettextA#1;;\endget}
\def\gettextA#1;#2;{\removesep#1;}
\def\gettranslation#1{\gettranslationA#1;;\endget}
\def\gettranslationA#1;#2;{\removesep#2;}
\def\removesep#1;#2\endget{#1}





\newcommand{\trace}{\raisebox{0.2ex}{\_}\rule{0cm}{0.7em}}

\begin{document}


\begin{forest}
sn edges
[NP
  [Det [eine;a] ]
  [N$'$
    [A [kluge;smart] ]
    [N$'$
      [N [\trace ] ] ] ] ]
\end{forest}

\end{document}

\end{forest}

Is there a way to allow such commands in translated trees? I do not understand the code, so I am a bit helpless here ...

4
  • You can performa a \newsavebox\mybox \savebox\mybox{\trace} in advance of the forest and then use \usebox{\mybox} inside the forest. Commented Oct 15, 2014 at 10:28
  • use \noexpand\trace instead \trace in forest environment. But I don't know what is your intend. Your code generates overlapping text and I don't understand the mentioned package.
    – wipet
    Commented Oct 16, 2014 at 4:30
  • 1
    Stefan, I checked the couple question you posted in last couple of days, and in all honesty, it seems like a bit of a mess. Almost the same code appears in all of them, and any provided fix breaks something different. I've tried to answer this one, but I'm not sure if it's going to be helpful. I'm afraid that you are already confused by the code you have, and I make it even more complicated.
    – yo'
    Commented Nov 24, 2014 at 0:42
  • Thanks for your help! I try to find ways to use forestin an effective way. This involves tikz and both packages are very powerful. I learn from the examples by going then back to the manual and try to understand what is going on. The code is not mine and of course people would have done it differently if they new all the possible ways I wanted to use and misuse it. In any case I am very grateful to all the help I got here. By you and others. Thanks again! Commented Nov 24, 2014 at 7:20

1 Answer 1

2

As mentioned in the comments, you have two simple options that I present below. However, I'm not quite sure what you are after.

\documentclass{minimal}   

\usepackage{forest}



\forestset{
  with translation/.style={
    l sep=0,inner xsep=0,
    append translation/.expanded/.wrap pgfmath arg={\gettranslation{##1}}{content},
    content/.expanded/.wrap pgfmath arg={\gettext{##1}}{content},
  },  
  append translation/.style={append={[#1,no edge,l=0,inner xsep=0,inner ysep=0,outer ysep=0,before
        computing xy={l-=2pt}]}},
  sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top},
                           where n children=0{tier=word,delay=with translation}{} 
                          }
}


\def\gettext#1{\gettextA#1;;\endget}
\def\gettextA#1;#2;{\removesep#1;}
\def\gettranslation#1{\gettranslationA#1;;\endget}
\def\gettranslationA#1;#2;{\removesep#2;}
\def\removesep#1;#2\endget{#1}

\newcommand\trace{\raisebox{0.2ex}{\_}\rule{0cm}{0.7em}}

\newcommand\traceB{\usebox\tracebox}
\newsavebox\tracebox
\AtBeginDocument{
  \savebox\tracebox{\trace}
}

\begin{document}

\begin{forest}
sn edges
[NP
  [Det [eine;a] ]
  [N$'$
    [A [kluge;smart] ]
    [N$'$
      [N [\noexpand\trace ] ] ] ] ]
\end{forest}


\begin{forest}
sn edges
[NP
  [Det [eine;a] ]
  [N$'$
    [A [kluge;smart] ]
    [N$'$
      [N [\traceB ] ] ] ] ]
\end{forest}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .