7

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.

9
  • But do you want the underline aligned with the baseline?
    – Sigur
    Commented Nov 2, 2013 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
    Commented Nov 2, 2013 at 17:22
  • Or even better with the size of a subscript.
    – Naji
    Commented Nov 2, 2013 at 17:25
  • 1
    @Naji, fraction is not a solution to you.
    – Sigur
    Commented Nov 2, 2013 at 17:27
  • 1
    this can help you tex.stackexchange.com/a/122121/14757
    – Sigur
    Commented Nov 2, 2013 at 17:33

3 Answers 3

4

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.

1
  • 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
    Commented Nov 2, 2013 at 18:12
4

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}
6
  • 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
    Commented Nov 2, 2013 at 17:32
  • A command would suffice @Naji
    – azetina
    Commented Nov 2, 2013 at 17:33
  • 1
    For example: \newcommand{\su}[2]{\underbracket[0.3pt][0pt]{\textrm{#1}}_{#2}} @Naji
    – azetina
    Commented Nov 2, 2013 at 17:35
  • 2
    underline _ is only for math mode.
    – Sigur
    Commented Nov 2, 2013 at 17:45
  • 1
    \textrm is in textmode and you are inputing something that requires mathmode ao_t. Fix: \su{$ao_t$}{j}
    – azetina
    Commented Nov 2, 2013 at 17:45
2

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 :)

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .