下面是我的表格的 latex 代码。但表格对齐不正确。此外,我收到错误“额外的对齐标签已更改为 cr”。请帮助我。提前致谢。
\begin{table*}[th]
\begin{scriptsize}
\caption{Experimental Results}
\vspace*{-2mm}
\begin{center}
\resizebox{\linewidth}{!}{%
{\renewcommand{\arraystretch}{3.0}
%\scalebox{1}{
%\begin{tabular}{|c||c|c|c||c|c|c||c|c|c|}\hline
\begin{tabular}{|M{4.5cm}||c|c|c|c||c|c|c||c|c|c|}\hline
\multirow{ 4}{*}{\Huge Benchmark} & \multicolumn{4}{|c||}{\Huge Original} & \multicolumn{3}{c|}{\Huge Trojan Avoidance (case1) } & \multicolumn{3}{c|}{\Huge Trojan Detection (case 2)} \\
\cline{2-13}
& \multicolumn{2}{c|}{\huge Area(PEs)} & \multirow{2}{*}{} &\multirow{ 2}{*}{ \huge \# contexts} & \huge Area(PEs) & \multirow{2}{*}{\huge Energy Consumption} &\multirow{ 2}{*}{ \huge \# contexts} &\huge Area(PEs)& \multirow{2}{*}{\huge Energy Consumption} & \multirow{ 2}{*}{\huge \# contexts}\\ \cline{2-3}
& \multirow{2}{*}{\huge Maximum PE among } & \Huge Total area & & & & & & & & & & \\
& \huge all the contexts(MX) & & \Huge Energy Consumption& & & & & & & & & &
\hline
\Huge Ave8 &\Huge 10$(C_{19})$ &\Huge 107 & &\Huge 23 &\Huge 148 & &\Huge 64 &\Huge 192 & &\Huge 64 \\ \hline
\Huge FIR &\Huge 15$(C_{40})$ &\Huge 236 & &\Huge 46 &254 & &64 &307 & &64 \\ \hline
\Huge Sobel &\Huge 23$(C_{9})$ &\Huge 119 & &\Huge 17 &166 & &64 &211 & &64 \\ \hline
\Huge Bsort &\Huge 30$(C_{5})$ &\Huge 105 & &\Huge 11 &158 & &64 &211 & & 64 \\ \hline
\Huge Kasumi &\Huge 29$(C_{28})$ &\Huge 212 & &\Huge 33 &243 & &64 &288 & &64 \\ \hline
\Huge Interp. &\Huge 40$(C_{20})$ &\Huge 301 & &\Huge 28 &337 & &64 &382 & &64 \\ \hline
\hline
\Huge Avg. &180 & &26 & 218& &64 &265 & &64 \\ \hline
\end{tabular} }}
%\end{adjustbox}
\end{minipage}}
\end{center}
\label{table:results}
\end{scriptsize}
\end{table*}
答案1
我尝试用多种方式来清理您的代码。例如,删除所有显式大小指令,启用自动换行(通过使用环境tabularx
和居中版本的X
列类型),并消除一行中超过 11 列的情况。鉴于表格有 11 列,我建议您以横向模式呈现它,而不是将其做得足够小(并且可能难以阅读)以使其适合纵向模式。
还有更多改进空间。例如,标题字符串“所有上下文中的最大 PE (MX)”似乎没有必要冗长——而且它肯定比任何其他标题字符串都长得多。
\documentclass{article}
\usepackage{tabularx,rotating,ragged2e,caption}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\captionsetup{skip=0.5\baselineskip}
\begin{document}
\begin{sidewaystable}
\setlength\tabcolsep{3pt} % default value: 6pt
\caption{Experimental Results}
\label{table:results}
\begin{tabularx}{\textwidth}{|l||C|C|C|C||C|C|C||C|C|C|}
\hline
Benchmark
& \multicolumn{4}{>{\hsize=4\hsize}C||}{Original}
& \multicolumn{3}{>{\hsize=3\hsize}C||}{Trojan Avoidance (case~1) }
& \multicolumn{3}{>{\hsize=3\hsize}C|}{Trojan Detection (case~2)} \\
\cline{2-11}
& \multicolumn{2}{c|}{Area (PEs)}
& Energy Consumption & \#~contexts
& Area (PEs) & Energy Consumption & \#~contexts
& Area (PEs) & Energy Consumption & \#~contexts\\
\cline{2-3}
& Maximum PE among all the contexts (MX) & Total area
& & & & & & & & \\
\hline\hline
Ave8 &10$(C_{19})$ &107 & &23 &148 & &64 &192 & & 64 \\ \hline
FIR &15$(C_{40})$ &236 & &46 &254 & &64 &307 & &64 \\ \hline
Sobel &23$(C_{9})$ &119 & &17 &166 & &64 &211 & &64 \\ \hline
Bsort &30$(C_{5})$ &105 & &11 &158 & &64 &211 & & 64 \\ \hline
Kasumi &29$(C_{28})$ &212 & &33 &243 & &64 &288 & &64 \\ \hline
Interp. &40$(C_{20})$ &301 & &28 &337 & &64 &382 & &64 \\ \hline
\hline
Average &180 & &26 & 218& &64 &265 & &64 & \\
\hline
\end{tabularx}
\end{sidewaystable}
\end{document}