## Monday, November 3, 2008

### \bar vs. \overline

Another quick post, this time about math. In particular about the \bar option. As many Latex users are aware, the \bar option is used to put a line over a letter/number in math mode, usually representing a mean. The problem with this method is that it puts a fixed-width bar over the letter (I think it's an underscore character '_') instead of covering the width of the letter(s).

This can be easily overcome with the overline option.

overline: \overline
usage: \overline{test}
Explanation: The overline option should be used instead of bar option.

The following code demonstrates the difference

\documentclass[12pt]{beamer}
\mode{
}
\begin{document}
\begin{frame}[plain]
\begin{align*}
Z& = \frac{\bar{BMI}-\mu}{\sqrt{\frac{\sigma^2}{N}}} \\
& = \frac{\bar{BMI}-\mu}{SE(\bar{BMI})} \\
\end{align*}
\begin{exampleblock}{RIGHT}
\begin{align*}

Z& = \frac{\overline{BMI}-\mu}{\sqrt{\frac{\sigma^2}{N}}} \\
& = \frac{\overline{BMI}-\mu}{SE(\overline{BMI})} \\
\end{align*}
\end{exampleblock}
\end{frame}
\end{document}

Which produces the following slide

1. Thanks, this was exactly what I was looking for. Keep it up!

2. It helps a lot...

3. Thanks so much.

4. This comment has been removed by a blog administrator.

5. Thanks so much. I really needed this for my thesis.

6. Thanks! Just what the doctor ordered.

7. Many Thanks!

8. Thank you!! My thesis was looking weird until I found this.

9. Thank you, though if you have an index to the letter than the overline, there is a white space between the letter and its index and it looks horrible.

\documentclass[12pt]{beamer}
\begin{document}

$\overline{V}_\textrm{p}$ instead of $\bar{V}_\textrm{p}$

\end{document}

Does anyone knows how to avoid the space between the V and p?

Thanks

10. You can put whatever you want in the argument to the overline command, so to put the overline above a number and its subscript, you do:

$\overline{V_\textrm{p}}$

11. You can also eliminate the space without having the overline cover both the symbol and its subscript by inserting a negative space (\!) between them:

$\overline{V}\!_\textrm{p}$

1. Thank you Kbolino, that's exactly what I was looking for.

12. That made my notes look nicer, and also lead me to try underline, which is what I wanted elsewhere. Thanks!

13. Thanks, nice tip!

14. THANK YOU! :)

15. Thank you for helping me write my paper!

16. Thanks! It saved the beauty of my thesis!

18. I would say this is correct if you have a variable with several letters (eg. BMI in the example). But if you have a variable with a single letter (eg. x), then \bar is better than \overline.

19. Thank you!

20. Thanks man, thesis on course too

21. Thanks, this helped fix my thesis!

22. Sometimes the overline is too wide. Is there a command in-between \bar and \overline?

1. Yes, but you have to define it yourself.
https://tex.stackexchange.com/questions/22100/the-bar-and-overline-commands

2. This comment has been removed by the author.

3. This comment has been removed by the author.