\cellcolor color fill in \tabular has vertical gap for cells separated with cmidrule

cellcolorgaptables

Experimenting with the solution presented in https://tex.stackexchange.com/a/613957/144487 I find that the cells of the table are not completely filled with color:

\documentclass[12pt,
    a4paper,
    ngerman,
    numbers=noenddot, % not 1.1. but 1.1 
    oneside,
    bibliography=totocnumbered,
    listof=totoc,
    parskip=half,
]{scrreprt}

\usepackage{roboto}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{tabularx}

% !!!!!!!!!!!!!!!!!!!!!
\usepackage{nicematrix}

\usepackage{booktabs} % for \midrule
\usepackage{colortbl} % in conjunction with color this creates colored tables
% Activate merged cell for tables
\usepackage{multirow}
% Fit tables etc. into page width
\usepackage{adjustbox}
% Table layout utilities
\usepackage{makecell}

\begin{document}

\begin{table}[p]
    \centering
    \caption{Some Caption}
    \label{tab:Some Caption}
    \begin{adjustbox}{max width=\textwidth}
        \begin{NiceTabular}{|l|l|c|c|c|}
            \toprule
            \textbf{Category}                   & \textbf{Core-Statement} & \textbf{Relevance}                     & \textbf{Häufigkeit}                    & \textbf{Occurrence}                   \\
            \midrule
            \multicolumn{1}{|l|}{\multirow{3}[6]{*}{Entrepreneurial Learning}}
            & Text                    & 41                                     & 37                                     & 11                                    \\
            \cmidrule{2-5}
            & More Text               & 34                                     & 31                                     & 9                                     \\
            \cmidrule{2-5}
            & Lean Startup            & 21                                     & 15                                     & 8                                     \\
            \midrule
            \multicolumn{1}{|l|}{\multirow{4}[8]{*}{Lorem Ipsum}}              & Gamma                   & 14                                     & 13                                     & 9                                     \\
            \cmidrule{2-5}                                                     & Size                    & \cellcolor[rgb]{ .906,  .902,  .902}11 & 18                                     & 11                                    \\
            \cmidrule{2-5}                                                     & Costs                   & \cellcolor[rgb]{ .906,  .902,  .902}9  & \cellcolor[rgb]{ .906,  .902,  .902}11 & \cellcolor[rgb]{ .906,  .902,  .902}6 \\
            \cmidrule{2-5}                                                     & New Stuff               & \cellcolor[rgb]{ .906,  .902,  .902}8  & \cellcolor[rgb]{ .906,  .902,  .902}9  & \cellcolor[rgb]{ .906,  .902,  .902}5 \\
            \bottomrule
        \end{NiceTabular}%
    \end{adjustbox}
    \label{tab:addlabel}%
\end{table}


\end{document}

yields

enter image description here

Any idea how to fix this?

Best Answer

If you can accept using tabularray, then everything will become very simple.

\documentclass[12pt,a4paper,oneside,bibliography=totocnumbered,listof=totoc,parskip=half]{scrreprt}
\usepackage[sfdefault]{roboto}
\usepackage{xcolor}
\definecolor{tbgray}{rgb}{.906,.902,.902}
\usepackage{tabularray}
\begin{document}
\begin{table}[h]
\caption{title}
\begin{tblr}
{
colspec        = {*{5}{Q[co=-1,l,m]}},
row{1}         = {halign=c},
cell{2-Z}{3-Z} = {halign=c},
hlines,vlines,
row{1}         = {cmd=\bfseries},
cell{2}{1}     = {r=3}{},
cell{5}{1}     = {r=4}{},
cell{X}{3}     = {bg=tbgray},
cell{Y-Z}{3-Z} = {bg=tbgray},
}
Category                 & CoreStatement & Relevance & Häufigkeit & Occurrence \\
Entrepreneurial Learning & Text          & 41        & 37         & 11         \\
                         & More Text     & 34        & 31         & 9          \\
                         & Lean Startup  & 21        & 15         & 8          \\
Lorem Ipsum              & Gamma         & 14        & 13         & 9          \\
                         & Size          & 11        & 18         & 11         \\
                         & Costs         & 9         & 11         & 6          \\
                         & New Stuff     & 8         & 9          & 5          \\
\end{tblr}
\end{table}

\begin{table}[h]
\caption{title}
\begin{tblr}
{
colspec        = {*{5}{Q[co=-1,l,m]}},
row{1}         = {halign=c},
cell{2-Z}{3-Z} = {halign=c},
hline{1,Z}     = {wd=.08em},
hline{2,5}     = {wd=.05em},
row{1}         = {cmd=\bfseries},
cell{2}{1}     = {r=3}{},
cell{5}{1}     = {r=4}{},
cell{X}{3}     = {bg=tbgray},
cell{Y-Z}{3-Z} = {bg=tbgray},
}
Category                 & CoreStatement & Relevance & Häufigkeit & Occurrence \\
Entrepreneurial Learning & Text          & 41        & 37         & 11         \\
                         & More Text     & 34        & 31         & 9          \\
                         & Lean Startup  & 21        & 15         & 8          \\
Lorem Ipsum              & Gamma         & 14        & 13         & 9          \\
                         & Size          & 11        & 18         & 11         \\
                         & Costs         & 9         & 11         & 6          \\
                         & New Stuff     & 8         & 9          & 5          \\
\end{tblr}
\end{table}

\begin{table}[h]
\caption{title}
\begin{tblr}
{
colspec        = {*{5}{Q[co=-1,l,m]}},
row{1}         = {halign=c},
cell{2-Z}{3-Z} = {halign=c},
hline{1,Z}     = {wd=.08em},
hline{2,5}     = {wd=.05em},
row{1}         = {cmd=\bfseries},
cell{2}{1}     = {r=3}{},
cell{5}{1}     = {r=4}{},
cell{X}{3}     = {fg=red5,cmd=\bfseries},
cell{Y-Z}{3-Z} = {fg=red5,cmd=\bfseries},
}
Category                 & CoreStatement & Relevance & Häufigkeit & Occurrence \\
Entrepreneurial Learning & Text          & 41        & 37         & 11         \\
                         & More Text     & 34        & 31         & 9          \\
                         & Lean Startup  & 21        & 15         & 8          \\
Lorem Ipsum              & Gamma         & 14        & 13         & 9          \\
                         & Size          & 11        & 18         & 11         \\
                         & Costs         & 9         & 11         & 6          \\
                         & New Stuff     & 8         & 9          & 5          \\
\end{tblr}
\end{table}
\end{document}

enter image description here