使用 xtabular 时防止多行标题拆分

使用 xtabular 时防止多行标题拆分

使用xtab包和xtabular环境,当使用多行时,我的表头会被分割。

例子:

\noindent
\begin{center}
\small
\tablefirsthead{%
    \hline
   & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\
   \cline{2-9} 
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\
  \hline
  \hline}
\tablehead{%
  \multicolumn{9}{l}{\small\sl continued from previous page} \\
  \hline
  & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\
  \cline{2-9} 
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\
  \hline
  \hline}
\tabletail{%
    \hline
    \multicolumn{9}{r}{\small\sl continued on next page}\\
}
\tablelasttail{\hline}
\topcaption{First Aggregation CFs table 1/2}
\label{first-aggregation-1}
\begin{xtabular}{|l||*{4}{l|}|*{4}{l|}}
    ClaConDef & 0.15 & 0.03 & 0.076 & 0.16 & - & - & - & - \\
    CovGenDev & - & - & - & - & - & - & - & - \\
    SupUmbAct & - & - & - & - & 0.125 & - &  0.15 & - \\
    SmoSeaTra & - & - & - & - & - & - & - & - \\
 \end{xtabular}
\end{center}

使用 pdflatex 渲染如下:

图像

标题的第二行不应重复,也不应与第一行分开。有什么建议吗?

添加

通过运行以下示例可以获得不良行为:

\documentclass{article}
\usepackage{xtab}
\begin{document}
\vspace*{\textheight}\vspace*{-10\baselineskip}
\begin{center}
\small
\tablefirsthead{%
    \hline
   & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\
   \cline{2-9}
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\
  \hline
  \hline}
\tablehead{%
  \multicolumn{9}{l}{\small\sl continued from previous page} \\
  \hline
  & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\
  \cline{2-9}
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\
  \hline
  \hline}
\tabletail{%
    \hline
    \multicolumn{9}{r}{\small\sl continued on next page}\\
}
\tablelasttail{\hline}
\topcaption{First Aggregation CFs table 1/2}
\label{first-aggregation-1}
\begin{xtabular}{|l||*{4}{l|}|*{4}{l|}}
    ClaConDef & 0.15 & 0.03 & 0.076 & 0.16 & - & - & - & - \\
    CovGenDev & - & - & - & - & - & - & - & - \\
    SupUmbAct & - & - & - & - & 0.125 & - &  0.15 & - \\
    SmoSeaTra & - & - & - & - & - & - & - & - \\
 \end{xtabular}
\end{center}
\end{document}

答案1

使用 longtable 的解决方案:

\documentclass{article}
\usepackage{longtable}
\begin{document}
\vspace*{\textheight}\vspace*{-8\baselineskip}

{\fontsize{8.5}{8.6}\selectfont\def\arraystretch{1.2}
\begin{longtable}{ |l||*4{l|}|*4{l|} }
\caption{First Aggregation CFs table 1/2}\label{first-aggregation-1}\\\hline
   & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\\cline{2-9}
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\\hline\hline
\endfirsthead
  \multicolumn{9}{l}{\small\sl continued from previous page} \\\hline
  & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\\cline{2-9}
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\\hline\hline
\endhead
\hline
\multicolumn{9}{r}{\small\sl continued on next page}\\
\endfoot
\hline
\endlastfoot
    ClaConDef & 0.15 & 0.03 & 0.076 & 0.16 & - & - & - & - \\
    CovGenDev & - & - & - & - & - & - & - & - \\
    SupUmbAct & - & - & - & - & 0.125 & - &  0.15 & - \\
    SmoSeaTra & - & - & - & - & - & - & - & - \\
\end{longtable}%
}

foo
\end{document}

随包裹表列反而:

\documentclass{article}
\usepackage{ltablex}
\begin{document}
\vspace*{\textheight}\vspace*{-10\baselineskip}

\begin{tabularx}{\linewidth}{ |l||*4{l|}|*4{l|} }
\caption{First Aggregation CFs table 1/2}\label{first-aggregation-1}\\\hline
   & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\\cline{2-9}
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\\hline\hline
\endfirsthead
  \multicolumn{9}{l}{\small\sl continued from previous page} \\\hline
  & \multicolumn{4}{c||}{NoExtKnowSrc} & \multicolumn{4}{c|}{UserMngmt} \\\cline{2-9}
  & StSeCo & SeLoCo & SeAb & SeRe & StSeCo & SeLoCo & SeAb & SeRe \\\hline\hline
\endhead
\hline
\multicolumn{9}{r}{\small\sl continued on next page}\\
\endfoot
\hline
\endlastfoot
    ClaConDef & 0.15 & 0.03 & 0.076 & 0.16 & - & - & - & - \\
    CovGenDev & - & - & - & - & - & - & - & - \\
    SupUmbAct & - & - & - & - & 0.125 & - &  0.15 & - \\
    SmoSeaTra & - & - & - & - & - & - & - & - \\
 \end{tabularx}

\end{document}

在此处输入图片描述

在此处输入图片描述

但是,当不使用 X 列时,使用 tabularx 没有任何实际意义。

相关内容