[Tex/LaTex] How to write under an underline

text-decorations

I would like to be able to write under the underline. Is it possible?

enter image description here

This is the simple code I have:

\documentclass{article}
\begin{document}
$\frac{ \textrm{Text}}{1} \frac{\textrm{Text}}{2} \frac{\textrm{Text}}{3}$
\end{document}

It does the job but I want to be able to make the texts under underlines smaller. One way to do so is to adjust the font each time. Is it an easier way? Or is there any built-in function for this. To assign the size which would be the same as the size for subscript.

Best Answer

It's always a good idea to write repetitive things in a macro:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newcommand{\underwrite}[3][]{% \underwrite[<thickness>]{<numerator>}{<denominator>}
  \genfrac{}{}{#1}{}{\textstyle #2}{\scriptstyle #3}
}
\begin{document}

See $\underwrite{\text{Text}}{1}\ 
  \underwrite{\text{Text}}{2}\ 
  \underwrite[2pt]{\text{Text}}{3}$.

\end{document}

The above MWE uses amsmath's \genfrac to create a fraction with \textstyle numerator and \scriptstyle denominator. You can, of course, add other functionality to it (like detecting the mode it's in and adjusting the size accordingly, say). Using \genfrac has the advantage of setting the fraction rule thickness; provided as an optional argument when using \underwrite[<thickness>]{<numerator>}{<denominator>}.

As reference, see section 4.11.3 The \genfrac command (p 14) in the amsmath documentation.