这是我的代码:
\documentclass[11pt,twoside]{report}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{array}
\begin{document}
\begin{table}[H]
\begin{tabular}{|l|lll|llll|l|}
\hline
\multirow{}{}{Algorithm Name} & \multicolumn{3}{l|}{Statistical properties} & \multicolumn{4}{l|}{Algorithm's features} & \multirow{2}{*}{Notes} \\ \cline{2-8}
& \multicolumn{1}{l|}{Average} & \multicolumn{1}{l|}{Variance} & Covariance & \multicolumn{1}{l|}{Non-Blind} & \multicolumn{1}{l|}{Noise robustness} & \multicolumn{1}{l|}{Linear algorithm} & CDW & \\ \hline
Algorithm1: Simple algorithm & \multicolumn{1}{l|}{T} & \multicolumn{1}{l|}{F} & F & \multicolumn{1}{l|}{T} & \multicolumn{1}{l|}{F} & \multicolumn{1}{l|}{T} & F & Illustrative purposes only \\ \hline
Algorithm2: Sebe 2005 {[}29{]} & \multicolumn{1}{l|}{T} & \multicolumn{1}{l|}{T} & F & \multicolumn{1}{l|}{F} & \multicolumn{1}{l|}{T} & \multicolumn{1}{l|}{F} & T & None \\ \hline
Algorithm3: Sebe 2006 {[}30{]} & \multicolumn{1}{l|}{T} & \multicolumn{1}{l|}{T} & T & \multicolumn{1}{l|}{F} & \multicolumn{1}{l|}{T} & \multicolumn{1}{l|}{F} & T & Future work \\ \hline
\end{tabular}
\end{table}
\end{document}
非常感谢您的帮助!
答案1
对于您的问题,存在许多解决方案,例如使用p<width>
列、使用包X
中定义的列tabularx
等。对于您的情况,tabularray
包可能很方便。无论如何,您的列标题非常宽,即使它们写在两列中。补救措施是使文本区域稍微宽一些(通过使用包geometry
)并使用\footnotesize
字体:
\documentclass[11pt,twoside]{report}
%\usepackage{a4wide}
\usepackage[margin=25mm]{geometry}
\usepackage{tabularray}
\begin{document}
\begin{table}[ht]
\footnotesize
\begin{tblr}{hlines, vlines,
colspec= { X[1.4,l,m] *{7}{X[c,m]} X[c, m]},
colsep = 3pt,
row{1} = {font=\bfseries}
}
\SetCell[r=2]{m} {Algorithm\\ Name}
& \SetCell[c=3]{c} {Statistical properties}
& & & \SetCell[c=4]{c} {Algorithm's features}
& & & & \SetCell[r=2]{m} Notes \\
& Average
& Variance
& Co\-variance
& {Non-\\ Blind}
& Noise robustness
& Linear algorithm
& CDW
& \\
{Algorithm 1:\\ Simple algorithm}
& T & F & F & T & F & T & F & Illustrative purposes only \\
Algorithm 2: Sebe 2005 [29]
& T & T & F & F & T & F & T & None \\
Algorithm 3: Sebe 2006 {[}30{]}
& T & T & T & F & T & F & T & Future work \\
\end{tblr}
\end{table}
\end{document}
如果由于某种原因您没有使用更宽的表格,\textwidth
那么您可以借助包仅在本地使表格变宽changepage
。
答案2
您需要允许表格中的大部分列自动换行。这可以通过从 a 环境切换tabular
到 atabularx
环境并X
在需要时使用 -type 列来实现。我还想鼓励您通过 (a) 删除所有垂直规则和 (b) 使用包的宏来让表格看起来更加开放,这样 (a) 可以摆脱所有垂直规则,(b) 使用更少但间距适当的水平规则booktabs
。
\documentclass[11pt,twoside]{report}
\usepackage[a4paper,margin=2cm]{geometry} % set page parameters as needed
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X}
\newcolumntype{C}{>{\Centering\hspace{0pt}}X}
\begin{document}
\begin{table}[ht]
\setlength\tabcolsep{2pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{} L CCC CCCc L @{}}
\toprule
Algorithm Name & \multicolumn{3}{c}{Statistical properties}
& \multicolumn{4}{c}{Algorithm's features} & Notes \\
\cmidrule(lr){2-4} \cmidrule(l){5-8}
& Average & Variance & Covariance & Non-Blind & Noise robustness & Linear algorithm & CDW & \\
\midrule
Alg1: Simple algorithm & T & F & F & T & F & T & F & Illustrative purposes only \\
\addlinespace
Alg2: Sebe 2005 [29] & T & T & F & F & T & F & T & None \\
\addlinespace
Alg3: Sebe 2006 [30] & T & T & T & F & T & F & T & Future work \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}