# Implementing a tabular within a forest node produces two bracket failures

i'm currently using the forest-usepackage in order to build up a family tree. I'd like to implement a table within a forest node. As long as i don't hit the 100 failure mark the code will be compiled and everything looks fine.

My Question: How to get rid of my bracket failures?

I got an minimized example right below.

\documentclass[margin=1cm]{standalone}
%
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[edges,linguistics]{forest}
\usepackage{textcomp}
%
\begin{document}
%
\begin{forest}
for tree=
{
draw,
minimum height=3cm,
minimum width=3cm,
l sep+=2cm,
edge path={\noexpand\path[\forestoption{edge}] (\forestOve{\forestove{@parent}}{name}.parent anchor) -- +(0,-1cm)-| (\forestove{name}.child anchor)\forestoption{edge label};}
}
[{\begin{tabular}{ll}{Stephanus & \\ ... & ... \\ abc & äöü}\end{tabular}}
[Christina]
[Maria]
[Stephanus]
]
\end{forest}
%
\end{document}


The only messages that are shown are:

Error line 25 !Missing }inserted.<inserted text>}\end{forest}

Error line 25 !Missing {inserted.<inserted text>{\end{forest}

"I've put in what seems to be necessary to fix
the current column of the current alignment.
Try to go on, since this might almost work."

• Welcome to TeX.SX! Placing the contents of the tabular environment in braces appears to be to blame (I'm not entirely clear why) \begin{tabular}{ll} Stephanus & \\ ... & ... \\ abc & äöü \end{tabular} compiles without error. – Dai Bowen Mar 25 '17 at 18:54

If you will drop curly braces (the cause of your troubles are inner ones) in table, than your problem will disappear:

\documentclass[margin=3mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[edges,linguistics]{forest}
%\usepackage{textcomp}

\begin{document}
%
\begin{forest}
for tree = {draw,
minimum height = 2cm, % <-- changed
minimum width = 3cm,
font = \linespread{.9}\selectfont, %< -- added for less vertical space between lines in nodes
l sep = 12mm,
fork sep = 6mm  % <-- added
}
[ \begin{tabular}{r@{\hskip=6pt}l} %<-- changed tabcolsep
Stephanus & Cornellus  \\
??    & 1234       \\
abc & defghijk
\end{tabular}% <-- here I remove surplus braces
[Christina]
[Maria]
[Stephanus]
]
\end{forest}
%
\end{document}


Edit: small changes (deleting of edge path = {...} is stolen from @cfr answer), which to my taste make tree more beautiful :). All are designated in above code.

• It wasn''t the braces around the tabular that were the problem, but rather the braces around the content of the tabular! (These: {Stephanus & \\ ... & ... \\ abc & äöü}.) – Sašo Živanović Mar 25 '17 at 20:01
• yes, the cause were inner braces. but after their removing I see, that also work without outer too. probably they should be returned for cases (I suppose), when in tabular are[  ]. – Zarko Mar 25 '17 at 20:07
• This may work, but you could just use align, which seems simpler to me. And the edges library is not doing much here. ;) – cfr Mar 26 '17 at 0:29

When you specify align in Forest, you are actually giving a tabular specification. Hence, your code attempts to nest a tabular within a tabular, which is not really necessary and will probably just create unwanted space.

Also, you don't appear to be using the edges library, despite loading it, but are instead emulating its forked edges style. It would be easier to use the pre-defined style and just adjust the distance between the parent and the fork.

\documentclass[border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[edges,linguistics]{forest}
\usepackage{textcomp}

\begin{document}

\begin{forest}
forked edges,
for tree={
draw,
fork sep'=1cm,
minimum height=3cm,
minimum width=3cm,
l sep+=2cm,
}
[Stephanus & \\ ... & ... \\ abc & äöü, align={ll}
[Christina]
[Maria]
[Stephanus]
]
\end{forest}

\end{document}


# EDIT

If you want to specify a different inter-column spacing for the tabular, you cannot write

align={l@{\hskip <dimension>}l}


as this upsets Forest's parser.

However, you can do one of two things.

First, if you want to change the spacing between two columns, you can load the array package and create a new column type. For a left-aligned column followed by variable column spacing,

\newcolumntype{k}[1]{l@{\hskip #1}}


allows you to write

align={k{2.5pt}l}


If you want to alter the inter-column spacing for all tabulars in the tree, you can simply execute the relevant TeX code. For example,

TeX={\setlength{\tabcolsep}{10pt}}


\documentclass[border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[edges,linguistics]{forest}
\usepackage{textcomp,array}
\newcolumntype{k}[1]{l@{\hskip #1}}
\begin{document}
\begin{forest}
forked edges,
for tree={
draw,
fork sep'=1cm,
minimum height=3cm,
minimum width=3cm,
l sep+=2cm,
}
[\multicolumn{2}{l}{Stephanus}  \\ ... & ... \\ abc & äöü, align={ll}
[Christina]
[Maria]
[Stephanus]
]
\end{forest}
\begin{forest}
forked edges,
for tree={
draw,
fork sep'=1cm,
minimum height=3cm,
minimum width=3cm,
l sep+=2cm,
}
[\multicolumn{2}{l}{Stephanus}  \\ ... & ... \\ abc & äöü, align={k{2.5pt}l}
[Christina]
[Maria]
[Stephanus]
]
\end{forest}
\begin{forest}
forked edges,
TeX={\setlength{\tabcolsep}{10pt}},
for tree={
draw,
fork sep'=1cm,
minimum height=3cm,
minimum width=3cm,
l sep+=2cm,
}
[\multicolumn{2}{l}{Stephanus}  \\ ... & ... \\ abc & äöü, align={ll}
[Christina]
[Maria]
[Stephanus]
]
\end{forest}
\end{document}


demonstrates the effects:

• good solution! I was not aware for align={...} option. now I wonder, if it is possible to change tabcolsep inside forest environment or is only solution to encapsulate forest in group, where before forest is defined tabcolsep? – Zarko Mar 26 '17 at 8:36
• @Zarko I'm sure you can do it. Here, I'd just specify the dimension directly if I wanted it to be different e.g. l@{1pt}l or whatever as that seems simpler. – cfr Mar 26 '17 at 15:54
• Unfortunately this doesn't work. It print out 1pt. Do I miss something? Reading of forest documentation doesn't help me much, I find only example how to write a table with forest (page 38), but example is so complicated (I still not figured out, how it works) that to my opinion is simpler to use standard table in node. – Zarko Mar 26 '17 at 17:01
• @Zarko Hmm. Yes. The usual @{\hskip 1pt} does not seem to work ... – cfr Mar 26 '17 at 18:36
• well, than my answer solve this (since use standard tabular), but this was not OP concern :) – Zarko Mar 26 '17 at 18:40