我需要将长段落放在 longtable 的单元格中,如以下 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}
但是,长表不允许在行内分页,而只能在行之间分页。在我的示例中,如果当前页面放不下整个段落/行,则页面底部会留下大量空白,并开始新的一页。
有没有办法让每行中尽可能多的段落行填满整个页面?输出结果如下
| ... |
|------------------------------|
| 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 |
|------------------------------|
| ... |
一种可能性是使用 mdframed 包,如下面的 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}
这是最好的方法吗?我们可以使用 longtable 包获得相同的结果,并利用其其他优秀功能吗?