I am editing a longtable. Some of my cells contain a lot of text. Page breaks seem to happen only where table rows end/begin. I'd like, however, for the rows to span pages; it's fine with me if, for example, the first few lines of a row are at the end of one page and the rest of the row's lines are on the next page.
[Tex/LaTex] Longtable: page breaks within row possible
longtablepage-breaking
Related Solutions
Use the parcolumns
package. Here is a small example:
\documentclass{article}
\usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{parcolumns}% http://ctan.org/pkg/parcolumns
\begin{document}
\begin{parcolumns}[nofirstindent,colwidths={1=2cm}]{4}
% Headings
\colchunk[1]{YEAR}
\colchunk[2]{\centering HISTORY}
\colchunk[3]{\centering CULTURE}
\colchunk[4]{\centering SCIENCE}
\colplacechunks
% Content
\colchunk[1]{\noindent 1770}
\colchunk[2]{\noindent\lipsum[1-3]}
\colchunk[3]{\noindent\lipsum[4-6]}
\colchunk[4]{\noindent\lipsum[7-9]}
\end{parcolumns}
\end{document}
Columns are constructed using \colchunk[<column>]{<stuff>}
and placed using \colplacechunks
. If you don't specify <column>
it's sequentially filled.
lipsum
(for dummy text, Lorem Ipsum style) and geometry
(for document layout) was used as an illustration in this example.
colortbl
doesn't much like \extracolsep
. For individual cells you can fiddle with the optional overhang arguments, but for rows that's a bit difficult.
Also your table isn't full width as the \extracolsep
glue is balanced by \LTleft
and \LTright
glue that is either side of the table.
If you make it full width, making the colour bands is much easier, as you know in advance how big they need to be:
\documentclass[9pt]{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage[margin=0.5in]{geometry}
\usepackage{fancyhdr}
\LTchunksize=200
\setlength{\parindent}{0cm}
\title{test}
\author{R}
\setlength{\headheight}{0.4in}
\setlength{\headwidth}{\textwidth}
\usepackage[table]{xcolor}
% define lightgray
\definecolor{lightgray}{gray}{0.9}
% alternate rowcolors for all long-tables
\let\oldlongtable\longtable
\let\endoldlongtable\endlongtable
%\renewenvironment{longtable}{\rowcolors{2}{white}{lightgray}\oldlongtable} {
%\endoldlongtable}
\def\zza{\global\let\zz\zzb
\fullwidthcolor{lightgray}}%
\def\zzb{\global\let\zz\zza}
\def\fullwidthcolor#1{\color{#1}\leaders\vrule\hskip\textwidth\hskip-\textwidth\kern0pt}
\def\resetLTcolor{\global\let\zz\zza}
\LTleft0pt
\LTright0pt
\begin{document}
\section{Sector}
\resetLTcolor
\begin{longtable}{ @{\zz\extracolsep{\fill}} |l | r | r | r | r | r|}
\hline
\multicolumn{1}{@{\fullwidthcolor{yellow}\extracolsep{\fill}} |l |}{}
& Beta & Phys & Phys & Phys & comp \\
\multicolumn{1}{@{\fullwidthcolor{yellow}\extracolsep{\fill}} |l |}{Industry Code}
& {} & {} & {} & {} & {} \endhead
\hline
Materials & 16,365,792 & 13,419,455 & 13,419,455 & 0.00 & -201,593 \\
Goods & 471,925 & 1,110,412 & 1,110,412 & 0.00 & -11,947 \\
Services & 7,122,991 & 8,511,225 & 9,492,570 & -981,345 & -75,117 \\
Banks & 5,078,280 & 6,123,238 & 12,084,671 & -5,961,433 & -69,738 \\
Health & 2,141,346 & 5,059,382 & 5,059,382 & 0.00 & -26,319 \\
Industrials & -6,013,491 & -4,758,346 & 6,036,445 & -10,794,791 & 3,722 \\
row & -4,093,746 & -3,755,730 & 0.00 & -3,755,730 & 45,628 \\
row & -1,753,606 & -1,006,601 & 2,533,792 & -3,540,393 & -18,962 \\
Consumer & 2,227,195 & 2,317,581 & 2,317,581 & 0.00 & -30,632 \\
All & 20,808,544 & 25,160,345 & 54,728,908 & -29,568,563 & nan \\
\hline
\end{longtable}
\end{document}
Best Answer
It is not in general possible. Consider if one cell is a large image and the next cell is text how would it break?
p
columns are essentially\parbox
es that do not break.