# Forcing \overline not to continuously extend to adjacent variables

Could someone kindly help me how I can correctly display the following formula?

(\pi\rho\overline{\Gamma_\theta}\overline{R_\theta}^2)


The output is shown below.

However, the overline should not be continuously extending over both \Gamma_\theta and R_\theta. I would expect something like the following, which is the edited version of the above picture using Microsoft Paint.

• \overline{\Gamma}_{\theta}\overline{R}_{\theta}^{2} – egreg Jul 7 '14 at 17:56
• I actually want to show that the averaging is on \Gamma_\theta and not on \Gamma. Please let me know of your thoughts. – AFP Jul 7 '14 at 18:07
• You could insert a "thinspace", \,, between the two groups of variables. However, I think the expression looks a lot better if you do not extend the overline over the subscript \thetas, i.e., if you follow @egregs advice. – Mico Jul 7 '14 at 18:11
• i think this looks better still: (\pi\rho\overline{\Gamma_{\!\theta}} \,\overline{\!R_\theta}^2) with a few more space adjustments. – barbara beeton Jul 7 '14 at 18:15
• Thank you @barbara beeton, @egreg, and @mico. Barbara's solution is exactly what I want. I also agree that @egreg's solution is simpler and nicer. It would be great to have your thoughts on what this \overline{\Gamma}_{\theta} implies? Does it imply averaging over \Gamma or \Gamma_theta? – AFP Jul 7 '14 at 18:21

Shortening the overline on the right when a subscript is involved seems the best thing to do; it won't completely cover the subscript, but it doesn't seem really necessary:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\average}[2][0]{{%
\mspace{#1mu}%
\overline{\mspace{-#1mu}\average@check#2\relax}%
}}
\newcommand\average@check[1]{%
#1\@ifnextchar_{\average@sub}{}%
}
\newcommand{\average@sub}[2]{% #1 is _
_{#2}\mspace{-2mu}\aftergroup\average@compensate
}
\newcommand{\average@compensate}{\mspace{2mu}}
\makeatother

\begin{document}

$(\pi\rho\overline{\Gamma_\theta}\overline{R_\theta}^2)$

$(\pi\rho\average{\Gamma_\theta}\average[2.5]{R_\theta}^2)$

$\average[2.5]{R}$

\end{document}


The optional argument is meant to shorten the overline on the left when the argument is slanted. The first line is the original \overline.

• Errors and other odd things happen for $\average{\mathrm{R}_\theta}$. – Dan Jul 7 '14 at 20:48
• @Dan Surely so; complex arguments like this should be input as \average{{\mathrm{R}}_\theta}`. The alternative is to have separate macros for variable with or without subscripts. – egreg Jul 7 '14 at 21:16