# Alternatingly shading rows with @{}

I want to alternately shade the rows in my table. I am aware of How to alternately shade rows in a table and similar questions. However, as my table is long and needs to be aligned very neatly in order to not be totally confusion, I make heavy use of the self-defined delimiters for cells via @{}. The formatting gets totally screwed when I try the solutions proposed elsewhere. I suppose the @{} is what trips up \rowcolors. How can I color the rows without screwing up the formatting?

A minimal example with my table is

\documentclass[a4paper]{scrartcl}

\usepackage{booktabs}
\usepackage[table]{xcolor}

\begin{document}

\rowcolors{2}{white}{gray!15} % <--- this is the solution from the other questions

\begin{center}
\toprule
& \multicolumn{7}{c}{$$SO(10)$$ }  & \multicolumn{7}{c}{$$SU(5)$$} & \multicolumn{6}{c}{$$\mathcal G_\mathrm{SM}$$} & \\
Level & \multicolumn{7}{c}{weight} & \multicolumn{6}{l}{weight} & $$\mathrm{IR}_x$$ & \multicolumn{5}{c}{weight} & $$\mathrm{IR}_Y$$ & SM state \\ \midrule
0 & (&0& 0& 0& 0& 1&) & (&0& 1& 0& 0&) & $$\mathbf{10}_1$$ &        (&1&0&1&) & $$\mathbf{3} \times \mathbf{2}_\frac{1}{6}$$&$$u_l$$\\
1 & (&0& 0& 1& 0& -1&) & (&0& 0& 0& 1&) & $$\overline{\mathbf 5}_{-3}$$ &   (&0&1&0&) & $$\overline{\mathbf{3}} \times \mathbf 1_\frac{1}{3}$$ & $$d^c_r$$\\
2 & (&0& 1& -1& 1& 0&) & (&1& -1& 1& 0&) & $$\mathbf{10}_1$$ &      (&0&1&0&) & $$\overline{\mathbf{3}} \times \mathbf 1_{-\frac{2}{3}}$$& $$u^c_r$$\\
3 & (&1& -1& 0& 1& 0&) & (&0& 0& 1& -1&) & $$\overline{\mathbf 5}_{-3}$$ &  (&0&0&1&) & $$\mathbf{1} \times \mathbf 2_{-\frac{1}{2}}$$ &$$\nu_l$$\\
3 & (&0& 1& 0& -1& 0&) & (&1& 0& -1& 1&) & $$\mathbf{10}_1$$ &      (&1&0&-1&) & $$\mathbf{3} \times \mathbf{2}_{\frac{1}{6}}$$ &$$d_l$$\\
4 & (&-1& 0& 0& 1& 0&) & (&-1& 0& 1&0&) & $$\mathbf{10}_1$$ &       (&-1&1&1&) & $$\mathbf{3} \times \mathbf{2}_{\frac{1}{6}}$$ &$$u_l$$\\
4 & (&1& -1& 1& -1& 0&) & (&0& 1& -1& 0&) & $$\overline{\mathbf 5}_{-3}$$ &     (&1&-1&0&) & $$\overline{\mathbf{3}} \times \mathbf{1}_\frac{1}{3}$$ &$$d^c_r$$\\
5 & (&-1& 0& 1& -1& 0&) & (&-1& 1& -1& 1&) & $$\mathbf{10}_1$$ &        (&0&0&0&) & $$\mathbf{1} \times \mathbf{1}_1$$ &$$e^c_r$$\\
5 & (&1& 0& -1& 0& 1&) & (&1& 0& 0& -1&) & $$\mathbf{10}_1$$ &      (&1&-1&0&) & $$\overline{\mathbf{3}} \times \mathbf{1}_{-\frac{2}{3}}$$& $$u^c_r$$\\
6 & (&-1& 1& -1& 0& 1&) & (&0& 0& 0& 0&) & $$\mathbf 1_5$$ &        (&0&0&0&) & $$\mathbf 1 \times \mathbf 1_0$$ &$$\nu_r$$\\
6 & (&1& 0& 0& 0& -1&) & (&1& -1& 0& 0&) & $$\overline{\mathbf 5}_{-3}$$ &  (&0&0&-1&) & $$\mathbf 1 \times \mathbf 2_{-\frac{1}{2}}$$ &$$e_l$$\\
7 & (&0& -1& 0& 0& 1&) & (&-1& 1& 0& -1&) & $$\mathbf{10}_1$$ &         (&0&-1&1&) & $$\mathbf 3 \times \mathbf 2_\frac{1}{6}$$ & $$u_l$$\\
7 & (&-1& 1& 0& 0& -1&) & (&0& -1& 0& 1&) & $$\mathbf{10}_1$$ &         (&-1&1&-1&) & $$\mathbf{3} \times \mathbf 2_\frac{1}{6}$$ &$$d_l$$\\
8 & (&0& -1& 1& 0& -1&) & (&-1& 0& 0& 0&) & $$\overline{\mathbf 5}_{-3}$$ &     (&-1&0&0&) & $$\overline{\mathbf{3}} \times \mathbf{1}_\frac{1}{3}$$ &$$d^c_r$$\\
9 & (&0& 0& -1& 1& 0&) & (&0& -1& 1& -1&) & $$\mathbf{10}_1$$ &         (&-1&0&0&) & $$\overline{\mathbf{3}}\times \mathbf{1}_{-\frac{2}{3}}$$ &$$u^c_r$$\\
10 & (&0& 0& 0& -1& 0&) & (&0& 0& -1& 0&) & $$\mathbf{10}_1$$ &         (&0&-1&-1&) & $$\mathbf{3} \times \mathbf 2_\frac{1}{6}$$& $$d_l$$\\
\bottomrule
\end{tabular}
\end{center}
\end{document}


