我有这个脚本:
\documentclass[letterpaper,twocolumn,10pt]{article}
\usepackage{graphicx}
\usepackage{array,tabularx}
\usepackage{multirow,booktabs} %
\usepackage{pifont}%
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{array,tabularx}
\begin{document}
\begin{table}[h]\centering
\begin{tabular}{lccccc}
\toprule
\multicolumn{2}{c}{SSS } & \multicolumn{3}{c}{HHH} \\
\cmidrule(lr){1-2} \cmidrule(r){3-5}
& & TTT \\
\cmidrule(lr){1-2} \cmidrule(lr){3-5}
AAA & BBB & CCC & DDD \\
\midrule
1 & 2 & 3 & 4 & 5 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
输出为:
我还想将第二行和第三行的水平线的颜色设为灰色。你能帮忙吗?
答案1
像那样?
\documentclass[letterpaper,twocolumn,10pt]{article}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{colortbl}
\begin{document}
\begin{table}[h]\centering
\begin{tabular}{lccccc}
\toprule
\arrayrulecolor{gray}
\multicolumn{2}{c}{SSS} & \multicolumn{3}{c}{HHH} \\
\cmidrule(lr){1-2} \cmidrule(r){3-5}
\multicolumn{2}{c}{} & \multicolumn{3}{c}{TTT} \\
\cmidrule(lr){3-5}
\arrayrulecolor{black}
AAA & BBB & CCC & DDD \\
\midrule
1 & 2 & 3 & 4 & 5 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
我还将示例清理到最低限度。此外,您加载array
两次tabularx
。