2

Considering the answer of question, I used the slashbox package to draw a diagonal line. But the problem is I have multiple rows in my table and that makes the line not aligned well within the cell corners. It also gives wierd spaces between cells:

\documentclass{article}
\usepackage{slashbox}
\usepackage{adjustbox}

\begin{document}


\begin{table}[!htpc]
\begin{center}
  \centering
  \caption{some table.}
  \label{possibility}
  \begin{footnotesize}

   \adjustbox{max height=\dimexpr\textheight-5.5cm\relax,
           max width=\textwidth}{
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}

  \hline
  % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
  &first  & first  & second  & second & both  & both  & &\\
  &key & key &  key &  key& key & key & none&all\\
\backslashbox{Room}{Date}  &at & at &  at &  at & at & at& & \\
   &d & p &  d & p & d & p & &\\ \hline
  $C_1$&Y & N & N & N & N & N & N &N \\ \hline

  \hline


\end{tabular}
}
\end{footnotesize}
\end{center}
\end{table}

\end{document} 

EDIT

I have used the answer presented by @bernard but it gives me ! Use of \line doesn't match its definition as an error. Not sure if it would happen for others as well.

2

It's better to use diagbox, which is more powerful. I improved your table using makecell (allows for line breaks and vertical padding in cells). Also, don't use the center environment in tables, as it adds unwanted vertical spacing; use \centering instead. The placement of the diagonal line is adjusted through the optional argument of \multirow.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{diagbox}
\usepackage{adjustbox}
\usepackage{caption, multirow, makecell}
\setcellgapes{3pt}

\begin{document}

\begin{table}[!htp]
  \centering
  \caption{some table.}
  \label{possibility}
  \footnotesize\makegapedcells
   \adjustbox{max height=\dimexpr\textheight-5.5cm\relax,
   max width=\textwidth}{
  \begin{tabular}{|*{9}{c|}}
    \hline
    \multirowcell{5.2}[2.3ex]{\diagbox[height=5.17\line]{\rlap{\enspace\raisebox{2ex}{Room}}}{\raisebox{-3.5ex}{Date}}} &\makecell{first\\key} & \makecell{first\\key} & \makecell{second\\key} & \makecell{second\\key} & \makecell{both\\keys} & \makecell{both\\keys}& none&all\\
          & at & at & at & at & at & at & & \\
          & d & p & d & p & d & p & & \\ \hline
    $C₁$ & Y & N & N & N & N & N & N & N \\
    \hline
  \end{tabular}
  }
\end{table}

\end{document} 

enter image description here

  • Always vote +1 for my friends. – Sebastiano May 16 '17 at 9:02
  • Why did you comment out the adjustbox? – lonesome May 16 '17 at 9:43
  • @lonesome: Sorry. I did it to see whether the table overflowed the prescribed dimensions, and I forgot to uncomment before posting. – Bernard May 16 '17 at 9:50
  • It also gives error as ! Use of \line doesn't match its definition. – lonesome May 16 '17 at 9:50
  • I asked about adjustbox just in case if it was a wrong choice. – lonesome May 16 '17 at 9:51

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.