Possible Duplicate:
Diagonal lines in table cell

How can I put an inclined line between two cells in a table? I know that \cline{i-j} put a partial horizontal line, but I want that this line is inclined... Can somebody help me?

  • Can you please describe in more detail what you mean with "inclined"? Should the line go from the upper corner of a cell to the bottom opposite corner of the same cell, or should it cross several cells? – Gonzalo Medina Jun 14 '11 at 21:16
  • Yes, thank you for the fast response. The line should go from the upper corner of a cell to the bottom opposite corner and I wanted to write things in both sides of the cell. – Flávio Marchesini Jun 14 '11 at 21:20

There is a slashbox package (not included in TeX Live2010) to draw diagonal lines in a matrix cell; however, the results obtained with this package are rather poor (see example below). Another option would be to use TikZ and a matrix of nodes. In the following example I show both approaches: one example taken from slashbox.tex and the other one built with the help of TikZ:



Meeting Room &&&&&\\\hline
Auditorium &&&&&\\\hline
Seminar Room &&&&&\\\hline


% the matrix
\matrix [matrix of nodes,text height=8pt,text depth=2pt,text width=0.5cm,nodes={align=center}] (mat)
a & b & c \\
d & e & f \\
g & h & i \\
j & k & l \\
% the horizontal lines
\foreach \i in {1,2,3,4}
  \draw (mat-\i-1.north west) -- (mat-\i-3.north east);
\draw (mat-4-1.south west) -- (mat-4-3.south east);
% the vertical lines
\foreach \i in {1,2,3}
  \draw (mat-1-\i.north west) -- (mat-4-\i.south west);
\draw (mat-1-3.north east) -- (mat-4-3.south east);
% the diagonal lines
\draw (mat-1-1.north west) -- (mat-1-1.south east);
\draw (mat-3-3.north west) -- (mat-3-3.south east);


| improve this answer | |

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