我正在尝试在多行环境中编写表格。但是,我的条目没有正确对齐。代码粘贴在下面。输出的屏幕截图已附上。有人能帮我解决这个问题吗?非常感谢。
\documentclass[sigconf, authordraft]{acmart}
\usepackage{booktabs} % For formal tables
\usepackage{multirow}
%\usepackage{mathptmx}
\usepackage{amsmath} % assumes amsmath package installed
\usepackage{amssymb} % assumes amsmath package installed
\begin{document}
\begin{table*}
\caption{Quality Metrics which require reference image}
\label{tab:table1}
\begin{tabular}{cccccccccl}
Sl.No.&Metric&Band&DWT -rule 1&DWT -rule 2&DWT -rule 3&DWT-rule 4&PCA&GIHS&GIHS-Choi \\ \hline
% \midrule
\multirow{4}{*}{1} &\multirow{4}{*}{Rel Bias} & Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
\multirow{4}{*}{2} &\multirow{4}{*}{ Rel VAR} & Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
\multirow{4}{*}{3} &\multirow{4}{*}{ Rel SDD} & Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi\\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
% \bottomrule
\end{tabular}
\end{table*}
\end{document}
答案1
缺少第二行(&
需要两行),因此内容对齐不正确。
*
我在命令的第二个参数中添加了\multirow
并更正了表格行的结尾(\\
)。
所结果的平均能量损失(请注意,它是最小的,我已经减少了它):
\documentclass[sigconf, authordraft]{acmart}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{table}
\centering
\caption{Quality Metrics which require reference image}
\label{tab:table1}
\begin{tabular}{cccccccccl}
Sl.No. & Metric & Band & DWT -rule 1 & DWT -rule 2 & DWT -rule 3 & DWT-rule 4 & PCA & GIHS & GIHS-Choi \\
\midrule
\multirow{4}{*}{1} & \multirow{4}{*}{Rel Bias} & Green & DWT-rule1 & DWT-rule2 & DWT-rule3 & DWT-rule4 & PCA & GIHS & GIHS-Choi \\
& & Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& & Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
& & Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
&
除了在数据行 2-4、6-8 和 10-12 中插入缺失符号外,您可能还想重新考虑表格的布局。例如,不要使用\multirow
特殊方式处理前两列的内容,只需删除\multirow
包装器并在第 4 行和第 8 行后添加一些垂直空白(通过\addlinespace
说明)。此外,考虑到表格几乎占据了文本块的整个宽度,为什么不“将其正式化”并使用确实tabular*
占用全部可用空间的环境呢?
\documentclass[sigconf, authordraft]{acmart}
\usepackage{booktabs}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{table*}
\setlength\tabcolsep{0pt}
\caption{Quality Metrics which require reference image}
\label{tab:table1}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{10}{l} }
% \toprule
Sl.No. & Metric & Band & DWT-rule 1 & DWT-rule 2 &
DWT-rule 3 & DWT-rule 4 & PCA & GIHS & GIHS-Choi \\
\midrule
1 & Rel Bias
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
\addlinespace
2 & Rel VAR
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
\addlinespace
3 & Rel SDD
& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi\\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
&& Green& DWT-rule1 & DWT-rule2& DWT-rule3 & DWT-rule4& PCA&GIHS&GIHS-Choi \\
% \bottomrule
\end{tabular*}
\end{table*}
\end{document}