# \cline doesn't work

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}

• Welcome to TeX.SE. The \cline is working fine. However you are also coloring the rows and hence it does not show up. If you comment out the \rowcolor commands you'll see that it is working. Are you sure you want to use rowcolor and a \cline to separate rows? Seems like only one should be necessary to do the job. Jan 1, 2012 at 2:26
• @Herbert Thanks for removing the {beamer} tag -- I hadn't been sure if beamer was relevant to this question. Jan 2, 2012 at 10:18

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.

1. 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:

2. Another option is to use \cmidrule from the booktabs 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}

3. Use the \hhline package which provides a command similar to \hline which takes a parameter similar to a tabular 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

• Both the booktabs and hhline 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:

\documentclass[table]{beamer}
\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]{1}
\multirow{-2}{*}{left\cellcolor[gray]{.9}}
& $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}


## Code: Use booktabs package:

\documentclass[table]{beamer}
\usepackage{xcolor,multirow}
\usepackage{booktabs}

\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}

\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} \\
\cmidrule{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}


## Code: hhline package:

\documentclass[table]{beamer}
\usepackage{xcolor,multirow}
\usepackage{hhline}

\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}
\hhline{~|------}
\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}


that is only a problem with the pdf viewer. Here is your example without any change:

Increasing or decreasing the zoom gives a "hidden" line. You must controll the behaviour with your viewer in the full-screen mode. And if the line is present can also be tested with a printed output which should show all lines.

• I tried with Acrobat 10.1 on Mac and it does not display the horizontal line, but surprisingly Mac Preview does show it!! However, Section 10 of the colortbl documentation seems to indicate that a feature of \cline is that "they are covered up by any colour pannels in the following row". Jan 1, 2012 at 17:37

With {NiceTabular} of nicematrix, you will have the expected result. The rules won't seem to disappear and you won't see thin white lines, whatever PDF viewer you use.

\documentclass{beamer}
\usepackage{nicematrix}

\begin{document}

\begin{frame}
\begin{table}
\centering
\begin{NiceTabular}{|c|cccccc|}
\CodeBefore
\rowcolor[gray]{0.9}{1,2}
\rowcolors{3}{blue!20}{blue!10}
\Body
\Hline
\Block{2-1}{left} & \Block{1-2}{first} & & \Block{1-2}{second} & & \Block{1-2}{third} \\
\cline{2-7}
& $x_1$ & $x_2$ & $x_3$ & $x_4$      & $x_5$ & $x_6$ \\
\Hline
A & a1    & a2    & a3    & a4         & a5   & a6 \\
B & b1    & b2    & \Block{1-2}{b34} & & b5   & b6 \\
C & c1    & c2    & c3    & c4         & c5   & c6 \\
D & d1    & d2    & d3    & d4         & d5   & d6 \\
\Hline
\end{NiceTabular}
\end{table}
\end{frame}

\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).