I am trying to make a complicated table, where each cell itself can be a table.
I found I can include tabularx inside tabular*, but unable to figure out why I get an error with the outer table is tabularx as well. May be someone can see what I am doing wrong.
This MWE works. The one below it does not work.
\documentclass[10pt,notitlepage]{article}%
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{array}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{tabular*}{\textwidth}{p{\textwidth}}\hline
\begin{tabularx}{\textwidth}{@{}|Y|Y|Y|@{}}\hline
\href{foo/index.htm}{A}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}&
\href{foo/index.htm}{B}&
\href{foo/index.htm}{C}\\\hline
\end{tabularx}
\end{tabular*}
\end{document}
Now I change the outer table to tabularX and it failed:
\documentclass[10pt,notitlepage]{article}%
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{array}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{tabularx}{\textwidth}{@{}Y@{}}\hline
\begin{tabularx}{\textwidth}{@{}|Y|Y|Y|@{}}\hline
\href{foo/index.htm}{A}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}&
\href{foo/index.htm}{B}&
\href{foo/index.htm}{C}\\\hline
\end{tabularx}
\end{tabularx}
\end{document}
error is
(./foo2.out) (./foo2.out)
! Extra }, or forgotten \endgroup.
\TX@trial ...er \tabular \the \toks@ \endtabular }
\TX@ckpt \TX@typeout@ {\@s...
l.18 \end{tabularx}
?
Using texlive 2013 on linux
Best Answer
The nested
tabularx
should be surrounded by{
and}
This is per the documentation. I found it by doing a search on
nest
in the documentation.You should probably make a couple changes though. Using
\textwidth
within the innertabularx
is most likely going to result in columns being too wide. Instead use\linewidth
. Here is a modified nestedtabularx
construction: