How to Color Only a Table Cell in LaTeX

Includes PGF, TikZ, PSTricks, and platforms/distributions: Kile, TeXstudio, TeXmaker, TeXnicCenter, MiKTeX, LyX
Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

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
Attachments
latex_cell_coloring.png
(9.04 KiB) Not downloaded yet
latex_cell_coloring.png
(9.04 KiB) Not downloaded yet
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply

Return to “LaTeX and MathJax”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests