# Error missing \endgroup for table tabulary with bullet list

I'm trying to insert a bullet list in a table of the type tabulary , but it always throws following error!

 Missing \endgroup inserted.
<inserted text>
\endgroup
\end{tabulary}


Code used:

\usepackage{tabulary}
%%
\begin{center}
\begin{tabulary}{0.7\textwidth}{|L|L|}
\hline
First Title & Second Title \\
\hline
Text  &  \begin{itemize}
\item PointOne
\item PointTwo
\end{itemize} \\
\hline
\end{tabulary}
\end{center}


I've closed every \begin with an \end, and I've tried the same with the table type tabular and it works.

• Why specifically tabulary? Placing this in a fixed-width tabularx works. – Werner Oct 7 '14 at 0:26
• Because with tabulary it is easier to have different column sizes. I placed just an example, my real table will have more columns and in the bullet list more text. And still i don't know why LateX throws the error. – Nico Eli Oct 7 '14 at 0:38
• I'm sure one can duplicate the output with tabularx, but without a concrete example, it's difficult to say. tabularx also allows for "different column sizes". – Werner Oct 7 '14 at 0:46

## 2 Answers

I'm sure this must be documented in the tabulary documentation somewhere...

\documentclass{article}
\usepackage{tabulary}
\makeatletter
\def\TY@tab{%
\setbox\z@\hbox\bgroup
\let$\let$$% \let\equation$\let\endequation\$%
\let\@itemdepth\count@
\let\itemize\endgraf
\let\enditemize\endgraf
\let\endenumerate\endgraf
\let\list\@gobbletwo\renewcommand\item[1][]{}%
\let\endlist\endgraf
\let\trivlist\endgraf
\let\endtrivlist\endgraf
\col@sep\tabcolsep
\let\d@llarbegin\begingroup\let\d@llarend\endgroup
\let\@mkpream\TY@mkpream
\def\multicolumn##1##2##3{\multispan##1\relax}%
\CT@start\TY@tabarray}
\makeatother

\begin{document}
\begin{center}

\begin{tabulary}{0.7\textwidth}{|L|J|}
\hline
First Title & Second Title \\
\hline
Text  &  \begin{itemize}
\item PointOne
\item PointTwo
\end{itemize} \\
\hline
\end{tabulary}

\begin{tabular}{|p{3cm}|p{5cm}|}
\hline
First Title & Second Title \\
\hline
Text  &  \begin{itemize}
\item PointOne
\item PointTwo
\end{itemize} \\
\hline
\end{tabular}

\end{center}
\end{document}


One can also make it work with the varwidth environment. I added the enumitem package to have control on the itemize parameters, and cellspace to ensure a minimal vertical spacing above and below cells contents in a given column: one adds the S pre-specifier before the L specifier:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[debugshow]{tabulary}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{pbox, varwidth}
\usepackage{cellspace}
\usepackage{enumitem}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}
\addparagraphcolumntypes{L}
\usepackage{makecell}
\newcommand*{\topdblline}{\Xhline{0.15ex}\\[-2.6ex]\hline}
\newcommand*{\botdblline}{\hline\\[-2.6ex]\Xhline{0.15ex}}

\begin{document}

\centering
%%
\begin{tabulary}{0.7\textwidth}{|L|SL|}
\hline
First Title & Second Title \\
\hline
Text & \begin{varwidth}{0.7\textwidth}
\begin{itemize}[wide, itemsep =0.25ex]
\item PointOne
\item PointTwo
\end{itemize}
\end{varwidth}
\\
\hline
\end{tabulary}
\end{document}


• using enumitem to control lists in tables is good idea (the default spacing often doesn't work too well in tabular layout) downside of using varwidth here (or not, depending) is that ty will only see the width of the box rather than the total width of all the items so won't allocate so much space to that column as it would have done. – David Carlisle Oct 7 '14 at 22:44
• @David Carlisle: I'm not sure I'm getting well what you mean about the downside of varwidth (a package which I don't know well): what I thought was the length parameter to varwidth was a bound, and I set it with the value I had at hand; I might as well have chosen, say, 0.4\textwidth, but I didn't know whether both (real) columns have roughly the same width. – Bernard Oct 7 '14 at 22:59
• varwidth's an impressive package, but the way tabulary automatically allocates column widths is a 2-pass system and in the first pass as much as possible is set as a single horizontal box (which is why the list environment generated an error) and the length of the box for each column used as a measure of the amount of text in that column, then the final table is set with parboxes in proportion to that. varwidth (or any parbox) hides its content from tabulary's measuring pass, so tabulary will only see the width of the box not the width of its contents set on one line – David Carlisle Oct 7 '14 at 23:03
• I see… So it's a matter of trial and error, and I mght as well used a minipage? Or will it be OK on a second pass, since, as far as I understand it, varwidth also measures the length of its contents? – Bernard Oct 7 '14 at 23:10
• yes varwidth measures all kinds of stuff, the final table will work out with a reasonable layout I think (as your example shows) but (I think, it's late and I wrote this code decades ago:-) that typically tabulary will allocate a narrower column to the list in a varwidth than it would to a list at the top level (once it is fixed so that doesn't error) once the column width is allocated though varwidth and the list will get set properly in that width – David Carlisle Oct 7 '14 at 23:17