2

Are there any decent alternatives to xcolor if I want to colour cells in a table? I want to highlight certain cells depending on my data, but not entire rows or columns.

I'm using Knitr and am having consistent problems with xcolor when I use the chunk option dev=tikz so would rather just avoid xcolor altogether.

Any suggestions appreciated.

1
  • 1
    xcolor doesn't really colour tables, it just includes colortbl if you use the table option, so you can use colortbl and the standard color package (although I don't understand your comment about xcolor) Commented Jun 27, 2014 at 8:45

1 Answer 1

4

You don't have to use xcolor to color cells of a table. Just load the package colortbl.

\documentclass{article}

\usepackage{colortbl} %use in the preamble

\begin{document}

\begin{table}[h]
\begin{tabular}{|c|c|c|}\hline
H1           & H2       & H3 \\\hline
\cellcolor{red} I am colored & I am not & \cellcolor{green} I too am\\\hline
\end{tabular}
\end{table}

\end{document}
2
  • How do you automatically colour all cells on the third column containing negative numbers?
    – skan
    Commented Mar 31, 2016 at 20:28
  • 1
    @skan Dated, but see if this addresses the column color matter. Commented Oct 11, 2018 at 21:17

You must log in to answer this question.

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