2

Possible Duplicate:
colortbl: \rowcolor in tables with \begin{tabular}{@{}ccc@{}}

I'm having some trouble with table row colors. Using rowcolor in an otherwise normal tabular works fine, like so:

\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}

\begin{tabular}{l c c c}
\hline
a11 & a12 & a13 & a14 \\
\hline
b11 & b12 & b13 & b14 \\
\rowcolor{gray!25} c11 & c12 & c13 & c14 \\
d11 & d12 & d13 & d14 \\
\hline
\end{tabular}

\end{document}

With a small change to the column padding, by adding @{} to the end of the rows, I'm able to eat up the whitespace on the right side of the table. However, the gray row's length remains the same as before, so it now extends beyond the end of the table, like in this example:

\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}

\begin{tabular}{l c c c@{}}
\hline
a11 & a12 & a13 & a14 \\
\hline
b11 & b12 & b13 & b14 \\
\rowcolor{gray!25} c11 & c12 & c13 & c14 \\
d11 & d12 & d13 & d14 \\
\hline
\end{tabular}

\end{document}

Unfortunately, I am not currently allowed to post images. How can I make it so the row background color matches the width of the rest of the table in the second case?

  • Your question was migrated here from another stackexchange site. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – percusse Sep 13 '12 at 14:08

0 Answers0