39

Is there a command like \bar{...} but such that the bar is placed below the symbol?

Of course there is \underline{...} but then the line is adapted to the width of the symbol and I don't want that (compare with the difference between \overline{...} and \bar{...}).

I need this for math mode.

3
  • Do you need it in text mode or in math mode? Have a look at the accents package.
    – egreg
    Jul 25, 2013 at 13:02
  • Maybe this from amsmath: \underset{\bar{}}{A}
    – Sigur
    Jul 25, 2013 at 13:03
  • @egreg That's good. Could you turn the comment into an answer please.
    – lpdbw
    Jul 25, 2013 at 13:12

6 Answers 6

34

The accents package has the feature you're looking for:

\usepackage{accents}
\newcommand{\ubar}[1]{\underaccent{\bar}{#1}}

Why the \newcommand? Because you might change your mind or find a new way to underline a symbol, so you can just modify the definition instead of hunting through the document for occurrences of \underaccent{\bar}.

2
  • Interesting. With this we don't need to write \bar{} like mine suggestion. Also, the space between the symbol and the bar is different.
    – Sigur
    Jul 25, 2013 at 13:23
  • 2
    @Sigur The accents package ensures that the correct vertical dimension is assigned to the underaccent; with \underset{\bar{}}{x} you get a full vertical sized bar; and, moreover, it will be in script style.
    – egreg
    Jul 25, 2013 at 13:30
25

My solution is \newcommand{\ubar}[1]{\text{\b{$#1$}}} since I get a conflict of accents and amsmath packages concerning \vec command.

2
  • Can someone please explain why this has been downvoted? I am unsure if I should use the accents package in case there is indeed an assue with the amsmath package, as @SergeyPolyakovskiy suggests, however it is unclear. I have tried searching it in other questions and it seems that such a \vec issue does exist, but some clarification would be helpful. Thanks!
    – Flint72
    Oct 5, 2014 at 21:25
  • 1
    This. This answer saved my hide. The solution that is accepted here -- and referenced seemingly everywhere when it comes to the problem of making a suitable underbar expression relies on a really outdated package that, as far as I can figure, was last updated in 2006. It is not compatible with amsmath and a host of other packages. This solution works tremendously well.
    – Tom
    Feb 15, 2016 at 3:51
9

You can play with the three parameters (1.2pt underset gap, .8ex rule length, .075ex rule width

\documentclass{article}
\usepackage{stackengine}
\begin{document}
\newcommand\barbelow[1]{\stackunder[1.2pt]{$#1$}{\rule{.8ex}{.075ex}}}
\( \overline{A} \bar{A} \barbelow{A} \)
\end{document}

enter image description here

1
  • 1
    I needed to use a subscript with the \barbelow{f}, and this solution works the best - thanks! I used a slightly different set of parameters (1pt, .8ex, 0.075ex) though.
    – pinaki
    Apr 20, 2020 at 21:25
4

Have you tried using \underbar{symbol} in a math environment?

3
  • 1
    This only works in text mode.
    – egreg
    Feb 20, 2018 at 0:24
  • Just used it in math environment! It does work!
    – chadoulis
    Jan 4, 2020 at 7:18
  • For me using \underbar gives a bunch of weird errors having to do with closing math mode.
    – ifly6
    Jan 15, 2020 at 19:41
0

Use the \textrm{.1.} for text mode IN the math mode. In the brackets you can then use the text mode command \underline{.2.} to underline your text input in the {.2.} brackets.

in math mode...

\textrm{\underline{this text input will be underlined}} 

... worked for me

0

This post was also very helpful for me as I've had a similar problem. I am using \bar and this solution

\usepackage{stackengine}
\newcommand\barbelow[1]{\stackunder[1.2pt]{$#1$}{\rule{.8ex}{.075ex}}}

to underline in math mode. Unfortunately it seems like the \bar commads provides a slightly thicker bar which is why I am wondering if there is a possibility to make \barbelow a little bit thicker as well?

Thanks in advanve :)

2
  • 3
    Hi, welcome. Please note that this site isn't like a normal forum. All answer-posts should contain solutions to the problem posed in the question-post. Follow-up questions, if not handled in comments should be asked via the Ask Question-link in the top right. That said, change .075ex to some higher value, the thickness of the bar is determined by that length. Jun 20, 2020 at 12:38
  • Thank you for your help! I am sorry as I didn't know that before and appreciate your answer. Will do better with future comments :) Jun 20, 2020 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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