4

The following MWE compiles just fine:

\documentclass{article}
\usepackage{forest}
\begin{document}

%\begin{tabular}{c}
  \begin{forest}
    [x\\y, align=center
      [z]
    ] 
  \end{forest}
%\end{tabular}

\end{document}

However, if the commented lines are un-commented, an error results:

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

The error is not consistent across cases. Sometimes the compiler complains like so:

Use of \@argarraycr doesn't match its definition.

On the other hand, the following code -- which retains the tabular environment but gets rid of the node under the multi-line node -- compiles:

\documentclass{article}
\usepackage{forest}
\begin{document}

\begin{tabular}{c}
  \begin{forest}
    [x\\y, align=center
      %[z]
    ] 
  \end{forest}
\end{tabular}

\end{document}

Somewhat oddly, I have never experienced this sort of error prior to a week ago. I update using tlmgr fairly regularly, so I would guess some update in some package somewhere is to blame. But I wouldn't venture a guess as to which. Replacing all occurrences of \\ with \protect\\ does resolve the error, but this still seems like a bug, since it is new behavior.

  • 1
    I can confirm the problem using forest.sty 2015/07/15 v1.09 Drawing (linguistic) trees Using an older version doen't produce the error. – Gonzalo Medina Jul 22 '15 at 15:38
  • I think the following is related: [\phantom{x}[y]] produces an error inside a forest, but neither [\protect\phantom{x}[y]] nor [\phantom{x}] do. – Simon C Jul 22 '15 at 15:46
  • This seems, indeed, like a bug. You should contact the package author (he might also see this question here, but an e-mail might be quicker). – Gonzalo Medina Jul 22 '15 at 15:57
  • 1
    Well, this is a funny bug, in my opinion. I have forgotten to remove a debug statement when releasing v1.09. Can you please confirm that removing line 2580 from forest.sty (... DEBUG calign ...) solves the problem? – Sašo Živanović Jul 22 '15 at 16:16
  • @SašoŽivanović Hi. Yes, I can confirn that removing that line solves the problem. – Gonzalo Medina Jul 22 '15 at 16:35
1

This is a bug introduced into forest v1.09. It is fixed in v1.0.10, which is available on ctan.

The bug is due to a leftover debugging statement, which issues a \typeout command, whose argument contains (after expansion) a \\ in the above non-working example.

Now, this is normally not a problem: having \typeout{\\} in the main body of a document is just fine. However, some environments redefine \\ in such a way that it is un-\typeoutable (e.g. tabular or flushleft): having \typeout{\\} inside such an environment will produce weird errors.

The working example above worked because the offending \typeout statement is run (in forest v1.09) only for nodes with exactly one child.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.