Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
But do you want the underline aligned with the baseline? –  Sigur Nov 2 '13 at 17:21
    
@Sigur, I didn't quite understand what you mean but I want it to appear exactly as it appears in the example above only with a smaller size. –  Naji Nov 2 '13 at 17:22
    
Or even better with the size of a subscript. –  Naji Nov 2 '13 at 17:25
1  
@Naji, fraction is not a solution to you. –  Sigur Nov 2 '13 at 17:27
1  
this can help you tex.stackexchange.com/a/122121/14757 –  Sigur Nov 2 '13 at 17:33

3 Answers 3

up vote 4 down vote accepted

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.

share|improve this answer
1  
Considering the fact that a simple vote up is not enough for thank you I just want to add that thank you very much indeed for such a thorough answer. –  Naji Nov 2 '13 at 18:12

Do you want something like that:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
Hello \(\underbracket[0.3pt][0pt]{\textrm{my}}_{1}\) \(\underbracket[0.3pt][0pt]{\textrm{your}}_{2}\) \(\underbracket[0.3pt][0pt]{\textrm{our}}_{3}\)World!
\end{document}
share|improve this answer
    
But can't I get rid of the trouble of adding \underbracket[0.3pt][0pt] every time? Do I have to make a command? –  Naji Nov 2 '13 at 17:32
    
A command would suffice @Naji –  azetina Nov 2 '13 at 17:33
1  
For example: \newcommand{\su}[2]{\underbracket[0.3pt][0pt]{\textrm{#1}}_{#2}} @Naji –  azetina Nov 2 '13 at 17:35
2  
underline _ is only for math mode. –  Sigur Nov 2 '13 at 17:45
1  
\textrm is in textmode and you are inputing something that requires mathmode ao_t. Fix: \su{$ao_t$}{j} –  azetina Nov 2 '13 at 17:45

You can simply use

\small{}

or

\tiny{}

to decreaase the size of your text.

Below is the improved version of your code:

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

Hope this helps :)

share|improve this answer
    
@Omid1989, if you see the history of edits you'll see that I had done it for you before. –  Sigur Nov 2 '13 at 18:20
    
@Sigur, why did you deleted one of the "l"s from my answer !!? –  Omid1989 Nov 2 '13 at 19:36
    
@Omid1989, if you see the history, I only edited the line at the beginning, not the command on the example. –  Sigur Nov 2 '13 at 20:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.