3

I am trying to create a table with colored rows and colored hrules between the rows, but I am getting a "Misplaced \noalign. \rowcolor" error.

The following example reproduces this problem:

\documentclass{article}

\usepackage{color, colortbl}

\begin{document}
  \begin{tabular}{l}
                    x \\ \noalign{\color{red}\hrule height 1pt}
    \rowcolor{blue} x
  \end{tabular}
\end{document}

The error disappears if I either remove the \noalign{...} or the \rowcolor.

How can I use both (or get the same result in a different way)?

8

You need to keep the colour restore within the noalign so need {} but colortbl allows you to colour \hline, so do you need this?

\documentclass{article}

\usepackage{color, colortbl}

\begin{document}
  \begin{tabular}{l}
                    x \\ \noalign{{\color{red}\hrule height 1pt}}
    \rowcolor{blue} x
  \end{tabular}
\end{document}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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