# Can't color text with \textoverline

When I add \textcolor to \textoverline, I get:

Error: Undefined control sequence.

I need to use color and textoverline for the same text. It is not working with me. Here is the code:

\documentclass{article}
\newsavebox\TBox
\def\textoverline#1{\savebox\TBox{#1}%
\makebox[0pt][l]{#1}\rule[1.1\ht\TBox]{\wd\TBox}{0.4pt}}
\begin{document}

\textcolor{red} {\textoverline{foo}}

\end{document}

• In preamble you should add package color or xcolor – Zarko Mar 7 '17 at 2:23
• BTW, your definition does not allow line breaks. It is better use \usepackage{umoline} ... \Overline{foo}, imho. – Fran Mar 7 '17 at 3:08
• The undefined-control-sequence error message occurs at \textcolor, not at \textoverline. As @Zarko has noted, load a package such as xcolor. – Mico Mar 7 '17 at 6:11