6

I am using the slashbox package in a table as shown next. However as you can see, the diagonal line in the first cell is not the real diagonal of that cell. This is because of the existence of more than a row in that cell. So how to make the diagonal line reach from the top left corner to the bottom right corner of the first cell to the left?

enter image description here

Here is my code:

\documentclass[12pt]{article}
\usepackage{slashbox}

\begin{document}

\begin{table}[htbp]
\begin{center}
\begin{tabular}[htp]{||l|c|c|c|c||}
\hline
\backslashbox{Adult}{Motion types}
& can definitely & \multicolumn{2}{c|}{can definitely } & can definitely\\
person
& walk & \multicolumn{2}{c|}{jump} & run\\
\cline {3-4}
& & more than
& more than & \\
& & 10 cm
& 20 cm & \\[4mm]
\hline \hline
Joe & Yes & No & No & No \\[4mm]
\hline
\end{tabular}
\end{center}
\end{table}

\end{document}

Thank you.

5

To get a cell spanning several rows, you can use the multirow package. \backslashbox works well with this within its implemantion limits - the slash is constructed as a LaTeX picture, and so there are only a limited number of slopes for the line allowed.

Sample output

\documentclass[12pt]{article}

\usepackage{slashbox,multirow}

\begin{document}

\begin{table}[htbp]
\begin{center}
\begin{tabular}[htp]{||l|c|c|c|c||}
\hline
\multirow{4}{*}{\backslashbox{Adult\\\strut person}{\strut Motion\\ types}}
& can definitely & \multicolumn{2}{c|}{can definitely } & can definitely\\
& walk & \multicolumn{2}{c|}{jump} & run\\
\cline {3-4} & & more than & more than & \\
& & 10 cm & 20 cm &\\
\hline \hline
Joe & Yes & No & No & No \\
Margaret & Yes & Yes & Yes & Yes \\
\hline
\end{tabular}
\end{center}
\end{table}

\end{document}

A more sophisticated solution with, more flexible choices of slash line, would use something like tikz, see Diagonal lines in table cell for some such approaches, but would still require such a \multirow command.

  • @ Andrew Swann Thank you very much. It works fine. I need a \backslashbox[50mm]{...} for example if I have longer words in the first cell. 1 vote up. – yCalleecharan May 14 '13 at 7:54

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.