I have a table in which I want a horizontal line only over a defined multicolumn. I checked some ideas from stackExchange like: How to add more space underneath and above a horizontal line in tabu? using cline or the one mentioned here: Adding a horizontal line to a multicolumn field in a longtable However, in my case the horizontal line is not appearing and I don't know why. I also tried the \cmidrule{} keyword that is mentioned here Adding table with restricted horizontal line but here I have the problem that the line is shifted to the top a bit which can be seen in the picture below.
A small test code is attached. Any suggestion to shift the horizonal line correctly would be nice to have. Or if someone has another suggestion to achieve that. Thanks in advance. Kind regards Tobi
\documentclass[a4paper, 11pt, ngerman]{scrreprt}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{hhline}
\usepackage{xcolor}
\begin{document}
\def\arraystretch{1.15}
\begin{table}[b]
\tiny
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\cmidrule{6-9}
\multicolumn{5}{c|}{} &
\multicolumn{2}{c|}{\cellcolor{gray!10}Annahme Kugel} &
\multicolumn{2}{c|}{\cellcolor{gray!10}Annahme Platte}
\\\hline
\cellcolor{gray!10}ID &
\cellcolor{gray!10}Breite &
\cellcolor{gray!10}Länge &
\cellcolor{gray!10}Breite&
\cellcolor{gray!10}Länge &
\cellcolor{gray!10}Volumen&
\cellcolor{gray!10}Radius (Äquiv)&
\cellcolor{gray!10}Volumen&
\cellcolor{gray!10}Radius (Äquiv)
\\
\cellcolor{gray!10}[-] &
\cellcolor{gray!10}[px] &
\cellcolor{gray!10}[px] &
\cellcolor{gray!10}[$\mu$m] &
\cellcolor{gray!10}[$\mu$m] &
\cellcolor{gray!10}[m$^{3}$] &
\cellcolor{gray!10}[m] &
\cellcolor{gray!10}[m$^{3}$] &
\cellcolor{gray!10}[m]
\\\hhline{|=|=|=|=|=|=|=|=|=|}
1 & 22.0 & 427.6 & 2.03704E-06 & 3.95926E-05 & 1.29033E-16 & 3.13476E-06 & 3.19321E-15 & 9.13509E-06 \\
\end{tabular}
\end{table}
\end{document}
Best Answer
This a classical problem with
\cline
in coloured tables. The rules frombooktabs
do not have this problem, but they add padding above and below rules which is not coloured, whence white strips at the top and bottom of coloured rows.The simplest solution is to use
\hhline
andmakecell
to add vertical padding at the top and bottom of cells in columns with specifiers prefixed with the letterS
(orC
ifsiunitx
is loaded). To obtain this padding, one defines minimal vertical distances between a cell and the above and below cells.So here is a possible code, in which I commented
\tableSettings
since I don't know how it is defined. Playing with the value of\tabcolsep
, I could use\footnotesize
in the place of\tiny
, which is practically unreadable.