2

I'm back with more table issues!

I am trying to center the top row on the following table (the one that reads "Center This"). I have been trouble shooting a few solutions here on tex but can't seem to get it right.

\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 Answer 1

3

Like this?

\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}

enter image description here

1
  • Ha! Yes, that was really simple - thank you. Commented Mar 30, 2019 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .