Both problems are related. \cline
has to support several \cline
s in a row, e.g.:
\documentclass{article}
\begin{document}
\begin{tabular}{*{5}{c}}
1 & 2 & 3 & 4 & 5\\
\cline{1-1}\cline{3-3}\cline{5-5}
A & B & C & D & E
\end{tabular}
\end{document}
Therefore \cline
cannot move down like \hline
, the definition of \cline
is (latex.ltx
):
\def\cline#1{\@cline#1\@nil}
\def\@cline#1-#2\@nil{%
\omit
\@multicnt#1%
\advance\@multispan\m@ne
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\advance\@multicnt-#1%
\advance\@multispan\@ne
\leaders\hrule\@height\arrayrulewidth\hfill
\cr
\noalign{\vskip-\arrayrulewidth}}
In the last step \cline
moves back to the original vertical position.
But the vertical space for the line can be added after the \cline
s, e.g.:
\cline{...}\cline{...}\noalign{\vskip\arrayrulewidth}
Applied to your example, it can be added to macro \whline
. This fixes also the problem with \cellcolor
:
\documentclass{article}
\usepackage{array}
\usepackage{colortbl}
\begin{document}
\newcolumntype{I}{!{\vrule width 3pt}}
\newlength\savedwidth
\newcommand\whline[1]{%
\noalign{%
\global\savedwidth\arrayrulewidth\global\arrayrulewidth 6pt%
}%
\cline{#1}%
\noalign{\vskip\arrayrulewidth}%
\noalign{\global\arrayrulewidth\savedwidth}%
}
\begin{tabular}{|cIc|c|}\hline
A & B & C \\ \hline
X & \cellcolor{red}Y & Z \\ \whline{1-3}
\cellcolor{green}100 & 10 & 1 \\ \hline
\end{tabular}
\end{document}
If you only want the bottom half of the double line to extend to the first column you can use
\documentclass{article}
\usepackage{hhline}
\begin{document}
\begin{tabular}{r|l|}
\hhline{~|-}
& hexadecimal \\
& octal \\ \cline{2-2}
& binary \\
\hhline{-:=}
\multicolumn{1}{|r|}{1984} & decimal \\
\hline
\end{tabular}
\end{document}
Best Answer
AFAIK the
\cline
does not add vertical space by itself, therefore the two are just printed over each other. Thebooktabs
package, which I can recommend greatly in general for all tables, defines therefore the\morecmidrules
macro:However, the
booktabs
manual says that double lines are evil and should not be used at all....