How to Color Only a Table Cell in LaTeX
Posted: Wed Feb 27, 2019 1:18 pm
Here below is an example showing how to color only a specific cell using xcolor's LaTeX table option. xcolor loads the colortbl package which allows rows and columns to be coloured, apart from individual cells. Color names are followed by ! without space, and a number (e.g., green! 35) determines the respective color intensity.
You can use booktabs for attractive, high quality optimized LaTeX tables.
From an example above, the output table should look as shown below:
- \documentclass{article}
- \usepackage[table]{xcolor}
- \begin{document}
- \begin{tabular}{|l|c|r|}
- \hline
- \cellcolor{red!15} Welcome & \cellcolor{magenta!35} to Open & \cellcolor{gray!25} Discussion Forums \\
- \hline
- \end{tabular}
- \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: