You need to use a column-specific line \cline
as well as a \multicolumn{1}{c|}
entry to remove the rules from the top left cell:
\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\begin{document}
\begin{table}[!ht]
\centering
\begin{tabular}{|c|c|c|c|}
\cline{2-4}
\multicolumn{1}{c|}{} & Item1 & Item2 & Item3 \\ \hline
Group1 & 0.8 & 0.1 & 0.1 \\ \hline
Group2 & 0.1 & 0.8 & 0.1 \\ \hline
Group3 & 0.1 & 0.1 & 0.8 \\ \hline
Group4 & 0.34 & 0.33 & 0.33 \\ \hline
\end{tabular}
\bigskip
\begin{tabular}{cccc}
\toprule
& Item1 & Item2 & Item3 \\ \midrule
Group1 & 0.8 & 0.1 & 0.1 \\
Group2 & 0.1 & 0.8 & 0.1 \\
Group3 & 0.1 & 0.1 & 0.8 \\
Group4 & 0.34 & 0.33 & 0.33 \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
I've also added a booktabs
variant, which is still clear in terms of the presentation, and looks cleaner.
Typically one could use hhline
to modify the horizontal rule within a tabular
, allowing a mixture of single and double lines. However, the output in your case is not very desirable. Here's an alternative, showing a modified version of your input (using booktabs
) first with \hhline
and then without (and some other tricks):
\documentclass{article}
\usepackage{booktabs,hhline}% http://ctan.org/pkg/{booktabs,hhline}
\begin{document}
\begin{tabular}{lrr}
\toprule
Item & Sales & Total \\
\midrule
Item 1 & 10 & \\
Item 1 & 10 & 20 \\ \hhline{--=}
Item 1 & 10 & \\
Item 2 & 10 & \\
Item 2 & 10 & 30 \\ \hhline{--=}
\end{tabular}
\bigskip
\begin{tabular}{lrr}
\toprule
Item & Sales & Total \\
\midrule
Item 1 & 10 & \\
Item 1 & 10 & 20 \\ \hline \\[\dimexpr-\normalbaselineskip+\arrayrulewidth+1pt]
\cline{3-3}
Item 1 & 10 & \\
Item 2 & 10 & \\
Item 2 & 10 & 30 \\ \hline \\[\dimexpr-\normalbaselineskip+\arrayrulewidth+1pt]
\cline{3-3}
\end{tabular}
\end{document}
The second option inserts a regular \hline
followed by a 1pt
gap and \cline{3-3}
(modify 1pt
for a different gap). More specifically, \dimexpr
allows for an expression of dimensions, jumping back (vertically upward) a full baseline skip (-\normalbaselineskip
) and then forward (vertically downward) the default width of the rule (\arrayrulewidth
, typically 0.4pt
) plus 1pt
.
I'm sure another technique would also suffice; this just seemed the most straight forward. This is mainly based on style, so there are other options as well.
The later option needs some additional hacking when using vertical borders also,
\documentclass{article}
\begin{document}
\begin{tabular}{|l|r|r|}
Item & Sales & Total \\
Item 1 & 10 & \\
Item 1 & 10 & 20 \\ \hline
& & \\[\dimexpr-\normalbaselineskip+\arrayrulewidth+1pt] \cline{3-3}
Item 1 & 10 & \\
Item 2 & 10 & \\
Item 2 & 10 & 30 \\ \hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{}
\\[\dimexpr-\normalbaselineskip+\arrayrulewidth+1pt] \cline{3-3}
\end{tabular}
\end{document}
Best Answer
i would use rules from
booktabs
for all horizontal rules in table not just one ...