1

I want to have a diagonal line from the top left hand corner to the bottom right hand corner of the first cell of my table.

So I want it to look something like the left table:

enter image description here

By just plainly using \diagbox or \backslashbox the diagonal line does however not go through the entire cell. And it only looks like the table under "basic".

If I attempt to correct this by using the height option the height of the complete row is changed and I don't know how to avoid that.

Now of course I am not the first one to ask such a question. But the answers to similar questions like

Diagonal line in table with vertical text

or

Diagonal line in table header when header is tall

one just produce the same problem as setting the height.

Here is my code as a MWE:

\documentclass[12pt, a4paper, twoside]{article}
\usepackage{diagbox}
\usepackage{slashbox}
\usepackage{rotating}

\begin{document}

    % basic table
    \begin{tabular}{c|c}
        R\textbackslash PF & 
        \begin{turn}{-90}PF 333 \space\end{turn} \\
        \hline
        R1 \\
    \end{tabular}

    \vspace{1cm}

    % simple diagonal line
    \begin{tabular}{c|c}
        \diagbox{R}{PF} &
        %\backslashbox{R}{PF} &
        \begin{turn}{-90}PF 333 \space\end{turn} \\
        \hline
        R1 \\
    \end{tabular}

    \vspace{1cm}

    % using height option
    \begin{tabular}{c|c}
        \diagbox[height=3cm]{R}{PF} &
        \begin{turn}{-90}PF 333 \space\end{turn} \\
        \hline
        R1 \\
    \end{tabular}

\end{document}

I would be very glad if someone knew and would let me know how to fix this. (sorry about the strange image and absent links but I do not have the reputation to post more)

1

Is this what you want?

\documentclass[12pt, a4paper, twoside, pdftex]{article}
\usepackage{diagbox}
\usepackage{graphicx}

\begin{document}

% using height option
\begin{tabular}{|c|c|}
  \hline
  \diagbox[height=8ex, width=4em]{\raisebox{0.5\height}{\enspace R}}{ \raisebox{-0.8\height}{\ PF}} &
  \rotatebox[origin =c]{-90}{\,PF 333} \\
  \hline
  R1 \\
\end{tabular}

\end{document} 

enter image description here

  • Thanks, it worked! While for me it does not matter whether I use turn or \rotatebox is there some (general) advantage to using \rotatebox ? – user3202098 Aug 15 '16 at 14:59
  • With \rotatebox you can specify the centre of rotation. – Bernard Aug 15 '16 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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