1

I have multiple tables in a document using xcolor's \cellcolor command but it offsets the text by a small amount so it is not centered correctly. \rowcolor does not exhibit the same behaviour. It looks as it does here:

4 row table showing cell 2 offset to the right by the \cellcolor command

Does anyone know why this is and how it might be solved globally?

\documentclass{article}

\usepackage[table]{xcolor}

\begin{document}

\begin{tabular}{|c|}
                          Centred \\ \hline
        \cellcolor{white} Centred \\ \hline
                          Centred \\ \hline
        \rowcolor{white}  Centred
\end{tabular}

\end{document}

1 Answer 1

0

Without the space between \cellcolor and the following text, the alignment is as expected:

enter image description here

\documentclass{article}

\usepackage[table]{xcolor}

\begin{document}

\begin{tabular}{|c|}
                          Centred \\ \hline
        \cellcolor{white}Centred \\ \hline
                          Centred \\ \hline
        \rowcolor{white}  Centred
\end{tabular}

\end{document}
1
  • This has been giving me a headache for a while and it's an extra space causing it. Hahaha. Thank you very much. Apr 30, 2020 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .