长表内的各表的列宽相同

长表内的各表的列宽相同

我使用了许多占据数页的长表。这些长表里面的表格有 1、2 或 3 列,所有表格的宽度相同:p{2cm}、p{2cm} 和 p{9.5cm}。

我已经尝试了一段时间,但我无法使它们的宽度相同,长表内的每个表都显示不同的宽度。一个简短的例子是:

\documentclass[a4paper,12pt] {book}
\usepackage{expl3}
\usepackage{booktabs,longtable,rotating} 
\usepackage{multirow} 
\usepackage{calc}

\begin{document} 

\newcommand{\subTableOne}[8]{%
\begin{tabular}{ @{\extracolsep{\fill}} | p{2cm - 2\tabcolsep - 1.25\arrayrulewidth}  |  p{2cm - 2\tabcolsep - 1.25\arrayrulewidth} |  p{9.5cm - 2\tabcolsep - 1.25\arrayrulewidth} | @{}}
\hline
  \multicolumn{3}{| p{13.5cm} |}{ }\\
  \multicolumn{3}{| c |}{ #1 }\\
  \multicolumn{3}{| c |}{ }\\
\hline
  Name: & \multicolumn{2}{ c |}{ #2 } \\
  Description: & \multicolumn{2}{ c |}{ #3 } \\
\hline
\hline
  \multicolumn{3}{| c |}{\multirow{2}{*} { Some title } } \\
  \multicolumn{3}{| c |}{ } \\
\hline
  \parbox[t]{2mm}{\multirow{2}{*}{\parbox{2cm}{Some \\ part:}}} & Type: & #3 \\
  \cline{2-3}
  & Size: & #4  \\
  \hline

  \parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{90}{\parbox{2cm}{Other \\ part:}}}} & Domain: & #5 \\
  \cline{2-3}
  & Size: & #6 \\
  \cline{2-3}
  & Distribution: & #7  \\

\hline
\end{tabular}%
}

\ExplSyntaxOn
\newcommand{\subSubtableInt}[1]{ % elems
\clist_map_inline:nn { #1 } { & \multicolumn{2}{ p{13.5cm - 4\tabcolsep - 2.5\arrayrulewidth} |}{ ##1} \\  }
}
\ExplSyntaxOff

\ExplSyntaxOn
\newcommand{\subSubtable}[3]{
\hline
\parbox[t]{2mm}{\multirow{\clist_count:n {#3}}{*}{\rotatebox[origin=c]{90}{\parbox{2cm}{#1}}}} & \multicolumn{2}{ p{13.5cm - 4\tabcolsep - 2.5\arrayrulewidth} |}{ #2 } \\
\subSubtableInt{#3}
& \multicolumn{2}{ p{13.5cm - 4\tabcolsep - 2.5\arrayrulewidth} |}{   } \\
}
\ExplSyntaxOff

\newcommand{\subTableTwo}[8]{%
\begin{tabular}{ @{\extracolsep{\fill}} | p{2cm - 2\tabcolsep - 1.25\arrayrulewidth}  |  p{2cm - 2\tabcolsep - 1.25\arrayrulewidth} |  p{9.5cm - 2\tabcolsep - 1.25\arrayrulewidth} | @{}}
\hline
  \multicolumn{3}{| c |}{\multirow{2}{*}{ Another title } } \\
  \multicolumn{3}{| c |}{ } \\

\hline
  Cat.1: & \multicolumn{2}{ p{11.5cm - 4\tabcolsep - 2.5\arrayrulewidth} |}{ #1 } \\

\hline
  Cat.2: & \multicolumn{2}{ p{11.5cm - 4\tabcolsep - 2.5\arrayrulewidth} |}{ #2 } \\

\subSubtable{Sub.1}{#3}{#4}
\subSubtable{Sub.2}{#5}{#6}
\subSubtable{Sub.3}{#7}{#8}

\hline
\end{tabular}%
 }

\setlength\tabcolsep{1.5pt} % default value: 6pt

\begin{longtable}{@{\extracolsep{\fill}}l@{}} %{@{}l@{}}

\caption{Longtable with subtables.} \\

\subTableOne{Main title}{the name}{a description}{category of the problem}{problem size}{detailed description}{estimation of size}{distribution} \\

\subTableTwo{comment}{another comment}{\# 1}{\# 2, \# 3, \ldots}{\# 1}{\# 2, \# 3, \# 4, \ldots}{\# 1}{\# 2, \# 3, \# 4, \ldots} \\

\label{tab:test1}

\end{longtable}


\end{document} 

渲染结果如下:

乳胶结果

知道如何正确地做到这一点吗?

相关内容