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{
\usetheme{Boadilla}
}
\begin{document}
\begin{frame}[plain]
\begin{alertblock}{WRONG}
\begin{align*}
Z& = \frac{\bar{BMI}-\mu}{\sqrt{\frac{\sigma^2}{N}}} \\
& = \frac{\bar{BMI}-\mu}{SE(\bar{BMI})} \\
\end{align*}
\end{alertblock}
\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