I'd like to draw a partial horizontal line just below of 'first second third' row, but \cline
doesn't work. Any suggestion?
\documentclass[table]{beamer}
\usepackage[T1]{fontenc}
\usepackage{xcolor,multirow}
\begin{document}
%%%
\begin{frame}
\frametitle{table example}
\begin{table}[h]
\centering
\rowcolors[]{2}{blue!20}{blue!10}
\begin{tabular}{|c|cccccc|} \hline
\rowcolor[gray]{.9}
&
\multicolumn{2}{>{\columncolor[gray]{.9}}c}{first} &
\multicolumn{2}{>{\columncolor[gray]{.9}}c}{second} &
\multicolumn{2}{>{\columncolor[gray]{.9}}c|}{third} \\
\cline{2-7}
\rowcolor[gray]{.9}
\multirow{-2}{*}{left}
& $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $x_6$ \\ \hline
A & a1 & a2 & a3 & a4 & a5 & a6 \\
B & b1 & b2 & \multicolumn{2}{>{\columncolor{blue!20}}c}{b34} & b5 & b6 \\
C & c1 & c2 & c3 & c4 & c5 & c6 \\
D & d1 & d2 & d3 & d4 & d5 & d6 \\ \hline
\end{tabular}
\end{table}
\end{frame}
\end{document}
Best Answer
As I mentioned in the comments, the
\cline
is working but is hidden due to the coloring of the rows, and it seems to me to be a bit of an overkill to use both a horizontal rule along with coloring to separate a row.My suggestion would be to remove the row color in the second row, and use
\cellcolor
to ensure that the\multirow
text is properly colored:Another option is to use
\cmidrule
from thebooktabs
package (see Known Issues below). This package highly recommends that you not use vertical lines in tables, but have left them in as that was in the original MWE. Note that this also requires setting\setlength{\aboverulesep}{0pt}
and\setlength{\belowrulesep}{0pt}
Use the
\hhline
package which provides a command similar to\hline
which takes a parameter similar to atabular
specification, so that vertical lines can be properly handled. The output of this is similar to that produced in #2 above. (see Known Issues below)Known Issues
booktabs
andhhline
solutions have an issue in that there is a white line in the\multirow
text which I do not know how to fix.Code: Remove row color from second row:
Code: Use
booktabs
package:Code:
hhline
package: