I am trying to use this solution which uses tikz, however I cannot get it to compile properly. I get the error:
Misplaced \omit. ...llcolor[HTML]{EFEFEF}\diag{0.2em}{1cm}{a}{b}
Searching for that led me to this other question, but as far as I can tell it is not related since \diag does not have an optional argument.
What is causing the error/how can I prevent it from happening?
Apologies for the lengthy preamble, but since I'm at a complete loss, I want to ensure that this MWE uses the exact same packages and settings as I do in my actual document.
(Pseudo)MWE
\PassOptionsToPackage{table,cxdraw}{xcolor}
\documentclass[draft]{book}
\usepackage[numbers,sort&compress]{natbib}
\usepackage[protrusion=true,expansion,babel=true]{microtype}
\usepackage{mathtools} % This includes "amsmath" and the dcases environment among other things
\usepackage{dsfont}
\usepackage{tikz}
\usepackage[ngerman,english]{babel}
% For tables:
\newcolumntype{x}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}
\usepackage{booktabs}
\usepackage{multirow}
% For listings and source code
%\usepackage{algorithm2e}
\usepackage{listings}
\lstset{%
basicstyle=\footnotesize,
showstringspaces=false,
numbers=left,
numberstyle=\tiny,
stepnumber=1,
captionpos=b,
language=Java,
frame=lines
}
%% ---------------- end of usepackages -------------------------
\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-\pgflinewidth},
minimum height=\baselineskip+\extrarowheight-\pgflinewidth] (box) {};
\draw[line cap=round] (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
}
}
\newcommand{\e}[1]{\ensuremath{\left\langle#1\right\rangle}}
%%----------------- end of preamble ----------------------------
\begin{document}
\begin{tabular}{@{}
>{\columncolor[HTML]{EFEFEF}}c
>{\columncolor[HTML]{EFEFEF}}c
>{\columncolor[HTML]{EFEFEF}}c
xcccc@{}}
$\kappa(0)$ & $\kappa(0)$ & \cellcolor[HTML]{EFEFEF}\diag{0.2em}{1cm}{a}{b} & \cellcolor[HTML]{EFEFEF}$i\mod{p} = 0$ & \cellcolor[HTML]{EFEFEF}$i\mod{p}=1$ & \cellcolor[HTML]{EFEFEF}$i\mod{p}=3$ & \cellcolor[HTML]{EFEFEF}$i\mod{p}=3$ \\
0 & 0 & 2 & $\e{0}\e{1}$ & $\e{1}\e{0}$ & - & - \\
0 & 1 & & & & & \\
1 & 0 & \multirow{-2}{*}{3} & \multirow{-2}{*}{$\e{0}\e{1}$}& \multirow{-2}{*}{$\e{1}\e{\kappa(1)}$}& \multirow{-2}{*}{$\e{\kappa(1)}\e{0}$}& \multirow{-2}{*}{-} \\
1 & 1 & 4 & $\e{01}$ & $\e{1}\e{1}$ & $\e{1}\e{0}$ & $\e{0}\e{0}$
\end{tabular}
\end{document}
! Package array Error: Illegal pream-token ("): 'c' used.-- will try again after minimizing the code. – Mike Renfro May 26 '15 at 13:12\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}in the preamble... – MaxAxeHax May 26 '15 at 13:23\diagcommand entirely and use thediagboxpackage. – Mike Renfro May 26 '15 at 13:23"? It is probably clashing with thengermanoption of babel which makes it an active letter (like~), maybe evenenglishor babel itself. – Qrrbrbirlbel May 26 '15 at 13:49