Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have two tables (created with tabularx in the class):

[ Table 1 ]
[ Table 2 ]

They may be adjacent on the same page, or split across two pages like this:

[ Table 1 ]
---- page break ----
[ Table 2 ]

If and only if a page break occurs between Table 1 and Table 2 I would like to add text of the following sort:

[ Table 1 ]
continued on page M
---- page break ----
continued from page N 
[ Table 2 ]

I am not sure whether it is relevant that the blocks being split are tables, but I thought to include just in case.

Is this possible in LaTeX? If so, how?

Thanks for reading.

share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

You can set them both in the same table using ltxtable or another package that combines longtable and tabularx, then longtable can put the continued lines in at the page break by specifying them in the table head and foot.

As noted in comments, if you don't need alignment you can just nest normal tabularx (or \parbox here) in a longtable:

\documentclass{article}

\usepackage{longtable}

\begin{document}


\begin{longtable}{l}
\endfirsthead
continued from page \thepage
\endhead
continued on next page
\endfoot
\endlastfoot
\fbox{\parbox[t][3cm][c]{2cm}{a table}}\\
\fbox{\parbox[t][4cm][c]{2.5cm}{another table}}
\end{longtable}

\vspace{4cm}

\begin{longtable}{l}
\endfirsthead
continued from page \thepage
\endhead
continued on next page
\endfoot
\endlastfoot
\fbox{\parbox[t][3cm][c]{2cm}{a table}}\\
\fbox{\parbox[t][4cm][c]{2.5cm}{another table}}
\end{longtable}

\end{document}
share|improve this answer
    
Sometimes the answer is too easy ;-) –  Marco Daniel Mar 6 '12 at 18:40
    
Thanks for the prompt response. I am not sure ltxtable solves the problem, and due to a caveat I cannot use it: First, unless I misunderstand, LTXtable seems to be for splitting a single table whereas I have two separate tables. In any case, due to constraints on the system I am using I cannot import an external file with LTXtable. Is the solution you proposing to wrap Table 1 and Table 2 in a longtable environment? That may work. Thanks. –  Brian M. Hunt Mar 6 '12 at 19:00
    
yes I thought afterwards that just putting two tables in a single column longtable may be simpler for you, if you don't need alignment between the two tables. –  David Carlisle Mar 6 '12 at 20:05
    
code example added to answer –  David Carlisle Mar 6 '12 at 20:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.