tabularx 环境中的列宽

tabularx 环境中的列宽

我有这张表:

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularx,booktabs,newtxmath} 
\newcolumntype{Z}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table*}
\caption{Scenario descriptions}\label{tab3}
\begin{tabularx}{\linewidth}{>{\hsize=.3\hsize\linewidth=\hsize } Z *{9}{Z} @{}}
\toprule
& \multicolumn{3}{c@{}}{Anomaly triggering} & \multicolumn{3}{c@{}}{Anomaly description} \\
\cmidrule(l){2-4}\cmidrule(l){5-7}
\addlinespace
Scenario & Condition & Begin & End & Type & Target & Impacted security criteria \\
\midrule
\addlinespace
1  & 1 & 2 & 3 & 4 & blablablablabla blab lablabl ablablabla ablablabla & 6\\
\addlinespace
2 & 1 & 2 & 3 & 4 & 5 & 6\\
\addlinespace
3 & 1 & 2 & 3 & 4 & 5 & 6  \\
\addlinespace
4 & 1 & 2 & 3 & 4 & 5 & 6 \\
\bottomrule
\end{tabularx}
\end{table*}

\end{document}

我想调整“目标”列,因为其中有较长的文本。我知道单个表中的 X 列设置为相同宽度,但我尝试强制调整第一列宽度,>{\hsize=.3\hsize\linewidth=\hsize } Z但其他列宽度不适应。

其他问题:您认为用这条线来调整“场景”会更好吗\cmidrule(l)

感谢您的帮助。

结果如下: 在此处输入图片描述

答案1

我会用tabular*

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularx,booktabs,newtxmath}

\begin{document}

\begin{table*}

\caption{Scenario descriptions}\label{tab3}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{7}{c} @{}}
\toprule
& \multicolumn{3}{c}{Anomaly triggering} & \multicolumn{3}{c@{}}{Anomaly description} \\
\cmidrule{2-4}\cmidrule{5-7}
\addlinespace
Scenario & Condition & Begin & End & Type & Target & Impacted security criteria \\
\midrule
\addlinespace
1  & 1 & 2 & 3 & 4 & \multicolumn{1}{p{3cm}}{\centering blablablablabla blab lablabl ablablabla ablablabla} & 6\\
\addlinespace
2 & 1 & 2 & 3 & 4 & 5 & 6\\
\addlinespace
3 & 1 & 2 & 3 & 4 & 5 & 6  \\
\addlinespace
4 & 1 & 2 & 3 & 4 & 5 & 6 \\
\bottomrule
\end{tabular*}

\end{table*}

\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularx,booktabs,newtxmath,lipsum} 
\newcolumntype{Z}{>{\centering\arraybackslash}X}

\begin{document}
    
    \begin{table*}
        \caption{Scenario descriptions}\label{tab3}
        \begin{tabularx}{\linewidth}{  *{5}{c}Zc}
            \toprule
            & \multicolumn{3}{c@{}}{Anomaly triggering} & \multicolumn{3}{c@{}}{Anomaly description} \\
            \cmidrule(l){2-4}\cmidrule(l){5-7}\cmidrule{1-1}
            \addlinespace
            Scenario & Condition & Begin & End & Type & Target & Impacted security criteria \\
            \midrule
            \addlinespace
            1  & 1 & 2 & 3 & 4 & \raggedright\lipsum[1] & 6\\
            \addlinespace
            2 & 1 & 2 & 3 & 4 & 5 & 6\\
            \addlinespace
            3 & 1 & 2 & 3 & 4 & 5 & 6  \\
            \addlinespace
            4 & 1 & 2 & 3 & 4 & 5 & 6 \\
            \bottomrule
        \end{tabularx}
    \end{table*}
    
\end{document}

相关内容