Welcome to the UK List of
TeX Frequently Asked Questions
on the Web

Searching

The index of Frequently Asked Questions about TeX is searchable.

Please enter your keyword here:   then press here: ,    or:
Google

Diagonal separation in corner cells of tables

You want to label both the top or bottom row and the left- or rightmost column, somewhere at the corner of the table where the row and column meet. A simple way to achieve the result is to construct the table with an arrangement of rules (and possibly \multicolumn entries), to look like:

-----------------
x  y
   --------------
   1  2  3  4  5
-----------------
1
2
3
4
5
-----------------

However, this doesn’t satisfy everyone: many want the labelling in a single cell at the top left of the table. It sounds a simple enough requirement, yet it calls for some slightly tricky LaTeX coding. The diagbox package does this job for you: it defines a command \diagbox whose two arguments provide the texts to be used; an optional argument may be used for fine tuning of the result. It draws a picture with the two labels on either side of a slanting line; the command (and hence the picture) may be placed in the corner cell, where the labelled row and column meet.

The diagbox package supersedes slashbox; the older package’s commands \slashbox and \backslashbox are provided in a compatible way in the newer package, to ease transition.

diagbox.sty
macros/latex/contrib/diagbox (or browse the directory); catalogue entry
slashbox.sty
macros/latex/contrib/slashbox (or browse the directory); catalogue entry

This answer last edited: 2010-11-22


Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=slashbox

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.27, released on 2013-06-07.