Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to reproduce this table:

table with thick first vertical and horizontal lines

(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?

share|improve this question
1  
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 at 8:01
    
Sorry, edit went in wrong place. –  Francis Davey Nov 10 at 15:00

2 Answers 2

up vote 25 down vote accepted

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}

Result


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%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#2%
  \advance\@multicnt-#1%
  \advance\@multispan\@ne
  \leaders\hrule\@height1pt\hfill
  \cr
  \noalign{\vskip-1pt}%
}
share|improve this answer
    
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 at 23:21
    
I mean partial horizontal thick lines. –  Hans Apr 25 at 23:34
1  
@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 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 at 15:01

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.

share|improve this answer
    
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
3  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.