\overline outside of math mode

Easy answer:

\newcommand{\textoverline}[1]{$\overline{\mbox{#1}}$}

Not so easy, but neater:

\makeatletter
\newcommand*{\textoverline}[1]{$\overline{\hbox{#1}}\m@th$}
\makeatother

We use the normal \overline of math mode, exploiting the fact that a \hbox in math mode typesets its argument in the font which was current at the time the math formula starts (also keeping spaces).

The strange \m@th is a precaution against possible setting of the parameter \mathsurround, a space added before and after in-line math formulas; it's usually zero, but a class might change it. When math mode is used for things like this, it's best to be on the safe side: \m@th sets the parameter to zero, but since a math formula forms a group, the setting is local and won't change the global one.


The basic answer to your question is that you can use the \overline{} command from math mode for text, too, if you combine it with \mbox{} command. The \mbox{} command lets you shift out of math mode while being in math mode. So try this:

\documentclass{article}
\begin{document}
$\overline{\mbox{This is under a line}}$ but this isn't.
\end{document}

Your question was essentially answered by egreg but there wasn't much explanation and this is a little too long to put as a comment.


If you want to have line breaks in the text you can use the soul package:

\documentclass{article}
\usepackage{soul}

\newcommand\ol[1]{{\setul{-0.9em}{}\ul{#1}}}

\begin{document}
\ol{This is under a line.}

\Huge\ol{This is under a line.}
\end{document}

The disadvantage of this approach is that the line height does not depend on the height of the content (so capital letters with accents will be problematic). It does scale with font size though.