表格中部分行禁止分页

表格中部分行禁止分页

我使用longtable包。它的允许命令\\*,用于禁止行分页。以下是代码,其中\\*不禁止分页。(第 44 行)生成的 pdf 如下:http://web-engineering.com.ua/mtest.pdf 这可能是因为使用了多行包吗?请帮忙。

    \documentclass[a4paper,oneside]{book}
    \usepackage{ltablex}
    \usepackage{calc}
    \usepackage{multirow}

    \newdimen{\newtblsparewidth}
    \newdimen{\newtblstarfactor}

    \begin{document}
    \vbox to 450pt{}
    \setlength{\newtblsparewidth}{\linewidth-2\tabcolsep-2\tabcolsep-2\tabcolsep-2\tabcolsep-2\tabcolsep}
    \setlength{\newtblstarfactor}{\newtblsparewidth / \real{4}}
    \begin{tabularx}{\linewidth}{l|l|l|X|}

\hline\noalign{\vskip-\arrayrulewidth}\endhead
\noalign{\vskip-\arrayrulewidth}\hline\endfoot

\multicolumn{1}{|m{0.13\newtblsparewidth}}{\multirow{3}{0.13\newtblsparewidth}{\textbf{/imp1}}} & 
\multicolumn{3}
  {|m{0.35\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.15\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.37\newtblsparewidth}|}
    {This  command imports viewer’s settings from the file specified by  setting\_file\_name parameter. Please note, all your current settings will  be overridden and lost.} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \hline

% ----

\multicolumn{1}{|m{0.13\newtblsparewidth}}{\multirow{3}{0.13\newtblsparewidth}{\textbf{/imp2}}} & 
\multicolumn{3}
  {|m{0.35\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.15\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.37\newtblsparewidth}|}
    {This  command imports viewer’s settings from the file specified by  setting\_file\_name parameter. Please note, all your current settings will  be overridden and lost.} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\* \hline

% ---

\multicolumn{1}{|m{0.13\newtblsparewidth}}{\multirow{3}{0.13\newtblsparewidth}{\textbf{/imp3}}} & 
\multicolumn{3}
  {|m{0.35\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.15\newtblsparewidth+2\tabcolsep+\arrayrulewidth+0.37\newtblsparewidth}|}
    {This  command imports viewer’s settings from the file specified by  setting\_file\_name parameter. Please note, all your current settings will  be overridden and lost.} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\multicolumn{1}{|l}{} & \multicolumn{1}{|m{0.35\newtblsparewidth}}{pagemode} & 
\multicolumn{1}{|m{0.15\newtblsparewidth}}{} & 
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\ \cline{2-4}

\end{tabularx}
\end{document}

答案1

在你的序言中写入:

\makeatletter
\newcommand\nobreakhline{%
\multispan\LT@cols
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\\*}
\newcommand\nobreakcline[1]{\@nobreakcline#1\@nil}%
\def\@nobreakcline#1-#2\@nil{%
  \omit
  \@multicnt#1%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#2%
  \advance\@multicnt-#1%
  \advance\@multispan\@ne
  \leaders\hrule\@height\arrayrulewidth\hfill\\*
  \noalign{\vskip-\arrayrulewidth}}
\makeatother

然后使用

[...]
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\*\nobreakhline
[...]

或者

[...]
\multicolumn{1}{|m{0.37\newtblsparewidth}|}{} \\*\nobreakcline
[...]

问题是\hline。没有它的 A\\*就可以工作。

相关内容