[Tex/LaTex] Diagonal line in table header when header is tall

diagboxtables

I've been trying to get a diagonally-split table header using the diagbox package, but I have a problem.

Here's a working sample that shows the problem:

    \documentclass[12pt, a4paper, twoside]{article}


\usepackage{diagbox} %table split headers
\usepackage{longtable} 
\usepackage{array}
\usepackage{rotating}

\newcommand{\tabred}{-4pt}
\newcommand*\rot{\rotatebox{90}}

\begin{document}

\begin{longtable}{
    | l<{\hspace{\tabred}} 
    | >{\hspace{\tabred}}c<{\hspace{\tabred}} 
    | >{\hspace{\tabred}}c<{\hspace{\tabred}} 
    | >{\hspace{\tabred}}c<{\hspace{\tabred}} 
    | >{\hspace{\tabred}}c<{\hspace{\tabred}} 
    | >{\hspace{\tabred}}c<{\hspace{\tabred}} 
    | >{\hspace{\tabred}}c<{\hspace{\tabred}}
    |}

\hline

\diagbox[dir=NW]{Feature}{Tool}  & %THIS IS THE PROBLEM!

\rot{Tool Alpha}    & 
\rot{Tool Delta}    & 
\rot{Tool Gamma}    & 
\rot{Tool Theta} & 
\rot{Tool Upsilon} & 
\rot{\textbf{Tool X (our proposal) }}\\

%\midrule
\hline

Feature A - Fooing the Bar  & NO    & NO    & NO    & NO    & OK    & OK\\
Feature B - Barring the Foo & OK    & NO    & OK    & NO    & NO    & OK\\
\hline
\end{longtable}

\end{document}

The problem is that, since I rotate the headers, they are very tall. As you can see from the image below, this ruins the alignment of the diagonal line:

enter image description here

As you can see, there are two problems: the north-west end of the diagonal line doesn't touch the north-west corner of the box, and the south-east end of the diagonal line doesn't touch the south-east corner.

With the answer posted here: https://tex.stackexchange.com/a/215370/45766 I've been able to use \rule to fix one of the angles, but never both. No matter what I try, the spacing screws up.

Any ideas?

Best Answer

I propose to make the last rotated header two-lined. This is possible with the \rothead and \rotcell commands from makecell * also use the keys height= and width= from diagbox. The width is set with the help of te eqparbox package, with eqboxwidth length. Finally I replaced your \tabred command with changing the value off \tabcolsep.

\documentclass[12pt, a4paper, twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage{diagbox} %table split headers
\usepackage{longtable}
\usepackage{array}
\usepackage{rotating}
\usepackage{eqparbox}
\usepackage{makecell, caption, booktabs}

\begin{document}

\centering\settowidth\rotheadsize{\bfseries(our proposal)}
\renewcommand\theadalign{cl}\renewcommand\cellalign{cl}
\renewcommand\theadfont{\bfseries}
\renewcommand\tabcolsep{4pt}\renewcommand\arraystretch{1.25}
\begin{longtable}{
    |l |*{6}{c |} }%
    \hline
    \diagbox[height=1.2\rotheadsize, width=\dimexpr\eqboxwidth{AB}+2\tabcolsep\relax]%
    {\raisebox{1.5ex}{Feature}}{\raisebox{-5ex}{Tool}} & %THIS IS THE PROBLEM!
    \rotcell{Tool Alpha} &
    \rotcell{Tool Delta} &
    \rotcell{Tool Gamma} &
    \rotcell{Tool Theta} &
    \rotcell{Tool Upsilon} &
    \rothead{Tool X\\\mbox{(our proposal)}}\\
    \hline
    \eqmakebox[AB][l]{Feature A – Fooing the Bar} & NO & NO & NO & NO & OK & OK \\
    \eqmakebox[AB]{Feature B – Barring the Foo} & OK & NO & OK & NO & NO & OK \\
    \hline
  \end{longtable}

\end{document} 

enter image description here