I am creating a large table which contains smaller tables in some cells. I was able to do this simply with the tabularx package, which allowed me to automatically size columns and wrap text. However, my table will span multiple pages, and I'd like automatic page breaks.
I tried ltablex package, which nicely breaks my table over multiple pages but only when there are no tables nested within cells. I tried using a tabular table (instead of tabularx) inside of a cell, and that works fine. However, I need the text-wrapping capabilities of the tabularx package for my nested table as well.
Here's some example code which works fine with the ltablex package commented out (first image below) but goes over the edge of my page. Similarly, ltablex works fine if I comment out the nested table in row 3 (second image below). I'm hoping someone can suggest a simple way to have the best of both worlds.
\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage{ltablex}
\usepackage{tabularx}
\makeatletter
\newcommand{\cellwidth}{\TX@col@width}
\makeatother
\begin{document}
\begin{tabularx}{\linewidth}{|l|X|X|X|}
\hline
Column 1 & Ideally, this text will wrap automatically inside the cells. The table should contain other tables in some cells. The table should be able to break across pages automatically. & Column 3 & Column 4 \\ \hline
Column 1 & Ideally, this text will wrap automatically inside the cells. The table should contain other tables in some cells. The table should be able to break across pages automatically. & Column 3 & Column 4 \\ \hline
&{\begin{tabularx}{\cellwidth}{|X|X|}
\hline
col 1 & col 2 \\ \hline
col 1 & col 2 \\ \hline
\hline
\end{tabularx}}&& \\ \hline
Column 1 & Ideally, this text will wrap automatically inside the cells. The table should contain other tables in some cells. The table should be able to break across pages automatically. & Column 3 & Column 4 \\ \hline
Column 1 & Ideally, this text will wrap automatically inside the cells. The table should contain other tables in some cells. The table should be able to break across pages automatically. & Column 3 & Column 4 \\ \hline
Column 1 & Ideally, this text will wrap automatically inside the cells. The table should contain other tables in some cells. The table should be able to break across pages automatically. & Column 3 & Column 4 \\ \hline
\end{tabularx}
\end{document}
With tabularx nested tables, no page breaking:
With ltablex table, no nested table:
Thank you!