colortbl
Enables the application of custom colors to table elements, including rows, columns, and individual cells in tabular environments.
Overview
Enhances the visual presentation and readability of LaTeX tables by providing comprehensive color customization capabilities. The package seamlessly integrates with standard tabular environments and other table-related packages.
- Supports coloring entire rows or columns for visual grouping and emphasis
- Allows precise control over individual cell colors for highlighting specific data points
- Compatible with both standard LaTeX tables and more complex table packages
- Commonly used in academic publications, technical documentation, and business reports where visual distinction within tables is important
- Particularly useful for creating heat maps, data visualization tables, and professional-looking financial reports
Getting Started
To use colortbl
, include it in your document preamble:
\documentclass{article}
\usepackage{color} % Required dependency
\usepackage{colortbl}
Examples
Creating a professional-looking financial table with alternating row colors.
\documentclass{article}
\usepackage{colortbl}
\usepackage{xcolor}
\begin{document}
\begin{center}
\large{Quarterly Financial Report}
\end{center}
\begin{tabular}{|l|r|r|r|}
\hline
\rowcolor{blue!40} Quarter & Revenue & Expenses & Profit \\
\hline
\rowcolor{gray!10} Q1 & \$10,000 & \$7,500 & \$2,500 \\
\hline
Q2 & \$12,500 & \$8,000 & \$4,500 \\
\hline
\rowcolor{gray!10} Q3 & \$15,000 & \$9,000 & \$6,000 \\
\hline
Q4 & \$18,000 & \$10,500 & \$7,500 \\
\hline
\rowcolor{yellow!20} Total & \$55,500 & \$35,000 & \$20,500 \\
\hline
\end{tabular}
\end{document}
Creating a color-coded schedule or timetable.
\documentclass{article}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{array}
\begin{document}
\begin{center}
\large{Weekly Schedule}
\end{center}
\begin{tabular}{|l|>{}p{2.5cm}|>{}p{2.5cm}|>{}p{2.5cm}|}
\hline
\rowcolor{gray!50} Time & Monday & Wednesday & Friday \\
\hline
9:00--10:30 & \cellcolor{red!25}Mathematics & \cellcolor{red!25}Mathematics & \cellcolor{red!25}Mathematics \\
\hline
11:00--12:30 & \cellcolor{blue!25}Physics & \cellcolor{green!25}Chemistry & \cellcolor{blue!25}Physics \\
\hline
14:00--15:30 & \cellcolor{yellow!25}English & \cellcolor{purple!25}History & \cellcolor{orange!25}Computer Science \\
\hline
\end{tabular}
\end{document}