Page 1 of 1

How to Color Only a Table Cell in LaTeX

Posted: Wed Feb 27, 2019 1:18 pm
by Eli
Here below is an example showing how to color only a specific cell using xcolor's LaTeX table option. xcolor loads the colortbl pack­age which al­lows rows and columns to be coloured, apart from in­di­vid­ual cells. Color names are followed by ! without space, and a number (e.g., green! 35) determines the respective color intensity.

  1. \documentclass{article}
  2. \usepackage[table]{xcolor}
  3. \begin{document}
  4. \begin{tabular}{|l|c|r|}
  5.  \hline
  6.  \cellcolor{red!15} Welcome  & \cellcolor{magenta!35} to Open  & \cellcolor{gray!25} Discussion Forums \\
  7.  \hline
  8. \end{tabular}
  9. \end{document}


You can use booktabs for attractive, high quality optimized LaTeX tables.

From an example above, the output table should look as shown below:
Image