如何合并这两个表,使第一个表和第二个表之间没有间隙并连接\bottomrule
?我尝试将两个表添加到一个表格环境中,但失败了。另外,为什么第 7 组的列更宽?
\documentclass{article}
\begin{document}
\keepXColumns
\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{\linewidth}{c|*{6}{>{\centering\arraybackslash}X}}%1.175
\toprule
\addlinespace
\captionsetup{textfont=it, skip=0.25ex}
\caption{Number of dendrograms in each group for 1,000 Bootstrap samples}
\label{table:KS_1k_groups}\\
\midrule
& Group 1 & Group 2 & Group 3 & Group 4 & Group 5 & Group 6\\
\midrule
\midrule
Number of Dendrograms & 13 & 12 & 5 & 4 (x3) & 3 (x4) & 2 (x4) \\
Cophenetic correlation & - & - & - & - & - & \\
\bottomrule
\end{tabularx}
\keepXColumns
\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{\linewidth}{c*{7}{>{\centering\arraybackslash}X}}%1.175
\midrule
Group 7 & Group 8 & Group 9 & Group 10 & Group 11 & Group 12 & Group 13 & Group 14\\
\midrule
\midrule
- & - & - & - & - & - & - & -\\
- & - & - & - & - & - & - & -\\
\bottomrule
\end{tabularx}
\end{document}
答案1
第一个表有 7 列,而第二个表有 8 列。尝试将它们合并在一起并希望获得相同的输出可能会很复杂。最好将两个表分开,但使第二个表更靠近第一个表。从\cmidrule
第二个表的开头删除并\vspace{-1.5\baselineskip}
在第一个表之后插入。这样,您的两个表看起来就像是只有一个表。请注意,float
包也会将它们视为一个表,因为它们都包含在同一个表环境中。因此,无论您的文本是什么,这两个表都不会彼此分开。
组 7 列较宽,因为类型c
不是X
有关的:不用在序言>{ \arraybackslash \Centering }X
中反复输入,只需定义。现在您可以使用来引用居中内容的列。tabularx
\newcolumntype{C}{ >{\arraybackslash \Centering}X }
C
X
\documentclass{article}
\usepackage{multirow}
\usepackage{caption}
\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{C}{ >{ \arraybackslash \Centering } X }
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{ltablex}
\begin{document}
\keepXColumns
\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{\linewidth}{c|*{6}C}%1.175
\toprule
\addlinespace
\captionsetup{textfont=it, skip=0.25ex}
\caption{Number of dendrograms in each group for 1,000 Bootstrap samples}
\label{table:KS_1k_groups}
\\
\midrule
& Group 1 & Group 2 & Group 3 & Group 4 & Group 5 & Group 6
\\
\midrule
\midrule
Number of Dendrograms & 13 & 12 & 5 & 4 (x3) & 3 (x4) & 2 (x4)
\\
Cophenetic correlation & - & - & - & - & - &
\\
\bottomrule
\end{tabularx}
\vspace{-1.5\baselineskip}
\keepXColumns
\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{\linewidth}{*{8}C}%1.175
Group 7 & Group 8 & Group 9 & Group 10 & Group 11 & Group 12 & Group 13 & Group 14
\\
\midrule
\midrule
- & - & - & - & - & - & - & -
\\
- & - & - & - & - & - & - & -
\\
\bottomrule
\end{tabularx}
\end{document}