# How to handle wide columns with \backslashbox?

I'm using the package slashbox and my left column is reasonably wide, how can I tune the diagonal line (created by \backslashbox) such that it starts and ends in the corners of the cell?

Example code:

\documentclass[11pt]{article}
\usepackage{slashbox}
\usepackage{pict2e}
\begin{document}
\begin{table}[ht!]
\centering
\begin{tabular}{ *{4}{|c}|}
\hline
\hline
relatively wide column& b & $3$ & $4$ \\
ds & c & $1$ & $4$ \\
\hline
\end{tabular}
\end{table}
\end{document}


Result:

-

The simplest and most straightforward way of doing this is to specify the literal size of the slashed box. In your case, it's about 40mm. So try this:

\backslashbox[40mm]{foo}{bar}


Generalising this approach would not be much more complicated. Compute the size of the backslashbox by taking the size of the column's widest string then add on two times the width of the table's column separators.

-
+1 for this simple solution. ALthough it increases the column with. I wasn't aware of that. –  Thorsten Donig Nov 13 '10 at 12:23
yes, nice answer to the question. Too bad there isn't a more automatic way to achieve this. Now I have a dilemma, @Thorsten answer offers a visually better way to solve this, but this answer by @Geoffrey is the exact answer to the question asked, which should I accept? –  Davy Landman Nov 13 '10 at 12:30

Since this is an issue concerning the slashbox package itself, the only solution might be a hack of the package source. Consider to restructure the table and tweak it with the booktabs package. See code below for some ideas.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs,multirow}

\begin{document}
\begin{table}[!ht]
\caption{Table caption}\label{tab:default}
\centering
\begin{tabular}{*{4}{|c}|}\hline
\multirow{2}{*}{foo} & \multicolumn{3}{|c|}{bar} \\ \cline{2-4}
relatively wide column& b & $3$ & $4$ \\
ds & c & $1$ & $4$ \\ \hline
\end{tabular}
\end{table}

\begin{table}[!ht]
\caption{Table caption}\label{tab:booktabs}
\centering
\begin{tabular}{*{4}{c}}\toprule
\multirow{2}{*}[-0.5ex]{foo} & \multicolumn{3}{c}{bar} \\ \cmidrule{2-4}
relatively wide column& b & $3$ & $4$ \\
ds & c & $1$ & $4$ \\ \bottomrule