1

I have used the code below to produce a table, however, it does not look correct. The regions that are causing issue are circled in red. Are the multicolumn/multirow packages not working in sync with tabular? Any suggestions to fix these issues?

Thanks in advance!

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{boldline}

\begin{table}[b!]
    \caption{.}
 \renewcommand{\arraystretch}{1.15}%
\centering
\setlength{\tabcolsep}{5.45pt}
\begin{tabular}{l c || c c c | c c c | c c} % 
\hlineB{2}
\multirow{3}{*}{} & \multirow{3}{*}{Year} & \multicolumn{3}{c|}{Technique}   &  \multicolumn{3}{c|}{Type}   & \multicolumn{2}{c}{Detail}\\
          &   & \multirow{2}{*}{Type}  &$\tau$ & \multirow{2}{*}{Idea}   & \multicolumn{3}{c|}{$\bar{u}$}   & \multicolumn{2}{c}{Idea}\\
    &   &  & [$-$] & &  $a$ & $b$ & $c$ & 1 & 2  \\ \hline \hline
& 2020 & -- & -- & -- & -- & -- & -- & -- & -- \\ 
\hlineB{2}
\end{tabular}
\end{table}
\end{document}

Since the answers refer to the original code of this question, it is provided here for reference. The above code has been edited by the OP.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{table}[b!]
    \caption{.}
 \renewcommand{\arraystretch}{1.15}
\centering
\setlength{\tabcolsep}{5.45pt}
\begin{tabular}{l c || c c c | c c c | c c} 
\toprule
        \multirow{3}{*}{} & \multirow{3}{*}{Year} & \multicolumn{3}{c}{Technique}   &  \multicolumn{3}{c}{Type}   & \multicolumn{2}{c}{Detail}\\
          &   & \multirow{2}{*}{Type}  &$\tau$ & \multirow{2}{*}{Idea}   & \multicolumn{3}{c}{$\bar{u}$}   & \multicolumn{2}{c}{Idea}\\
    &   &  & [$-$] & &  $a$ & $b$ & $c$ & 1 & 2  \\ \hline \hline
& 2020 & -- & -- & -- & -- & -- & -- & -- & -- \\ 
\bottomrule
\end{tabular}
\end{table}
\end{document}
2
  • 2
    The fact that you use \toprule suggests that you are loading booktabs, and booktabs simply does not like vertical rules, see Vertical table lines are discontinuous with booktabs.
    – campa
    Apr 9 at 15:50
  • 1
    A single vertical rule is bad, a double vertical rule is… ;-) Just don't use them!
    – egreg
    Apr 9 at 22:47
2

As already pointed out in the comments, if you want vertical rules, you should not use the booktabs package and stick to the regular \hline macro.

Also, if you use multicols, you need to tell them in the column definition that you want to have a vertical rule. So, instead of \multicolumn{3}{c}{...}, you should write \multicolumn{3}{c|}{...} where appropriate.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{multirow}

\begin{document}
\begin{table}[b!]
\caption{.}
\renewcommand{\arraystretch}{1.15}
\centering
\setlength{\tabcolsep}{5.45pt}
\begin{tabular}{l c || c c c | c c c | c c} 
\hline
\multirow{3}{*}{} & \multirow{3}{*}{Year} & \multicolumn{3}{c|}{Technique} &  \multicolumn{3}{c|}{Type} & \multicolumn{2}{c}{Detail} \\
 &  & \multirow{2}{*}{Type} & $\tau$ & \multirow{2}{*}{Idea} & \multicolumn{3}{c|}{$\bar{u}$} & \multicolumn{2}{c}{Idea} \\
 &  &  & [$-$] & &  $a$ & $b$ & $c$ & 1 & 2  \\ \hline \hline
 & 2020 & -- & -- & -- & -- & -- & -- & -- & -- \\ 
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

4
  • thanks for your suggestion! This is almost perfect -- is there anyway of emulating the \toprule and \bottomrule line thickness using \hline?
    – jrjrjr
    Apr 9 at 21:45
  • @jrjr: you have the \Xhline and \Xcline commands from makecell, or \hlineB and \clineB form boldline (shipunov bundle`).
    – Bernard
    Apr 9 at 22:27
  • thanks for the suggestion! I have updated the code and figure attached -- I am still getting an issue (as highlighted by the red circles). Do you know how to fix that? thanks
    – jrjrjr
    Apr 9 at 22:43
  • 1
    Please keep your original problem with picture and code in your question (you may add an additional question if related), because otherwise the answers are of no help for others who may have the same problem. Apr 10 at 6:01
1

If you actually want to use vertical rules with the horizontal rules of booktabs (which is not at all in the spirit of \booktabs), you should use {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{caption}
\usepackage{nicematrix}
\usepackage{booktabs}

\begin{document}
\begin{table}[b!]
\caption{My Caption}
\renewcommand{\arraystretch}{1.15}
\centering
\setlength{\tabcolsep}{5.45pt}
\begin{NiceTabular}{c || c c c | c c c | c c} 
\toprule
& \Block{1-3}{Technique} &&&  \Block{1-3}{Type} &&& \Block{1-2}{Detail} \\
Year & \Block{2-1}{Type} & $\tau$ & \Block{2-1}{Idea} & \Block{1-3}{$\bar{u}$} &&& \Block{1-2}{Idea} \\
&  & [$-$] & &  $a$ & $b$ & $c$ & 1 & 2  \\ 
\hline\hline
2020 & -- & -- & -- & -- & -- & -- & -- & -- \\ 
\bottomrule
\end{NiceTabular}
\end{table}
\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.