8

I would like to create commands to produce overlines (respectively wide hats or arrows) with a subscript at the end. The commands

\overline{X}^{1}   \widehat{X}^{2}  \overrightarrow{X}^{3}

do not suit my needs since the subscripts should be controlled by the overline (respectively wide hat, right arrow). Ideally I would like to have a command like

\myoverline_{1}{X}   \mywidehat_{2}{X}  \myoverrightarrow_{3}{X}

What would be the cleanest way to do so?

P.S. The closest thing I was able to find is this question.

Update Here is a picture of what I wish to obtain:

enter image description here

J.-E. Pin
  • 619
  • 1
    i'm unable to picture what you want from this description. in the cited answer, the "superscripts" are actually set above the "decoration". do you want your "subscripts" stacked below the over-accents, and then that whole construction stacked on top of what it's embellishing? if you could draw a picture, and post it as a scan, that would be very helpful. – barbara beeton Dec 23 '13 at 16:43
  • 2
    \overline{X_1}? – egreg Dec 23 '13 at 16:44
  • 1
    I think you meant superscript instead of subscript. – Herr K. Dec 23 '13 at 18:13
  • @kevin-c No, I mean subscript, the subscript is relative to the bar, not to the X. – J.-E. Pin Dec 23 '13 at 18:21
  • @J.-E.Pin: I see. It would be useful if you could add this piece of information to the question (i.e. that 1 is a subscript to the overline). – Herr K. Dec 23 '13 at 18:27
  • 2
    I'm not sure the reader would understand that the little number is a subscript to the decoration rather than an exponent for the expression. – egreg Dec 23 '13 at 18:35
  • @egreg I agree with you and I hope that the comments have now clarified what I really meant. I was not familiar with the word "decoration", which I should have used. Please accept my apologies for being imprecise. – J.-E. Pin Dec 23 '13 at 19:09

2 Answers2

10

your example looks enough like a symbol with a (raised) \overline and a superscript to the base symbol that i'm going to construct that.

the second image might suffice:

enter image description here

\documentclass{article}
\begin{document}
 $\overline{\mathrm{X}\vphantom{()}}^1
 \quad
 \smash{\overline{\mathrm{X}\vphantom{()}}}\vphantom{X}^1$
\end{document}
6

This approach gives the subscript to the "overline" as you seemed to indicate. With this implementation, the overline thickness is .4pt which can be changed. The bottom of the subscript is 1.5pt below the top of the argument. The 2pt setting determines the vertical location of the overbar relative to the subscript.

\documentclass{article}
\usepackage{stackengine}
\stackMath
\newcommand\subline[2]{\stackon[-1.5pt]{#1}{\rule[2pt]{\widthof{$#1$}}{.4pt}_{#2}}}
\begin{document}
\renewcommand\stackalignment{l}
$A = \subline{X}{1} \subline{g}{2} \subline{Xyzq}{12}$
\end{document}

enter image description here


For the widehat, I adopt a bit of a different approach, making added use of the scalerel package. The parameter \hatgap gives the vertical gap between item and hat, and \subdown gives the relative placement of the subscript relative to the hat.

\documentclass{article}
\usepackage{scalerel}
\usepackage{stackengine}
\stackMath
\def\hatgap{2pt}
\def\subdown{-2pt}
\newcommand\reallywidehat[2][]{%
\renewcommand\stackalignment{l}%
\stackon[\hatgap]{#2}{%
\stretchto{%
    \scalerel*[\widthof{$#2$}]{\kern-.6pt\bigwedge\kern-.6pt}%
    {\rule[-\textheight/2]{1ex}{\textheight}}%WIDTH-LIMITED BIG WEDGE
}{0.5ex}% THIS SQUEEZES THE WEDGE TO 0.5ex HEIGHT
_{\smash{\belowbaseline[\subdown]{\scriptstyle#1}}}%
}}
\begin{document}
$\reallywidehat[1]{zbcdklm} \times
\reallywidehat[ijk]{zbcdefghijk} = 
\reallywidehat{zb}$
\end{document}

enter image description here

The widehat EDIT is very loosely based on my solution at Really wide hat symbol, though this implementation is superior to that one.