Here's something that might work for you. It uses the package pgffor. I've only partially implemented it: there's a lot to rewrite in your code. But I think it achieves the effect that you want.

\documentclass[a4paper]{scrartcl}

\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage{pgffor}

\newcommand{\nnkweights}[1]{(\foreach \x in {#1} {\makebox[1.15em][r]{\x}})}
\begin{document}

\rowcolors{2}{white}{gray!15} % <--- this is the solution from the other questions

\begin{center}
\begin{tabular}    {c c  c  l c  c  c} \toprule
& {$$SO(10)$$ }  & \multicolumn{2}{c}{$$SU(5)$$}    & \multicolumn{2}{c}{$$\mathcal G_\mathrm{SM}$$} &          \\\cmidrule(rl){3-4}\cmidrule(rl){5-6}
Level & {weight}       & {weight}    & $$\mathrm{IR}_x$$  & {weight} & $$\mathrm{IR}_Y$$                   & SM state \\ \midrule
0 & \nnkweights{  0, 0, 0, 0, 1}  & \nnkweights{ 0, 1, 0, 0}  & $$\mathbf{10}_1$$             & \nnkweights{ 1, 0}\nnkweights{  1} & $$\mathbf{3} \times \mathbf{2}_\frac{1}{6}$$              & $$u_l$$  \\
1 & \nnkweights{  0, 0, 1, 0,-1}  & \nnkweights{ 0, 0, 0, 1}  & $$\overline{\mathbf 5}_{-3}$$ & \nnkweights{ 0, 1}\nnkweights{  0} & $$\overline{\mathbf{3}} \times \mathbf 1_\frac{1}{3}$$    & $$d^c_r$$\\
2 & \nnkweights{  0, 1, -1, 1, 0} & \nnkweights{ 1, -1, 1, 0} & $$\mathbf{10}_1$$             & \nnkweights{ 0, 1}\nnkweights{  0} & $$\overline{\mathbf{3}} \times \mathbf 1_{-\frac{2}{3}}$$ & $$u^c_r$$\\
3 & \nnkweights{  1, -1, 0, 1, 0} & \nnkweights{ 0, 0, 1,-1}  & $$\overline{\mathbf 5}_{-3}$$ & \nnkweights{ 0, 0}\nnkweights{  1} & $$\mathbf{1} \times \mathbf 2_{-\frac{1}{2}}$$            & $$\nu_l$$\\
3 & \nnkweights{  0, 1, 0, -1, 0} & \nnkweights{ 1, 0, -1, 1} & $$\mathbf{10}_1$$             & \nnkweights{ 1, 0}\nnkweights{ -1} & $$\mathbf{3} \times \mathbf{2}_{\frac{1}{6}}$$            & $$d_l$$  \\
\bottomrule
\end{tabular}
\end{center}

\end{document}


I'm made a few additional changes: I got rid of the \qquads and I've added some \cmidrules. I might suggest putting the content of the \makeboxes in math-mode so that the negative sign is type-set correctly, but I've not implemented that change.

Regarding \qquad, if you really want the extra space in your document, I would suggest adding a dummy column and adding the appropriate white space via \rule{<dim>}{0pt} in its first occurrence. If you're particularly finicky about the space then you can do something like \rule{\dimexpr<desired-dimension>-2\tabcolsep\relax}{0pt}. Otherwise, the alternate row shading apparently doesn't like handling @{<detail>}.

Finally, I would suggest changing

\rowcolors{2}{white}{gray!15}


to

\rowcolors{5}{white}{gray!15}


to get the coloring out of your header. The row specification seems a bit off, but that's because the \cmidrules are fooling xcolor into thinking there are extra rows added to the table.

Having done this, the result will be