Sunday, 2 June 2013

Clashing multirow with tikz

Clashing multirow with tikz

In order to get a diagonal line in a cell, I picked up a piece of code from here.
The code adapted to my situation works fine until I decide to use multirow.
Here is the MWE.
\documentclass{article}

\usepackage{multirow}

\usepackage{tikz}
\newcommand\diag[4]{%
  \multicolumn{1}{p{#2}|}{\hskip-\tabcolsep
  $\vcenter{\begin{tikzpicture}[baseline=0,anchor=south west,inner sep=#1]
  \path[use as bounding box] (0,0) rectangle (#2+2\tabcolsep,\baselineskip);
  \node[minimum width={#2+2\tabcolsep},minimum height=\baselineskip+\extrarowheight] (box) {};
  \draw (box.north west) -- (box.south east);
  \node[anchor=south west] at (box.south west) {#3};
  \node[anchor=north east] at (box.north east) {#4};
 \end{tikzpicture}}$\hskip-\tabcolsep}}

\begin{document}

  \begin{tabular}[t]{|c|c|c|}
    \hline
    \multirow{2}{*}{\diag{.1em}{.5cm}{$a$}{$i$}}&\multicolumn{2}{c|}{A}\\\cline{2-2}
    &1\\
  \end{tabular}


\end{document}
This produces an error message,
! Misplaced \omit. \multispan ->\omit \@multispan l.20 ...ultirow{2}{*}{\diag{.1em}{.5cm}{$a$}{$i$}} &\multicolumn{2}{c|}{A}\...
If I omit the \multirow part this works fine.
Appreciate any help.

No comments:

Post a Comment