# Undefined control sequence with \green and \red

The following is table.tex:

\documentclass{article}
\usepackage{color}
\begin{document}
\pagestyle{empty}
\begin{tabular}{ l | r }
Problem & Expansions \\
\hline
{\green Unit} Grid & \green 382,536 \\
{\red Life} Grid & \red 994,437 \\
\hline
{\green Unit} Pancake & \green 69 \\
{\red Sum} Pancake & \red 3,711 \\
\end{tabular}
\end{document}


When I do:

latex table


I get this error:

! Undefined control sequence.
l.14       {\green
Unit} Grid & \green 382,536 \


I get similar errors for the other uses of \red and \green. Doing \usepackage{color} with \red and \green works with other documents, I don't understand why it doesn't work in this context.

• You need to use \color{green} or \textcolor{green}{<green text>}. – Martin Heller Jul 8 '13 at 19:52

\begin{document}
\pagestyle{empty}
\begin{tabular}{ l | r }
Problem & Expansions \\
\hline
{\color{green} Unit} Grid & {\color{green} 382,536} \\
{\color{red} Life} Grid & {\color{red} 994,437} \\
\hline
{\color{green} Unit} Pancake & {\color{green} 69} \\
{\color{red} Sum} Pancake & {\color{red} 3,711} \\
\end{tabular}
\end{document}


This how you need to define the color changes with the color package. Here is a link to the wiki reference https://en.wikibooks.org/wiki/LaTeX/Colors

Per egreg's suggestions,

\begin{document}
\pagestyle{empty}
\begin{tabular}{ l | r }
Problem & Expansions \\
\hline
\textcolor{green}{Unit} Grid & \textcolor{green}{382,536} \\
\textcolor{red}{Life} Grid & \textcolor{red}{994,437} \\
\hline
\textcolor{green}{Unit} Pancake & \textcolor{green}{69} \\
\textcolor{red}{Sum} Pancake & \textcolor{red}{3,711} \\
\end{tabular}
\end{document}

• Also \textcolor{green}{Unit}, which seems more apt for this case, requiring no outer braces. – egreg Jul 8 '13 at 20:03
• Thank you for the answer to how to get it to work correctly. I think the reason it worked elsewhere is it was within a powerdot presentation, which apparently allows \green and \red. – user24544 Jul 8 '13 at 20:24