# overline command in math mode with verbatim

Does anyone know how to get something like \overline{\verb!signal!} to work? I cannot seem to figure out how to get \overline to understand a verbatim command.

• Welcome to TeX.SX! Do you really need \verb? – egreg Feb 18 at 18:24
• Does \overline{\mathtt{signal}} work for you? What effect are you trying to achieve? – Davislor Feb 18 at 18:24
• Unless you use trickery, verbatim cannot be used as arguments to other commands. Please give some background on what this is supposed to be used for. – daleif Feb 18 at 18:26
• Tried \mathtt and it didn't work. I am trying to make the font within the \overline{ } to be using the verbatim font. Perhaps, there's a better way of doing it, but right now it only works if you remove \verb!signal! – stineje Feb 18 at 18:29
• You can obviously do this: \begin{eqnarray*} \verb!signal! = a \cdot b \end{eqnarray*}. But, once you put in \verb within an \overline, it doesn't work. For example, \begin{eqnarray*} \verb!signal! = a \cdot \overline{\verb!b!} \end{eqnarray*}. Perhaps, I am just doing this so convoluted. – stineje Feb 18 at 18:29

Not something I would do in my document, but here it is:

\documentclass{article}

\makeatletter
\newcommand{\textoverline}{\afterassignment\text@verline\let\next= }
\def\text@verline{%
\setbox\z@=\hbox\bgroup\aftergroup\finishtext@verline
}
\def\finishtext@verline{$\overline{\box\z@}$}
\makeatother

\begin{document}

\textoverline{\verb!abc{dd{\x!}

\end{document}


Don't use this in the argument to another command.

If you just need the typewriter font and no special characters, you can do it in a much simpler way:

\documentclass{article}

\newcommand{\overlinett}[1]{%
\ensuremath{\overline{\texttt{#1}}}%
}

\begin{document}

\overlinett{signal}

\end{document}


• Thank you!!!!! That worked. Interestingly, it didn't work if I had \overlinett{test_signal} unless I did \overlinett{test_signal}, but since its a typewriter font, this makes sense with the _. Thanks again so much!!!! – stineje Feb 18 at 18:41
• @stineje if this answer solved your problem you could accept it as best answer, so other people can find it easily. – manooooh Feb 19 at 18:55
\documentclass{article}
\usepackage{verbatimbox,amsmath}
\begin{document}
\begin{verbbox}signal\end{verbbox}
$\overline{\theverbbox}$
\end{document}