# How can I reproduce this table with thick lines?

I'm trying to reproduce this table:

(apologies for the terrible cameraphone pic)

I don't know how to get the slightly thicker leftmost and topmost line.

Here's a minimal example of what I have so far:

\documentclass[a4paper,12pt]{article}

\begin{document}

\begin{tabular}{c|c|c|c|c|c}
$*$ & $a$ & $b$ & $c$ & $d$ & $e$ \\\hline
$a$ & $a$ & $b$ & $c$ & $b$ & $d$ \\\hline
$b$ & $b$ & $c$ & $a$ & $e$ & $c$ \\\hline
$c$ & $c$ & $a$ & $b$ & $b$ & $a$ \\\hline
$d$ & $b$ & $e$ & $b$ & $e$ & $d$ \\\hline
$e$ & $d$ & $b$ & $a$ & $d$ & $c$
\end{tabular}

\end{document}


Is there an easy way to make the leftmost and topmost lines thicker?

-
well your cam pic does have some nice colors! – flow Aug 28 '13 at 13:10
@flow ... none of which appear on the page! Lovely, (: – Harold Aug 28 '13 at 21:32
Eh...finite groupoids! – MattAllegro Apr 26 '14 at 8:01
Sorry, edit went in wrong place. – Francis Davey Nov 10 '14 at 15:00

You could define a thick version of \hline and a thick | as new column type as I did below. Both are based on the original code, only the thickness got changed from \arrayrulewidth to 1pt.

\documentclass[a4paper,png]{standalone}
\usepackage{array}

\makeatletter
\newcommand{\thickhline}{%
\noalign {\ifnum 0=}\fi \hrule height 1pt
\futurelet \reserved@a \@xhline
}
\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}
\makeatother

\begin{document}

\begin{tabular}{c"c|c|c|c|c}
$*$ & $a$ & $b$ & $c$ & $d$ & $e$ \\\thickhline
$a$ & $a$ & $b$ & $c$ & $b$ & $d$ \\\hline
$b$ & $b$ & $c$ & $a$ & $e$ & $c$ \\\hline
$c$ & $c$ & $a$ & $b$ & $b$ & $a$ \\\hline
$d$ & $b$ & $e$ & $b$ & $e$ & $d$ \\\hline
$e$ & $d$ & $b$ & $a$ & $d$ & $c$
\end{tabular}

\end{document}


On request here a definition of a thick version of \cline:

\newcommand{\thickcline}[1]{%
\@thickcline #1\@nil%
}

\def\@thickcline#1-#2\@nil{%
\omit
\@multicnt#1%
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\cr
\noalign{\vskip-1pt}%
}

-
I truly love this answer, however, what if I want a thick line but from certain position on the table to another one (not coordinates, good idea anyway) like the usage of cline. – Hans Apr 25 '14 at 23:21
I mean partial horizontal thick lines. – Hans Apr 25 '14 at 23:34
@Hans: I added a definition for a \thickcline now. Note that if you mix it with normal \cline or \hline the lines will be top aligned, which doesn't look that good. – Martin Scharrer Apr 26 '14 at 7:55
I'd really like to use this, but when I do there is a gap between the leftmost line and the left edge of the table and the rightmost line and the right edge of the table so the top line overhangs the lines going down and this looks terrible. What do I do to fix that? – Francis Davey Nov 10 '14 at 15:01
@MartinScharrer Your definition of " gives me display problems when I try to place it as the left and right edge lines, e.g. \begin{tabular}{"c"c"} ... will make the horizontal lines go beyond the vertical ones at the edges. I made the following modification: \newcolumntype{[}{@{\vrule width 1pt\hspace{6pt}}} \newcolumntype{]}{@{\hspace{6pt}\vrule width 1pt}} \newcolumntype{!}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}} which seems to get rid of the problem used as \begin{tabular}{[c!c]} .... My ! is the same as your ": for people using Kile the latter might be annoying. – Miguel Jul 21 '15 at 9:11

The package tabu provides such a modification by the optional arguments of the vertical line and the command \tabucline

\documentclass[a4paper,12pt]{article}
\usepackage{tabu}
\begin{document}

\begin{tabu}{c|[2pt]c|c|c|c|c}
$*$ & $a$ & $b$ & $c$ & $d$ & $e$ \\\tabucline[2pt]{-}
$a$ & $a$ & $b$ & $c$ & $b$ & $d$ \\\hline
$b$ & $b$ & $c$ & $a$ & $e$ & $c$ \\\hline
$c$ & $c$ & $a$ & $b$ & $b$ & $a$ \\\hline
$d$ & $b$ & $e$ & $b$ & $e$ & $d$ \\\hline
$e$ & $d$ & $b$ & $a$ & $d$ & $c$
\end{tabu}

\end{document}
`

However to produce nice tables avoid vertical lines and be spare with horizontal lines. For all this I recommend the package booktabs. Via google you will find a lot of examples.

-
Thank you for the super-fast and cogent response. I'm going to be typesetting a fair number of these tables which define binary operations on finite sets. Can you elaborate on how you think the appearance could be improved? Should this be a separate question? – Harold Jan 20 '12 at 18:49
This is possibly one case where rules may remain, as it's really a lattice and not a formal table. But I would avoid thick rules anyway. – egreg Jan 20 '12 at 18:56
@Harold: My note depends on normal tables. For your binary tables I would work in the same way but I would also increase the space between the cells. – Marco Daniel Jan 20 '12 at 21:18
@MarcoDaniel, good. Thanks. – Harold Jan 20 '12 at 23:27
Dear @MarcoDaniel, how can I color one table box in tabu environment? Thanks for help, R. – user51937 Apr 7 '15 at 16:27