我带着更多表格问题回来了!
我正在尝试将下表的顶行居中(即标有“居中”的行)。我在 tex 上尝试过几种解决方案,但似乎都无法解决问题。
\documentclass[format=acmsmall, anonymous=true]{acmart}
\usepackage{array,tabularx,ragged2e,booktabs}
\begin{table}
\centering
\begin{tabularx}{\linewidth}{lrlr}
\hline
\rowcolor[HTML]{EFEFEF}
\multicolumn{4}{X}{\cellcolor[HTML]{EFEFEF}
\textbf{Center This}} \\ \hline
\textit{\textbf{}} & \textit{\textbf{\#}} & \textit{\textbf{}} & \textit{\textbf{\#}} \\ \hline
\rowcolor[HTML]{EFEFEF}
\textit{N} & 28,191 & \textit{\textbf{N}} & 36,466,751 \\
\textit{\textbf{N}} & 1,864,879 & \textit{N} & 28,060 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 20,332 & \textit{\textbf{N}} & 2,780,477 \\
\textit{N} & 223,125 & \textit{N} & 156,596 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 855,370 & \textit{N} & 103,620 \\
\textit{N} & 97,971 & \textit{N} & 12,592 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 597,320 & \textit{N} & 5,933,800 \\
\textit{N} & 592,703 & \textit{N} & 26,060 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 6,379,367 & \textit{\textbf{N}} & 843,139 \\
\textit{N} & 3,132,240 & \textit{N} & 132,380 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 84,780 & \textit{\textbf{N}} & 452,743 \\
\textit{N} & 236,082 & \textit{N} & 7,849,435 \\
\rowcolor[HTML]{EFEFEF}
\textit{\textbf{N}} & 1,990,117 & \textit{N} & 171,539 \\
\textit{N} & 6,884,437 & \textit{\textbf{N}} & 41,269,789 \\ \hline
\\
\end{tabularx}
\caption{....}
\vspace{-5mm}
\end{table}
\FloatBarrier
答案1
像这样?
\documentclass[format=acmsmall, anonymous=true]{acmart}
\usepackage{array,tabularx,ragged2e,booktabs,colortbl}
\begin{document}
\begin{table}
\centering
\begin{tabularx}{\linewidth}{lrlr}
\hline
\rowcolor[HTML]{EFEFEF}
\multicolumn{4}{X}{\cellcolor[HTML]{EFEFEF}\centering
\textbf{Center This}} \\ \hline
\textit{\textbf{}} & \textit{\textbf{\#}} & \textit{\textbf{}} & \textit{\textbf{\#}} \\ \hline
\rowcolor[HTML]{EFEFEF}
\textit{N} & 28,191 & \textit{\textbf{N}} & 36,466,751 \\
\textit{\textbf{N}} & 1,864,879 & \textit{N} & 28,060 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 20,332 & \textit{\textbf{N}} & 2,780,477 \\
\textit{N} & 223,125 & \textit{N} & 156,596 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 855,370 & \textit{N} & 103,620 \\
\textit{N} & 97,971 & \textit{N} & 12,592 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 597,320 & \textit{N} & 5,933,800 \\
\textit{N} & 592,703 & \textit{N} & 26,060 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 6,379,367 & \textit{\textbf{N}} & 843,139 \\
\textit{N} & 3,132,240 & \textit{N} & 132,380 \\
\rowcolor[HTML]{EFEFEF}
\textit{N} & 84,780 & \textit{\textbf{N}} & 452,743 \\
\textit{N} & 236,082 & \textit{N} & 7,849,435 \\
\rowcolor[HTML]{EFEFEF}
\textit{\textbf{N}} & 1,990,117 & \textit{N} & 171,539 \\
\textit{N} & 6,884,437 & \textit{\textbf{N}} & 41,269,789 \\ \hline
\\
\end{tabularx}
\caption{....}
\vspace{-5mm}
\end{table}
% \FloatBarrier
\end{document}