4

I'm using the method from this post to generate booktabs tables with alternating rowcolors (yes I know it's a frowned upon practice but I have to use it). Now I want to use \cmidrule to generate a line in the header spanning over the last 5 columns. Unfortunately the line has the wrong background color now. Is there a way to fix this?

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{colortbl}% http://ctan.org/pkg/colortbl
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{graphicx}% http://ctan.org/pkg/graphicx

\colorlet{tableheadcolor}{gray!25} 
\newcommand{\headcol}{\rowcolor{tableheadcolor}} %
\colorlet{tablerowcolor}{gray!10} 
\newcommand{\rowcol}{\rowcolor{tablerowcolor}} %

\newcommand{\topline}{\arrayrulecolor{black}\specialrule{0.1em}{\abovetopsep}{0pt}%
        \arrayrulecolor{tableheadcolor}\specialrule{\belowrulesep}{0pt}{0pt}%
        \arrayrulecolor{black}}

\newcommand{\midline}{\arrayrulecolor{tableheadcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
        \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
        \arrayrulecolor{black}}

 \newcommand{\rowmidlinecw}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
        \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
        \arrayrulecolor{black}}

 \newcommand{\rowmidlinewc}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
        \arrayrulecolor{tablerowcolor}\specialrule{\belowrulesep}{0pt}{0pt}%
        \arrayrulecolor{black}}

\newcommand{\rowmidlinew}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{black}}

\newcommand{\rowmidlinec}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{black}}

 \newcommand{\bottomline}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}%
 \newcommand{\bottomlinec}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}%

\begin{document}

\begin{table}[htb!]
\centering

\begin{tabular}{lllccccc}
    \topline
    \headcol &         &                                                         & \multicolumn{5}{c}{Kodierung}    \\
    \cmidrule {4-8}
    \headcol & Einheit & Faktor $x_i$  & -2  & -1    & 0    & 1     & 2    \\
    \midline
    Badtemperatur            & °C      & 1      & 40  & 45    & 50   & 55    & 60   \\
    \rowcol Bandgeschwindigkeit      & mm/min  & 2      & 500 & 625   & 750  & 875   & 1000 \\
    Trockentemperatur        & °C      & 3      & 22  & 36,5  & 51   & 65,5  & 80   \\
    \rowcol \begin{tabular}[c]{@{}l@{}}Luftfeuchte im \\ Trockenmedium\end{tabular} & \%      & 4                                                       & 0   & 13,75 & 27,5 & 41,25 & 55   \\ 
    \bottomlinec
\end{tabular}
\caption{Faktoren und ihre Kodierung}
\label{tab:FaktorenKodierung}
\end{table}

\end{document}

I appreciate any help

Jon

0 Answers0