0

I'm still new to latex and having some trouble with my tables. I have to make a table in the format below (e.g., specific line thickeness, double lines below column headers, and vertical lines between columns). How can I extend the vertical lines between the columns in my headers that use multicolumn?

If this is not possible with booktabs, what is another package that works well with mult columns and multi rows?

% \usepackage{amssymb}
% \usepackage{array}
% \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\def\toprule{\specialrule{1.5pt}{0pt}{0pt}}
\def\botrule{\toprule}
\def\headerrule{\hline\hline}
\def\midrule{\specialrule{0.5pt}{0pt}{0pt}}

\begin{table}
\centering
\caption{CAPTION.}

\begin{tabular}{C{2cm}|C{2cm}|C{2cm}|C{2cm}|C{2cm}|C{4cm}C{4cm}}
\toprule

Column A & \multicolumn{3}{c}{Column B} & Column C & Column D \\
\cline{2-4}
& B1 & B2 & B3       \\
\headerrule

blah & \checkmark & \checkmark & \checkmark & blah & blah \\
\midrule
blah & \checkmark & -- & \checkmark & blah & blah \\

\botrule
\end{tabular}

\end{table}

enter image description here

4
  • 3
    read the booktabs package documentation. It by design makes vertical rules unusable. Choose booktabs or | do not use both. Nov 22, 2022 at 21:17
  • please provide a small complete document not just fragment so we do not have to guess definitions of C etc Nov 22, 2022 at 21:37
  • 2
    perhaps you just want & B1 & B2 & B3 & & \\ so the row does not end short and the rules get drawn? Nov 22, 2022 at 21:39
  • Thank you, using `Column A & \multicolumn{3}{c|}{Column B} & Column C & Column D \\ \cline{2-4} & B1 & B2 & B3 & & \` works. I will accept it as an answer if you write it up.
    – a11
    Nov 22, 2022 at 21:46

2 Answers 2

2

You did not provide a usable example but it seems you just want

 & B1 & B2 & B3 & &       \\ 

so the row does not end short and the vertical rules get drawn

2

For fun, but you may liked :-)

  • With tabularray package you can define lines thickness in table preamble
  • Columns width you can define absolutely or better as ration between width of X columns (as is done in MWE below).
\documentclass{article}
\usepackage{geometry}
\usepackage[skip=1ex, 
            font=sf, labelfont=bf,
            singlelinecheck=false]{caption}
\usepackage{tabularray}
\usepackage{dingbat}
\newcommand\cm{\checkmark}

\begin{document}
    \begin{table}[ht]
    \centering
\sffamily
\caption{CAPTION.}

\begin{tblr}{hline{1,Z}=1pt, 
             hline{2,4-Z}=solid,
             hline{3} = {1}{-}{},
             hline{3} = {2}{-}{},
             vline{2-Y} = solid,
             colspec={ *{5}{X[c]} X[2,c] }
            }
\SetCell[r=2]{h}   Column A    
            & \SetCell[c=3]{c}  Column B    
                    &       &       & \SetCell[r=2]{h}   Column C  
                                                & \SetCell[r=2]{h}   Column D  \\
            & B1    & B2    & B3    &           &           \\

blah        & \cm   & \cm   & \cm   & blah      & blah      \\
blah        & \cm   & --    & \cm   & blah      & blah      \\
\end{tblr}
    \end{table}
\end{document}

enter image description here

You must log in to answer this question.

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