Is there a way to color text in an entire table without using environment tabular? For example, change the color of text in every cell to red.
Asked
Active
Viewed 6.7k times
17
-
Which tabular-like environmet(s) do you use? – Mico May 24 '15 at 06:44
-
I use tabular environment. – cerebrou May 24 '15 at 06:45
3 Answers
20
Just use
{\color{red}\begin{tabular}{cc}
a&b\\
1&2
\end{tabular}}
and the table will be red.
David Carlisle
- 757,742
15
Do you thing on something like this:

\documentclass{standalone}
\usepackage[table]{xcolor}
\begin{document}
\begin{tabular}{>{\color{red}}c >{\color{red}}c}
\hline
A & B \\
C & D \\
\hline
\end{tabular}
\end{document}
If you wish in red (or other selected color) entire table (with lines), than before table just put command \color{red}
Zarko
- 296,517
2
Previous posts work for coloring individual columns or whole table contexts in latex. But while using this code for any latex template of a journal you have to write the package \usepackage[table]{xcolor} just next to the \documentclass{standalone}, otherwise, the code will not work. for e.g.
\documentclass[review]{elsarticle}
\usepackage[table]{xcolor}
\usepackage{amssymb,amsmath}
\usepackage{url}
Again for coloring individual texts of a table, you can use
\begin{tabular}{l l }
\toprule
1 & \textcolor{blue}{Water} \\
2 & Hippo grass \\
\bottomrule
\end{tabular}
Leucippus
- 1,636
-
1But the question is about not have to set the color in every cell ... With respect to
xcolorpackage, sometimes is not needed, because it is already loaded by the document class or another package, and in this case you do not need the [table] option . Also, although sometimes the order of the packages matter, usually it must be simply in any place of preamble, no just under the\documentclassline. – Fran Nov 01 '19 at 07:39 -