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 agree to our terms of service, privacy policy and cookie policy

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