# superscripting a dot which is enclosed in square brackets

This question is about how to extend the nice answer here by @egreg https://tex.stackexchange.com/a/304078/103130

to the following case (which is close to what I need except that the brackets should appear around the dot, and the brackets should be a bit closer together):

\documentclass{article}
\usepackage{amsmath,graphicx}

\makeatletter
\newcommand\boverdot{}

\DeclareRobustCommand\boverdot[1]{\mathord{\mathpalette\b@dot{#1}}}
\newcommand{\b@dot}[2]{%
\sbox\z@{$\m@th#1\dot{#2}$}%
\raisebox{-\dp\z@}{\scalebox{.5}[.2]{$\m@th#1[$}}%
\copy\z@
\raisebox{-\dp\z@}{\scalebox{.5}[.2]{$\m@th#1]$}}%
}
\makeatother

\begin{document}

$a_{\boverdot{i}}$

\end{document}


Can anyone see how to fix this? Thanks

• Extra credit if anyone can come up with a solution that only uses amsmath and graphicx packages! – user103130 Apr 13 '16 at 19:54

I adapted \bunderline from my answer (putting square brackets around the underline of a letter (in math mode)) at the cited question into \boverdot. It works in all math styles.

\documentclass{article}
\usepackage{stackengine,graphicx,scalerel,amsmath}
\stackMath
\def\tinylb{\smash{\scalebox{.25}{$\SavedStyle[$}}}
\def\tinyrb{\smash{\scalebox{.25}{$\SavedStyle]$}}}
\def\bunderline#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$}\def\useanchorwidth{T}%
\stackunder[1.2pt]{\SavedStyle#1}{\tinylb\rule[.3\LMpt]{\wd0}{.4pt}\tinyrb}}}
\def\boverdot#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$}\def\useanchorwidth{T}%
\stackon[-1.2\LMpt]{\SavedStyle\dot#1}{\tinylb\rule[0.3\LMpt]{\wd0}{0pt}\tinyrb}}}
\let\overdot\dot
\begin{document}
$a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{i},\boverdot{i},d$

$\scriptstyle a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{i},\boverdot{i},d$

$\scriptscriptstyle a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{i},\boverdot{i},d$
\end{document}


To bring the brackets a bit closer, multiply \wd0 in the definition of \boverdot by a value less than one, in this case .5.

\documentclass{article}
\usepackage{stackengine,graphicx,scalerel,amsmath}
\stackMath
\def\tinylb{\smash{\scalebox{.25}{$\SavedStyle[$}}}
\def\tinyrb{\smash{\scalebox{.25}{$\SavedStyle]$}}}
\def\bunderline#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$}\def\useanchorwidth{T}%
\stackunder[1.2pt]{\SavedStyle#1}{\tinylb\rule[.3\LMpt]{\wd0}{.4pt}\tinyrb}}}
\def\boverdot#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$}\def\useanchorwidth{T}%
\stackon[-1.2\LMpt]{\SavedStyle\dot#1}{\tinylb\rule[0.3\LMpt]{.5\wd0}{0pt}\tinyrb}}}
\let\overdot\dot
\begin{document}
$a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{i},\boverdot{i},d$

$\scriptstyle a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{i},\boverdot{i},d$

$\scriptscriptstyle a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{i},\boverdot{i},d$
\end{document}


The non-centered dot above the g is a function of special letter-specific kerning associated with the \dot macro. The following avoids that problem by forcing the overdot to be centered over the letter.

\documentclass{article}
\usepackage{stackengine,graphicx,scalerel,amsmath}
\stackMath
\def\tinylb{\smash{\scalebox{.25}{$\SavedStyle[$}}}
\def\tinyrb{\smash{\scalebox{.25}{$\SavedStyle]$}}}
\def\bunderline#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$}\def\useanchorwidth{T}%
\stackunder[1.2pt]{\SavedStyle#1}{\tinylb\rule[.3\LMpt]{\wd0}{.4pt}\tinyrb}}}
\def\boverdot#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$}\def\useanchorwidth{T}%
\stackon[1.2\LMpt]{\SavedStyle#1}{%
\tinylb\smash{\raisebox{-1.8\LMpt}{\makebox[.5\wd0]{$\SavedStyle\cdot$}}}\tinyrb}}}
\let\overdot\dot
\begin{document}
$a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{\imath},\boverdot{\imath},d$

$\scriptstyle a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{\imath},\boverdot{\imath},d$

$\scriptscriptstyle a,\overdot{b},\boverdot{b},\overdot{g},\boverdot{g}, \overdot{\imath},\boverdot{\imath},d$
\end{document}


• This is great, thanks! How could I reduce the spacing between the square brackets to bring them closer together? – user103130 Apr 13 '16 at 19:30
• @user103130 Multiply \wd0 in the \boverdot definition. See my revision. – Steven B. Segletes Apr 13 '16 at 19:33
• spaces between dot and brackets not symmetrical over the "g". and maybe \imath instead of undotted "i"? – barbara beeton Apr 13 '16 at 19:34
• Thanks again Steven! I'm curious why the dot is sometimes not equidistant from the square brackets, but other times it is. Do happen to know how the brackets could be centered properly? – user103130 Apr 13 '16 at 19:35
• @barbarabeeton I am aware of the g asymmetry. However, it arises because there must be glyph-unique kerns for the dots over various letters, to which my algorithm does not have access. – Steven B. Segletes Apr 13 '16 at 19:37

Does this solution also works for you ? It seems to be a lot simpler and the result seems to be the same.

\documentclass{article}
\usepackage{amsmath,graphicx}

\newcommand{\boverdot}[1]{\overset{\scalebox{.5}[.2]{$[$} \boldsymbol{.} \scalebox{.5}[.2]{$]$}}{#1}}

\begin{document}
$a_{\boverdot{i}}$
\end{document}

• Unfortunately your solution changes the height of the subscripted letter. Also, the square brackets are a bit too far apart. However, it is really nice that this only uses the amsmath and graphicx packages – user103130 Apr 13 '16 at 19:46
• By "height", I really meant vertical position. :) The subscripted letter gets moved down. – user103130 Apr 13 '16 at 19:59