# How to overline only part of the text in subscript format

I can format h_y using the command $\overline{h_y}$, but I want to type h_y,max where y,max is subscript but the horizontal line of overline only cover h_y.

Thank you

• Probably not ideal, but what about $\overline{h_y}{}_{,max}$? – leandriis Jun 5 '19 at 7:13
• Can you explain what the notation should mean? I would suspect something like $(\overline{h_y})_{\max}$ would be more appropriate, but the context matters. – Andrew Swann Jun 5 '19 at 7:56

Though I think this notation might confuse the reader, here is a solution which makes the max part have zero width by using \mathrlap. The following \hphantom puts (nearly) the same amount of space back in.

\documentclass{article}
\usepackage{mathtools}

\begin{document}
$\overline{h_{y,\mathrm{max}}} = 1$
\medskip

$\overline{h_{y\mathrlap{,\mathrm{max}}}}_{\hphantom{,\mathrm{max}}} = 1$
\end{document}


\documentclass{article}
\usepackage{mathtools}
\begin{document}

$\overline{h_{y\mathrlap{,\max}}}$ \qquad foo

\end{document}


• Why \qquad? That's arbitrary. – egreg Jun 5 '19 at 22:54

The simplest strategy is to add an overline with the desired width (but occupying no horizontal space) and then typeset the symbol to be partially overlined.

\documentclass{article}
\usepackage{mathtools}

\newcommand{\partialoverline}[1]{%
\mathrlap{\overline{\phantom{#1}}}%
}

\begin{document}

$\partialoverline{h_y}h_{y,\max}$

\end{document}


• Great short macro code. – Sebastiano Jun 5 '19 at 23:05

My proposal is to use a spartan macro called \oversize.

\documentclass[a4paper,12pt]{article}
\newcommand{\oversize}[1]{\mkern-1.5mu\overline{\mkern-1.5mu#1\mkern-28mu}\mkern30mu}
\begin{document}
$\oversize{h_{y,\mathrm{max}}}= 1$
\end{document}


Changhing the values of two \mkern of \overline{\mkern0mu#1\mkern-10mu} you can increase the lenght of \overline. The last \mkern10mu it is only to bring closer to the code equality and 1. See the example below.

\documentclass[a4paper,12pt]{article}
\newcommand{\oversize}[1]{\mkern-1.5mu\overline{\mkern0mu#1\mkern-10mu}\mkern10mu}
\begin{document}
$\oversize{h_{y,\mathrm{max}}}= 1$
\end{document}