I would like to write
\overline{Y}_n
in order to display the mean of Y. This yields:
However when I do this there is a gap between the Y and the n. Using
\bar{Y}_n
yields:
This avoids the gap however in that case the bar above the Y is not long enough for my liking.
I have seen that there exists a question \overline and \widehat with subscript but that question asks about subscript added to the bar symbol, not subscript added to the symbol(s) which are under the bar.
I'm also aware of this question: Overline over a symbol with an index but that question is about what you should or shouldn't do; not a method to solve this problem.
Thanks in Advance!
EDIT: I realize that this question is very similar to this one: Symbol with overline and subscript leads to wrong kerning, however the answer given below is better than the ones to that question.




\overline{Y}_{\!n}, but it requires a little typing. – Steven B. Segletes May 17 '17 at 11:45\overline), you should either use the answer provided in the question Arzigoglu linked to or use AboAmmar's answer. – Skillmon May 17 '17 at 12:28