Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In order to get a diagonal line in a cell, I picked up a piece of code from Diagonal lines in table cell

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.

share|improve this question
    
Use of diagbox was found to be a better option. This also did not clash with multirow. –  Masroor Jun 3 '13 at 7:39
    
The problem here lies in using a multicolumn inside a multirow. This asks for all kinds of problems, prompting the "Misplaced \omit" error. –  Heinrich Jul 30 '13 at 13:49

1 Answer 1

up vote 4 down vote accepted

enter image description here

As noted in comments you can't use \multicolumn here however as it is only spanning 1 cell, you don't need \multicolum and can simply use a \parbox.

The picture was generating a 12pt overfull box warning as 2\tabcolsep was accounted for twice so I removed the inner addition of this ammount.

The A was in a multicolumn{2} so I put the 1 in to match, otherwise things didn't line up.

The code needed array package adding as you'd used \extrarowheight which is defined by that package.

\documentclass{article}

\usepackage{multirow,array}

\usepackage{tikz}
\newcommand\diag[4]{%
%  \multicolumn{1}{p{#2}|}
  \parbox[t]{#2}%
  {\hskip-\tabcolsep
  $\vcenter{\begin{tikzpicture}[baseline=0,anchor=south west,inner sep=#1]
  \path[use as bounding box] (0,0) rectangle (#2,\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-3}
    &\multicolumn{2}{c|}{1}\\
  \end{tabular}


\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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