[Tex/LaTex] How to handle wide columns with \backslashbox

tables

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
   \backslashbox{foo}{bar} & test & header & header \\
   \hline
   relatively wide column& b & $3$ & $4$ \\
   ds & c & $1$ & $4$ \\
   \hline
  \end{tabular}
 \end{table}
\end{document}

Result:

alt text

Best Answer

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.

alt text