# Page breaks inside paragraphs in longtable

I need to put long paragraphs in cells of a longtable as in the following MWE

\documentclass[10pt]{article}

\usepackage[margin=2cm,a4paper]{geometry}
\usepackage{lipsum}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage{color}
\definecolor{gray}{gray}{0.9}

\begin{document}

\begin{longtable}{|c|p{4.5cm}|p{5.5cm}|c|}%

\hline
\rowcolor{gray} \bf Column 1 & \bf Column 2 & \bf Column 3 & \bf Column 4 \\\hline
A & B & C & D \\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]%
} \\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]%
}
\\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]
}
\\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]
}
\\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]
}
\\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]
}
\\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]
}
\\\hline

\multicolumn{4}{|p{17cm}|}{
\lipsum[1-3]
}
\\\hline

\end{longtable}

\end{document}


However, longtables do not allow page breaks within rows, but only between rows. In my example, if the full paragraph/row does not fit in the current page, a lot of white space is left at the bottom of the page and a new page is started.

Is there a way to fill the pages with as much lines of a paragraph within a row as possible? The output would look like as follows

| ...                          |
|------------------------------|
| xxx xx xxx xxxx xx xxx xx xx |
| xxx xx xxx xxxx xx xxx xx xx |
| xxx xx xxx xxxx xx xxx xx xx |

<a page break here>

| xxx xx xxx xxxx xx xxx xx xx |
| xxx xx xxx xxxx xx xxx xx xx |
| xxx xx xxx xxxx xx xxx xx xx |
|------------------------------|
| ...                          |


One possibility is to use the mdframed package as in the following MWE

\documentclass[10pt]{article}

\usepackage[margin=2cm,a4paper]{geometry}
\usepackage{mdframed}
\mdfsetup{skipabove=0pt,skipbelow=0pt,topline=false}
\usepackage{lipsum}
\usepackage{colortbl}
\usepackage{color}
\definecolor{gray}{gray}{0.9}

\begin{document}

\noindent
\begin{tabular}{|p{8mm}|p{5cm}|p{7.45cm}|p{2cm}|}\hline
\rowcolor{gray} \bf No. & \bf Title & \bf WP Leader & \bf Months \\\hline
WP1 & A Work Package & A University & m6--m45 \\\hline
\end{tabular}
\vspace{-2pt}
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%

\vspace{4pt}
\noindent
\begin{tabular}{|p{8mm}|p{5cm}|p{7.45cm}|p{2cm}|}\hline
\rowcolor{gray} \bf No. & \bf Title & \bf WP Leader & \bf Months \\\hline
WP2 & A Work Package & A University & m6--m45 \\\hline
\end{tabular}
\vspace{-2pt}
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%

\vspace{4pt}

\noindent
\begin{tabular}{|p{8mm}|p{5cm}|p{7.45cm}|p{2cm}|}\hline
\rowcolor{gray} \bf No. & \bf Title & \bf WP Leader & \bf Months \\\hline
WP3 & A Work Package & A University & m6--m45 \\\hline
\end{tabular}
\vspace{-2pt}
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%

\vspace{4pt}

\noindent
\begin{tabular}{|p{8mm}|p{5cm}|p{7.45cm}|p{2cm}|}\hline
\rowcolor{gray} \bf No. & \bf Title & \bf WP Leader & \bf Months \\\hline
WP4 & A Work Package & A University & m6--m45 \\\hline
\end{tabular}
\vspace{-2pt}
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%

\vspace{4pt}

\noindent
\begin{tabular}{|p{8mm}|p{5cm}|p{7.45cm}|p{2cm}|}\hline
\rowcolor{gray} \bf No. & \bf Title & \bf WP Leader & \bf Months \\\hline
WP5 & A Work Package & A University & m6--m45 \\\hline
\end{tabular}
\vspace{-2pt}
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%
\begin{mdframed}
\lipsum[1-2]
\end{mdframed}%

\end{document}


Is this the best possible way to do it? Can we obtain the same result with the longtable package, to use its other nice features?

• only by hand, splitting each cell at an appropriate place and making two longtable rows. – David Carlisle Dec 7 '16 at 0:55
• ...another way of saying: "Avoid what you're doing, or use another tool." ;) – Werner Dec 7 '16 at 1:09
• Alas, it is not myself who designed the forms for which I am asking research funding :-( Is there any other latex package that could do the job ? I have seen mentioned other packages in similar threads like parcolumns or cals. Any suggestion ? – Esteban Zimanyi Dec 7 '16 at 7:39
• since you are just talking about one hand written document not automating thousands of pages, why is it a problem to split your text into two longtable rows? – David Carlisle Dec 7 '16 at 9:02
• In the document there are many sections/pages before the longtable. The longtable spanning multiple pages describes Work Packages, and for each of them I have to describe Objectives, Tasks, Deliverables, ... each of them in one or several paragraphs. I cannot manually put the pagebreaks since when adding/deleting content before the longtable would require to manually rearrange the pagebreaks again. In some other post you mention to use a list environment in order to split within a row. Could you please elaborate? – Esteban Zimanyi Dec 7 '16 at 9:20