0

The following code works well:

\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
  \rowcolors{2}{gray!25}{white}
  \begin{tabular}{cc}
    \rowcolor{gray!50}
    Table head & Table head\\
    Some values & Some values\\
    Some values & Some values\\
  \end{tabular}
\end{document}

However, when trying to remove the space before/after the first/last column or set it to different length, I get this error:

Use of @startpbox doesn't match its definition. \begin{tabular}{@{}cc@{1mm}}

for

\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
  \rowcolors{2}{gray!25}{white}
  \begin{tabular}{@{}cc@{1mm}}
    \rowcolor{gray!50}
    Table head & Table head\\
    Some values & Some values\\
    Some values & Some values\\
  \end{tabular}
\end{document}

Knowing that I have updated all the packages before running this test.

  • Your example compiles without error for me. Show your log-file. – Ulrike Fischer Mar 31 at 20:01
  • @UlrikeFischer You can find it here – Diaa Mar 31 at 20:37
  • Your colortbl is outdated. Check for updates in user mode. – Ulrike Fischer Mar 31 at 20:40
  • @UlrikeFischer You got it. However, I wonder why updating in Admin mode doesn't make it right. – Diaa Mar 31 at 20:57
  • 2
    the admin mode can't update your user packages. So always check for updates in both modes. – Ulrike Fischer Mar 31 at 21:00
2

With the correct code for the final spacing, it works:

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

\begin{document}
{\setlength{\tabcolsep}{0pt}%
\rowcolors{2}{gray!25}{white}
\begin{tabular}{c<{\hspace{12pt}}c<{\hspace{1mm}}}
\rowcolor{gray!50} Table head &Table head\\
Some values & Some values\\
Some values & Tome values\\
 \end{tabular}}

 \end{document} 

enter image description here

  • Thanks for pointing this out. But, may I know why the is the space before the first column still there? – Diaa Mar 31 at 19:49
  • Oh! I forgot the other side. It's a problem with the overhang. I'll update my answer in a moment. – Bernard Mar 31 at 19:53
  • @Diaa: I've updated my answer. I had to take another approach for the colour overhang problem. – Bernard Mar 31 at 20:19
  • 1
    By calculations: the default value of \tabcolsep is 6pt, and there are two of them between two columns (with the vertical rule, if any, in the middle). – Bernard Mar 31 at 21:03

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.