Graphics, Figures & TablesLongtable and wrapping

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
and_mue
Posts: 1
Joined: Fri Jun 19, 2015 10:00 am

Longtable and wrapping

Post by and_mue »

Dear Latex Community,

I am relatively new to Latex and I have currently a problem when generating a longtable that spans across multiple pages and the wrapping of a footnote and or other text within the table. Please find my example code below. I tried to use the \multicolumn command as I want that the text goes across all four columns, however, this does not work properly i.e. no wrapping. Furthermore, I tried to use \caption*, did not work either. Has somebody any suggestions on how I can do this?

Thank you and kind regards
Andreas

Code: Select all

\begin{center}
\begin{longtable}{ccrr}
\caption[Descriptive statistics]{Descriptive statistics} \label{tab:Descriptive statistics} \\

[b]Here I want a text that goes across the four columns and is wrapped at the end on new rows. If possible, this should appear on each page. Alternatively, this can be put at the end of the table. [/b]

\multicolumn{4}{l}{Panel A: XXX} \\
\hline
\rule{0pt}{3ex}  
\multirow{2}{*}{XXX} & 
\multirow{2}{*}{XXX} & 
\multicolumn{2}{c}{XXX)} \\
 & & \multicolumn{1}{c}{XXX} & \multicolumn{1}{r}{XX} \\
\hline \\ [-2ex]
\endfirsthead
\multicolumn{4}{c}%
{\small{{\bfseries \tablename\ \thetable.{}} XXX (continued)}} \\ [1ex]
\hline \\ [-2ex]
\endhead
\hline \multicolumn{4}{r}{{Continued on next page}} \\
\endfoot
\endlastfoot
    XXX  & XXX   & XXX & XXX \\
\multicolumn{4}{l}{Panel B: XXX}\\
\hline
& & \multicolumn{1}{c}{XXX} & \multicolumn{1}{r}{XXX} \\
\hline
\end{longtable}
\end{center}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Longtable and wrapping

Post by Johannes_B »

Hi and welcome,

i am not quite sure what you are trying to achieve. Always hard to guess when a table only contains XXX. Using standard article, the table perfectly fits on one page as well. Put some funny animals in the table, or fruit, or vegetable or ... be a bit creative. Helping is more fun that way ;-)

By the way, you adjusted spacing after rules, you might be interested in package booktabs.

Code: Select all

\documentclass{article}
\usepackage{showframe}
\usepackage{multirow}
\usepackage{longtable}
\begin{document}
%\begin{center}% JB: No
	\begin{longtable}{ccrr}
		\caption[Descriptive statistics]{Descriptive statistics} \label{tab:Descriptive statistics} \\
		\multicolumn{4}{p{.9\linewidth}}{Panel A: XXX
		Here I want a text that goes across the four columns and is wrapped at the
		end on new rows. If possible, this should appear on each page.
		Alternatively, this can be put at the end of the table. 
		} \\
		\multicolumn{4}{l}{Panel A: XXX} \\
		\hline
		\rule{0pt}{3ex}  
		\multirow{2}{*}{XXX} &
		\multirow{2}{*}{XXX} &
		\multicolumn{2}{c}{XXX)} \\
		& & \multicolumn{1}{c}{XXX} & \multicolumn{1}{r}{XX} \\
		\hline \\ [-2ex]
	\endfirsthead
	\multicolumn{4}{c}%
	{\small{{\bfseries \tablename\ \thetable.{}} XXX (continued)}} \\ [1ex]
	\hline \\ [-2ex]
\endhead
\hline \multicolumn{4}{r}{{Continued on next page}} \\
\endfoot
\endlastfoot
XXX  & XXX   & XXX & XXX \\
\multicolumn{4}{l}{Panel B: XXX}\\
\hline
& & \multicolumn{1}{c}{XXX} & \multicolumn{1}{r}{XXX} \\
\hline
\end{longtable}
%\end{center}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply