1

I want to put a lengthy caption at the end of a table, and, as currently formatted, the caption doesn't fit on the page with the last row of the table. The result is a rather ugly header on the last page; in particular, the double \hline in the head produces a horizontal line unattached to a table, which is rather unsightly. Basically, I'm looking for something like a \endlasthead.

Example code:

\documentclass[landscape]{article}
\usepackage{lmodern}
\usepackage{graphicx, longtable, multirow}

\begin{document}
\begin{longtable}{|c|c|}
\hline
\textbf{Letters} & \textbf{Numbers} \\
\hline \hline
\endfirsthead

\multicolumn{ 2 }{c}
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} 
\\ \hline 
\textbf{Letters} & \textbf{Numbers} \\ 
\hline \hline    
\endhead

\hline \multicolumn{2}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\endlastfoot

A & 1 \\ B & 2 \\ C & 3 \\ D & 4 \\ E & 5 \\ F & 6 \\ G & 7 \\ H & 8 \\ I & 9 \\ J & 10 \\ K & 11 \\ L & 12 \\ M & 13 \\ N & 14 \\ O & 15 \\ P & 16 \\ Q & 17 \\ R & 18 \\ S & 19 \\ T & 20 \\ U & 21 \\ V & 22 \\ W & 23 \\ X & 24 \\ Y & 25 \\ Z & 26 \\

\caption{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}
\end{longtable}

\end{document}

Here's a question where someone was able to change the first foot, so I'm guessing this should be possible. My tex fu isn't up to parsing @Heiko Oberdeik's solution, but if someone can explain how it could be modified for my purposes that would work.

2

Here is a solution that consists in fixing experimentally the width of the caption. The default for \LTcaptionwidth is 4in, I use captionsetup inside the table, just before \caption.

I also suppressed vertical lines, as it is bad typographical practice, and used booktabs.

Here is the code:

\documentclass[landscape]{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{graphicx, longtable, multirow, array}
\usepackage{caption, booktabs, threeparttablex}
\renewcommand\arraystretch{1.25}
\captionsetup{labelfont = {bf, small}, font = small}

\begin{document}

\noindent\begin{longtable}{@{\,}c@{} c@{}c@{}}
\toprule
\textbf{Letters} &\hspace{1.5em} & \textbf{Numbers} \\
 \cmidrule(l{4pt}r{2pt}){1-1}\cmidrule(l{4pt}r{4pt}){3-3}
\endfirsthead
%
\multicolumn{3}{c}
{{\small\bfseries \tablename\ \thetable}{} -- \footnotesize continued from previous page}
\\ \midrule
\textbf{Letters} & & \textbf{Numbers} \\
 \cmidrule(l{4pt}r{2pt}){1-1}\cmidrule(l{4pt}r{4pt}){3-3}
\endhead
%
 \cmidrule(l{4pt}r{4pt}){1-1}\cmidrule(l{4pt}r{4pt}){3-3}
\multicolumn{3}{r}{\footnotesize Continued on next page}
\endfoot
%
\bottomrule\addlinespace
\captionsetup{width =0.55\LTcapwidth}
\caption{Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}
\endlastfoot
%
A & & 1 \\ B & & 2 \\ C & & 3 \\ D & & 4 \\ E & & 5 \\ F & & 6 \\ G & & 7 \\ H & & 8 \\ I & & 9 \\ J & & 10 \\ K & & 11 \\ L & & 12 \\ M & & 13 \\ N & & 14 \\ O & & 15 \\ P & & 16 \\ Q & & 17 \\ R & & 18 \\ S & & 19 \\ T & & 20 \\ U & & 21 \\ V & & 22 \\ W & & 23 \\ X & & 24 \\ Y & & 25 \\ Z & & 26
%
\end{longtable}

\end{document} 

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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