Graphics, Figures & Tableslongtable | Correct Appearance

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
buzon
Posts: 7
Joined: Tue Jan 17, 2012 1:08 am

longtable | Correct Appearance

Post by buzon »

Hello,
I am struggling with the longtable - I used to have a table in tabular environment before,
but when the table didn't fit well to the page, I decided to try longtable as a solution.

My goal is to have nice long table, automatically broke to the pages.

How to do this correctly? (check my failing code)

Code: Select all

\documentclass[10pt,a4paper]{article}

\usepackage[table]{xcolor} % for colors in tables
\usepackage{tabularx} 
\usepackage{color} % for font color
\usepackage{caption}
\usepackage{multirow}  % for multirows in tables
\usepackage{longtable}
\usepackage[Q=yes]{examplep} %for verbatim 

\begin{document}

\begin{longtable}{|c| p{9.5cm}|}
\hline
\multicolumn{2}{|c|}{ \cellcolor{gray} \textbf{ \Q{\\textcolor{white}{ Title_here }}} } \\  
\hline
\hline
\multicolumn{2}{|c|}{ \cellcolor{yellow} \textbf{Medium} } \\
\hline Description & 

ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline
ds\newline

\\
\hline Foo & bar \\
\hline
\caption{\protect\Q{Title_here}}  
\end{longtable}

\end{document}

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: longtable | Correct Appearance

Post by Stefan Kottwitz »

Hi,

longtable can break between rows, but it cannot make a page break within a cell. The example has a huge row, which cannot be broken. It would work if you have rows in common height. Perhaps it wasn't a good test example and your real content has normal rows.

Stefan
LaTeX.org admin
Post Reply