Breaking an hline for header

revtextables

I'm generating a document using Revtex{4-2}, and I'm struggling to create a nice table that's broken columnwise into two halves. The table looks something along the lines of this,

Random table snippit

and the source code is this,

\begin{table*}[h!]
    \begin{ruledtabular}
        \centering
        \caption{\label{tab:3} Random table.}   
        \begin{tabular}{cccccc}
            \multicolumn{3}{c}{Oil} & \multicolumn{3}{c}{Solution}\\ 
            Var & $x$ & $y$ & Var & $x$ & $y$\\ 
            \hline
            100 & 12 & 0.45 & 180 & 33 & 0.05\\
            200 & 15 & 0.14 & 240 & 84 & 0.04\\
            300 & 34 & 0.09 & 460 & 96 & 0.02\\
            400 & 58 & 0.02 & 780 & 21 & 0.21\\
            500 & 59 & 0.08 & 920 & 57 & 0.85\\
            600 & 7 & 0.50 & 450 & 56 & 0.96\\
            700 & 26 & 0.05 & 120 & 42 & 0.02\\ 
        \end{tabular}
    \end{ruledtabular}
\end{table*}

I would prefer to avoid vertical lines. Is there a way to add a disconnected hline under the multicolumns containing "Oil" and "Solution"? Something like:

enter image description here

I just don't know how to add the horizontal lines under the two multicolumns.

Best Answer

You mean like this? A ruledtabular is nothing other than a page-wide tabular with double rules, this is simply achieved using a tabularx that is \textwidth wide with double \hlines.

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{table}[h!]
    \renewcommand{\arraystretch}{1.2}
    \centering
    \caption{\label{tab:3} Random table.}  
    \medskip 
    \begin{tabularx}{\textwidth}{YYYcYYY} \hline\hline
        \multicolumn{3}{c}{Oil} & & \multicolumn{3}{c}{Solution}\\ 
        Var & $x$ & $y$ && Var & $x$ & $y$\\ 
        \cline{1-3} \cline{5-7}
        100 & 12 & 0.45 && 180 & 33 & 0.05\\
        200 & 15 & 0.14 && 240 & 84 & 0.04\\
        300 & 34 & 0.09 && 460 & 96 & 0.02\\
        400 & 58 & 0.02 && 780 & 21 & 0.21\\
        500 & 59 & 0.08 && 920 & 57 & 0.85\\
        600 &  7 & 0.50 && 450 & 56 & 0.96\\
        700 & 26 & 0.05 && 120 & 42 & 0.02\\ \hline
    \end{tabularx}
\end{table}

\end{document}

enter image description here