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}

jrjrjr
  • 373
  • 3
  • 12

2 Answers2

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

  • thanks for your suggestion! This is almost perfect -- is there anyway of emulating the \toprule and \bottomrule line thickness using \hline? – jrjrjr Apr 09 '21 at 21:45
  • @jrjr: you have the \Xhline and \Xcline commands from makecell, or \hlineB and \clineB form boldline (shipunov bundle`). – Bernard Apr 09 '21 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 09 '21 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. – Jasper Habicht Apr 10 '21 at 06: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

F. Pantigny
  • 40,250