2

As per the working MWE below (based on the solution https://tex.stackexchange.com/a/165337/69378), I like the simplicity of nesting a table into the cell of a parent table compared to the multirow package. Page breaking is one of my favourite capabilities of the longtable package and I'm wondering if it's possible to, rather than starting from longtable and using tabular sub-tables to create columns or tables to present greater details, use longtable in both instances.

Since it doesn't work to use two nested instances of longtable, is it possible to patch a macro or command to let longtable nest within other longtables or does the capabilities that let it split across pages make this too complicated?

I did test using tabular as the parent table, and tabular as the sub-tables which works fine, so I'd guess that it's indeed particular to the longtable code even though the errors thrown look pretty generic (missing end groups and paragraph ending before complete).

%https://tex.stackexchange.com/questions/165332/creating-a-table-within-a-longtable

\documentclass{article}
\usepackage{multirow,longtable}

\begin{document}

\begin{longtable}{ l l} 
    \hline
    Outer column & Detail column\\ 
    \hline      

    a & 
    \begin{tabular}{l l }
        A1 & B1 \\ 
        A2 & B2 \\ 
        A3 & B3 \\ 
    \end{tabular} 
    \\
    b & 
    \begin{tabular}{l l }
        A1 & B1 \\ 
        A2 & B2 \\ 
        A3 & B3 \\ 
    \end{tabular} 
    \\
    d & etc \\
    \hline
\end{longtable}

\end{document}
2
  • As far as I can see, there is no need for multirows or nested tables unless you want the contents of the outer column to be vertically centered with respect to the corresponding entries in the detail column.
    – leandriis
    Commented Mar 25, 2019 at 6:00
  • It would be perhaps possible to setup things so that you don't get an error from an inner longtable, but it wouldn't break either, so where is the point? Commented Mar 25, 2019 at 9:17

1 Answer 1

2

longtable never breaks a page within a row (apart from the fact that it isn't implemented it is not clear how in general you would specify compatible page breaking in every cell in the row). So even if things were adjusted so that you got no error message the longtable would effectively act like a standard tabular so there would be no advantages to doing this.

In the example shown you don't need nesting at all, just use blank cells in the first column.

1
  • Thanks a lot for your answer, I must be misremembering a previous use-case I had. I thought I remembered, at one point, having huge paragraphs of text in a row splitting itself adequately across a page break mid cell. Extrapolating on this, I thought I could get the sub rows to break themselves without introducing too much extra white space on a page, while preserving the outer layer. I wonder if I was thinking about tcolorbox... I think I will try and make a second MWE with sum large amounts of dummy text and p{} formatted columns to see if I can't pin down what I thought I remembered.
    – EngBIRD
    Commented Mar 26, 2019 at 4:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .