我的表格将一行的条目放在表格边框之外

我的表格将一行的条目放在表格边框之外

这是我在这里的第一个问题。我彻底搜索了,使用了诸如“latex 表格数据超出边界”之类的搜索词及其许多排列组合,但没有成功。我有一张\multicolumn表格,表格中的一行在表格外面浮动,位于“下页继续”行下方。以下是表格的代码以及相关行:

\usepackage{hyperref}
\usepackage{pdfpages}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{longtable}

\title{SOP X}
\doctype{SOP}
\docnumber{XX-XXXXX}
\supercedes{None}
\effectivedate{09/26/16}
\revisiondate{09/26/16}

\begin{document}
\setcounter{tocdepth}{3}
\tableofcontents

\section{Purpose}
\begin{longtable}{|p{5cm}|p{.25cm}|p{.25cm}|p{10.5cm}|}
\caption{Title of Table} \label{t:title_of_table}
\endfirsthead

\multicolumn{4}{c} {{\bfseries \tablename\ \thetable{} -- Continued from Previous Page }} \\ \hline 
\endhead

\hline \multicolumn{4}{|r|}{Continued on Next Page} \\ \hline
\endfoot

\hline \hline
\endlastfoot 

\hline \fancyhead{}

\multirow{7}{\linewidth}{This Floats Outside the Table; Shd Be the 1st Column}  & \multirow{7}{\linewidth}{J} & 1 & This is in the 4th column; it shows up in the last row of the previous page, but the "This Floats Outside the Table" cell and the "{J}" cell make a second row, floating outside the page underneath the table \\ \cline{3-4}
                   &                   & 2 & This is OK, it shows up in the next page in the right column, where it should \\ \cline{3-4}
                   &                   & 3 & This is OK too \\ \cline{3-4}
                   &                   & 4 & This is OK too \\ \cline{3-4}
                   &                   & 5 & This is OK too \\ \cline{3-4}
                   &                   & 6 & This is OK too \\ \cline{3-4}
                   &                   & 7 & etc. \\ \hline
 \end{document}

答案1

longtable您可以使用\\*而不是将一组行放在一起\\。 的星号形式\\结束表格而不允许分页。

例子:

\documentclass{article}
\usepackage[
  hmargin=2cm,
]{geometry}
\usepackage{longtable}
\usepackage{multirow}

\begin{document}
\vspace*{.85\textheight}

\begin{longtable}{|p{5cm}|p{.25cm}|p{.25cm}|p{10.5cm}|}

\caption{Title of Table} \label{t:title_of_table}

\endfirsthead

\multicolumn{4}{c} {{\bfseries \tablename\ \thetable{} -- Continued from Previous Page }} \\ \hline 

\endhead

\hline \multicolumn{4}{|r|}{Continued on Next Page} \\* \hline
\endfoot

\hline \hline
\endlastfoot 

\hline


\multirow{7}{\linewidth}{This Floats Outside the Table; Shd Be the 1st Column}  & \multirow{7}{\linewidth}{J} & 1 & This is in the 4th column; it shows up in the last row of the previous page, but the "This Floats Outside the Table" cell and the "{J}" cell make a second row, floating outside the page underneath the table \\* \cline{3-4}

                   &                   & 2 & This is OK, it shows up in the next page in the right column, where it should \\ \cline{3-4}
                   &                   & 3 & This is OK too \\* \cline{3-4}
                   &                   & 4 & This is OK too \\* \cline{3-4}
                   &                   & 5 & This is OK too \\* \cline{3-4}
                   &                   & 6 & This is OK too \\* \cline{3-4}
                   &                   & 7 & etc. \\ \hline

\end{longtable}
\end{document}

现在行组转到第二页。

当然,大量的表格行或较大的行会使 TeX 很难找到好的断点。

相关内容