根据我的问题如何修复下一页上拆分的 Longtable 多列,现在我有这个代码:
\documentclass[a4paper,oneside,11pt]{book}
\usepackage[hmargin={3cm,2cm},vmargin={2cm,2cm}]{geometry}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage[labelsep=period]{caption}
\titlespacing{\chapter}{0cm}{-1.2cm}{0.7cm}
\titlespacing*{\section}
{0pt}{2ex plus 1ex minus .2ex}{2ex plus .2ex}
\titleformat{\section}
[hang]
{\bfseries}
{\bfseries\thesection}{1ex}{\bfseries}
\begin{document}
\chapter{Random Text}
\section{Section Name}
\lipsum[1]
\begingroup
\setcellgapes{5pt}
\makegapedcells
\begin{longtable}{|c|c|p{9cm}|}
\caption{Random text for caption here.}
\label{table1} \\
\hline
\textbf{Head1}&\multicolumn{2}{c|}{\textbf{Head2}} \\
\hline
\endfirsthead
\caption[]{Random text for caption here. (Continue)} \\
\hline
\textbf{Head1}&\multicolumn{2}{c|}{\textbf{Head2}} \\
\hline
\endhead
\multicolumn{3}{r @{}}{\small\emph{continue on the next page}} \\*
\endfoot
\hline
\endlastfoot
%%%% table nody
1&Text2&Long text here.\\
\cline{2-3}
&Text2&\lipsum[4]\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\hline
2&Text2&Long text here.\\
\cline{2-3}
&Text2&\lipsum[4]\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\hline
\end{longtable}
\endgroup
\section{Section Name 2}
\lipsum[2]
\end{document}
答案1
简单的解决方法是,您可以添加\newpage
要移动到下一页的行。您可以让上一页的最后一行移动到下一页。
\documentclass[a4paper,oneside,11pt]{book}
\usepackage[hmargin={3cm,2cm},vmargin={2cm,2cm}]{geometry}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage[labelsep=period]{caption}
\titlespacing{\chapter}{0cm}{-1.2cm}{0.7cm}
\titlespacing*{\section}
{0pt}{2ex plus 1ex minus .2ex}{2ex plus .2ex}
\titleformat{\section}
[hang]
{\bfseries}
{\bfseries\thesection}{1ex}{\bfseries}
\begin{document}
\chapter{Random Text}
\section{Section Name}
\lipsum[1]
\begingroup
\setcellgapes{5pt}
\makegapedcells
\begin{longtable}{|c|c|p{9cm}|}
\caption{Random text for caption here.}
\label{table1} \\
\hline
\textbf{Head1}&\multicolumn{2}{c|}{\textbf{Head2}} \\
\hline
\endfirsthead
\caption[]{Random text for caption here. (Continue)} \\
\hline
\textbf{Head1}&\multicolumn{2}{c|}{\textbf{Head2}} \\
\hline
\endhead
\multicolumn{3}{r @{}}{\small\emph{continue on the next page}} \\*
\endfoot
\hline
\endlastfoot
%%%% table nody
1&Text2&Long text here.\\
\cline{2-3}
&Text2&\lipsum[4]\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\hline
\newpage
2&Text2&Long text here.\\
\cline{2-3}
&Text2&\lipsum[4]\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\cline{2-3}
&Text2&Long text here.\\
\hline
\end{longtable}
\endgroup
\section{Section Name 2}
\lipsum[2]
\end{document}