2

How can draw custom size hline to get lines like the ones below M, S, and T? enter image description here

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{table}
\centering
\begin{tabular}{cccccccccc}
          & \multicolumn{3}{c}{M} & \multicolumn{3}{c}{S} & \multicolumn{3}{c}{T} \\
    Model & S & T & S,T & M & T & M,T & M & S & M,S \\
    \hline
    MVAE   & 0.24 & 0.20 & 0.32 & 0.43 & 0.30 & 0.75 & 0.28 & 0.17 & 0.29 \\
    MMVAE  & 0.75 & 0.99 & 0.87 & 0.31 & 0.30 & 0.30 & 0.96 & 0.76 & 0.84 \\
    MoPoE  & 0.74 & 0.99 & 0.94 & 0.36 & 0.34 & 0.37 & 0.96 & 0.76 & 0.93 
\end{tabular}
\end{table}
\end{document}

UPDATE: as suggested by @Teddy van Jerry, \cmidrule draws lines as in the image above.

5
  • 3
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for the users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Commented Dec 19, 2023 at 9:25
  • 5
    Check out \cmidrule from booktabs. Commented Dec 19, 2023 at 9:25
  • 3
    Please provide a minimal working example (MWE). Do you use the booktabs package by chance? It provides \cmidrule which can be trimmed, for example using \cmidrule(lr){3–5}. Commented Dec 19, 2023 at 9:26
  • @TeddyvanJerry \cmidrule is what I was looking for! Commented Dec 19, 2023 at 9:57
  • (And \cmidrule isn't reflected in the code posted ...)
    – MS-SPO
    Commented Dec 19, 2023 at 11:04

1 Answer 1

1

(just to treat this query as having received an answer)

Since your code loads the booktabs package anyway, I suggest you employ that package's \cmidrule macro. I would also replace the lone \hline directive with \midrule.

enter image description here

\documentclass{article}
\usepackage{booktabs} % for '\midrule' and '\cmidrule' macros

\begin{document}
\begin{table}
\centering
\begin{tabular}{@{} l *{9}{c} @{}}
    Model 
    & \multicolumn{3}{c}{M} 
    & \multicolumn{3}{c}{S} 
    & \multicolumn{3}{c@{}}{T} \\
    \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(l){8-10}
    & S & T & S,T & M & T & M,T & M & S & M,S \\
    \midrule
    MVAE   & 0.24 & 0.20 & 0.32 & 0.43 & 0.30 & 0.75 & 0.28 & 0.17 & 0.29 \\
    MMVAE  & 0.75 & 0.99 & 0.87 & 0.31 & 0.30 & 0.30 & 0.96 & 0.76 & 0.84 \\
    MoPoE  & 0.74 & 0.99 & 0.94 & 0.36 & 0.34 & 0.37 & 0.96 & 0.76 & 0.93 
\end{tabular}
\end{table}
\end{document}

You must log in to answer this question.

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