1

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.

4
  • 1
    Welcome to TeX.SX! Did you already try \cline{1-3} \cline{4-6} right after \multicolumn{3}{c}{Oil} & \multicolumn{3}{c}{Solution}\\ ?
    – leandriis
    Sep 2, 2021 at 16:29
  • The use of table* as well as the screenshot in your question leads me to the conclusion that your table currently is as wide as the entire text. If you use a twocolumn layout, you may want to switch to table as the table in its current form should be narrow enough to fit in one of the two text columns.
    – leandriis
    Sep 2, 2021 at 16:33
  • @leandriis - Your suggestion to use two \cline directives is good.
    – Mico
    Sep 2, 2021 at 16:44
  • @leandriis - Yep the two clines worked. I tried this before I think with & seperating the clines and it gave an error. Should've played around with it more. Thanks?
    – lwarwaru
    Sep 3, 2021 at 17:11

1 Answer 1

1

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

2
  • 2
    The OP uses the revtex (or maybe revtex4-2) document class, which defines the ruledtabular environment.
    – Mico
    Sep 2, 2021 at 16:41
  • @AboAmmar - Mico is correct, I'm using revtex4-2. However, this table looks nice, I may try to use it.
    – lwarwaru
    Sep 3, 2021 at 17:14

You must log in to answer this question.

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