我制作了一张表格,希望得到您的反馈和可能的改进(我是表格使用的初学者)。
这是我的代码:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{multirow}
\usepackage{tabularx,booktabs,newtxmath}
\newcolumntype{Z}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table*}[bt]
\caption{Scenario results}\label{tab4}
\begin{tabularx}{\linewidth}{ @{} c *{10}{Z} @{}}
\toprule
& \multicolumn{3}{c@{}}{Anomaly 1} & \multicolumn{3}{c@{}}{Anomaly 2} & \multicolumn{3}{c@{}}{Anomaly 3} & Anomaly anticipation\\
\cmidrule(l){2-4}\cmidrule(l){5-7}\cmidrule(l){8-10}\cmidrule(l){11-11}
Scenario & Detection & Propagation on system variables & Pump impact rates & Detection & Propagation on system variables & Pump impact rates & Detection & Propagation on system variables & Pump impact rates & $\Delta t$\\
\midrule
\addlinespace
%Scenario 1
\multirow{2}{*}{1} & $ed_{coh}$=$true$ & \multirow{2}{*}{$s_{2}$$\rightarrow$$f_{2}$$\rightarrow$$l_{1}$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}PU1(65.6\%)\\ PU2(65.6\%)\end{tabular}}& $ed_{coh}$=$true$ & \multirow{2}{*}{$s_{1}$$\rightarrow$$f_{1}$$\rightarrow$$l_{1}$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}PU1(65.6\%)\\ PU2(65.6\%)\end{tabular}} & $cd_{err}$=$true$ & \multirow{2}{*}{$l_{1}$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}PU1(68.8\%) \\ T1(68.8\%)\end{tabular}}& \multirow{2}{*}{\textbf{22,6h}} \\
& t=57h & & & t=79h & & & t=79,6h \\
\addlinespace
%Scenario 2
\multirow{2}{*}{2} & $cd_{err}$=$true$ & \multirow{2}{*}{$l_{7}$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}PU10(68.8\%)\\ PU11(68.8\%)\end{tabular}}& n/a & \multirow{2}{*}{n/a} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}n/a\\n/a\end{tabular}} & n/a & \multirow{2}{*}{n/a} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}n/a\\ n/a\end{tabular}}& \multirow{2}{*}{n/a} \\
& t=30h & & & n/a & & & n/a \\
\addlinespace
%Scenario 3
\multirow{2}{*}{3} & $ed_{coh}$=$true$ & \multirow{2}{*}{$s_{4}$$\rightarrow$$f_{4}$$\rightarrow$$l_{3}$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}PU4(65.6\%)\\PU5(65.6\%)\end{tabular}}& $ed_{coh}$=$true$ & \multirow{2}{*}{$s_{5}$$\rightarrow$$f_{5}$$\rightarrow$$l_{3}$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}PU4(65.6\%)\\PU5(65.6\%)\end{tabular}} & $cd_{err}$=$true$ & \multirow{2}{*}{$l_{3}$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}PU4(68.8\%)\\PU5(68.8\%)\end{tabular}} & \multirow{2}{*}{\textbf{9,8h}} \\
& t=3,9h & & & t=11,3h & & & t=13,7h \\
\addlinespace
%Scenario 4
\multirow{2}{*}{4} & n/a & \multirow{2}{*}{n/a} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}n/a\end{tabular}}& n/a & \multirow{2}{*}{n/a} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}n/a\end{tabular}} & n/a & \multirow{2}{*}{n/a} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}n/a\end{tabular}}
& \multirow{2}{*}{n/a} \\
& n/a & & & n/a & & & n/a \\
\bottomrule
\end{tabularx}
\end{table*}
\end{document}
也许将文本置于第一行和第二行的中央会更好?
感谢您的帮助。
答案1
我不会用\multirow
在任何情况下
我正确地分离了数学,并让 TeX 进行列间空间计算;如果你注意到,我将 PIR 列分成两列,以便更好地对齐。
此外,siunitx
始终使用 来确保小数点标记的一致使用。如果删除output-decimal-marker={,}
,您将在任何地方都获得小数点(独立于输入)。
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{newtxtext,newtxmath}
\usepackage{multirow}
\usepackage{booktabs,siunitx}
\sisetup{detect-all,output-decimal-marker={,}}
\begin{document}
\begin{table*}[bt]
\newcommand{\mr}[1]{\multirow{2}{*}{#1}}
%\newcommand{\mr}[1]{#1}
\newcommand{\mc}[1]{\multicolumn{2}{c}{#1}}
\newcommand{\ts}[1]{\textsubscript{#1}}
\newcommand{\edcoh}{\mathrm{ed}_{\mathrm{coh}}}
\newcommand{\cderr}{\mathrm{cd}_{\mathrm{err}}}
\newcommand{\true}{\mathrm{true}}
\setlength{\tabcolsep}{0pt}
\caption{Scenario results}\label{tab4}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
c
*{3}{ c c l @{\extracolsep{0pt}\ } r @{\extracolsep{\fill}} }
c
@{}
}
\toprule
Scenario &
\multicolumn{4}{c}{Anomaly 1} &
\multicolumn{4}{c}{Anomaly 2} &
\multicolumn{4}{c}{Anomaly 3} &
AA \\
\cmidrule{2-5}
\cmidrule{6-9}
\cmidrule{10-13}
\cmidrule{14-14}
& Detection & PSV & \mc{PIR}
& Detection & PSV & \mc{PIR}
& Detection & PSV & \mc{PIR}
& $\Delta t$ \\
\midrule
\addlinespace
%Scenario 1
\mr{1} & $\edcoh=\true$ & \mr{$s_{2}\to f_{2}\to l_{1}$} & PU1 & (\num{65.6}\%)
& $\edcoh=\true$ & \mr{$s_{1}\to f_{1}\to l_{1}$} & PU1 & (\num{65.6}\%)
& $\cderr=\true$ & \mr{$l_{1}$} & PU1 & (\num{68.8}\%)
& \mr{\bfseries\SI{22,6}{\hour}} \\
& $t=\SI{57}{\hour}$ & & PU2 & (\num{65.6}\%)
& $t=\SI{79}{\hour}$ & & PU2 & (\num{65.6}\%)
& $t=\SI{79,6}{\hour}$ & & T1 & (\num{68.8}\%) \\
\addlinespace
%Scenario 2
\mr{2} & $\cderr=\true$ & \mr{$l_{7}$} & PU10 & (\num{68.8}\%)
& n/a & \mr{n/a} & \mc{n/a}
& n/a & \mr{n/a} & \mc{n/a} & \mr{n/a} \\
& $t=\SI{30}{\hour}$ & & PU11 & (\num{68.8}\%) & n/a & & \mc{n/a} & n/a & & \mc{n/a} \\
\addlinespace
%Scenario 3
\mr{3} & $\edcoh=\true$ & \mr{$s_{4}\to f_{4}\to l_{3}$} & PU4 & (\num{65.6}\%)
& $\edcoh=\true$ & \mr{$s_{5}\to f_{5}\to l_{3}$} & PU4 & (\num{65.6}\%)
& $\cderr=\true$ & \mr{$l_{3}$} & PU4 & (\num{68.8}\%)
& \mr{\bfseries\SI{9,8}{\hour}} \\
& $t=\SI{3,9}{\hour}$ & & PU5 & (\num{65.6}\%)
& $t=\SI{11,3}{\hour}$ & & PU5 & (\num{65.6}\%)
& $t=\SI{13,7}{\hour}$ & & PU5 & (\num{68.8}\%) \\
\addlinespace
%Scenario 4
\mr{4} & n/a & \mr{n/a} & \mc{\mr{n/a}}
& n/a & \mr{n/a} & \mc{\mr{n/a}}
& n/a & \mr{n/a} & \mc{\mr{n/a}}
& \mr{n/a} \\
& n/a & & & & n/a & & & & n/a \\
\midrule[\heavyrulewidth]
\multicolumn{14}{l}{PSV: Propagation on system variables; PIR: Pump impact rates;
AA: Anomaly anticipation}
\end{tabular*}
\end{table*}
\end{document}
环境中定义的临时命令table*
不仅仅是一个缩写。如果我\mr
将的定义改为
\newcommand{\mr}[1]{#1}
输出变为
这证实了我的观点:每个表的使用\multirow
都可以通过不删除它来改进。;-)
答案2
这是一个略有不同的方法,它基于siunitx
数字,使用较少单位的\multiow
命令,没有嵌套的表格,tabular*
而是tabularx
:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{multirow}
\usepackage{booktabs,newtxmath}
\usepackage{makecell}
\usepackage[detect-weight]{siunitx}
\sisetup{output-decimal-marker = {,}}
\begin{document}
\begin{table*}[bt]
\setlength{\tabcolsep}{0pt}
\caption{Scenario results}\label{tab4}
\begin{tabular*}{\linewidth}{ @{\extracolsep{\fill}} c *{3}{ccl}c}
\toprule
& \multicolumn{3}{c@{}}{Anomaly 1} & \multicolumn{3}{c@{}}{Anomaly 2} & \multicolumn{3}{c@{}}{Anomaly 3} & Anticipation\\
\cmidrule(l){2-4}\cmidrule(l){5-7}\cmidrule(l){8-10}\cmidrule(l){11-11}
Scenario & Detection & PSV & \makecell{PIR} & Detection & PSV & \makecell{PIR} & Detection & PSV & \makecell{PIR} & $\Delta t$\\
\midrule
\addlinespace
%Scenario 1
\multirow{2}{*}{1}
& $ed_{coh}=\text{true}$
& \multirow{2}{*}{$s_{2} \rightarrow f_{2} \rightarrow l_{1}$}
& PU1 (65.6\%)
& $ed_{coh}=\text{true}$
& \multirow{2}{*}{$s_{1} \rightarrow f_{1}\rightarrow l_{1}$}
& PU1 (65.6\%)
& $cd_{err}=\text{true}$
& \multirow{2}{*}{$l_{1}$}
& PU1 (68.8\%)
& \multirow{2}{*}{\bfseries\SI{22,6}{\hour}} \\
& t = \SI{57}{\hour}
&
& PU2 (65.6\%)
& t = \SI{79}{\hour}
&
& PU2 (65.6\%)
& t = \SI{79,6}{\hour}
&
& T1 (68.8\%)\\
\bottomrule
\multicolumn{11}{l}{PSV = Propagation on system variables; PIR = Pump impact rates}
\end{tabular*}
\end{table*}
\end{document}