[Tex/LaTex] Right superscript dot

accentsamsmathmath-mode

I would like to achieve the following: a dot right of an expression

with this minimal example

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}

\newcommand{\dotr}[1]{%
#1\accentset{\mbox{\bfseries .}}{\vphantom{#1}}}

\begin{document}
$\dotr{(X+Y)}$
\end{document}

but the dot is too high. How can I lower the dot?

Thanks a lot!

Best Answer

A simple solution using \bullet as superscript:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\dotr}[1]{#1^{\bullet}} 

\begin{document}
$\dotr{(X+Y)}$  
\end{document}  

Result

If the bullet is too large, it can be reduced using the graphicx package. The following example also measures the first term and puts the bullet as high as possible without exceeding the height of the term before:

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

\makeatletter
\newcommand{\dotr}[1]{%
  \mathpalette\@dotr{#1}%
}
\newcommand*{\@dotr}[2]{%
  % #1: math style (\displaystyle, ..., \scriptscriptstyle)
  % #2: argument of \dotr
  \sbox0{$\m@th#1#2$}%
  \usebox{0}%
  % simulating a superscript
  \raisebox{\dimexpr\ht0-\height}{$\m@th#1\@smallbullet#1\bullet$}%
  \kern\scriptspace
}
\newcommand*{\@smallbullet}[2]{%
  \scalebox{.5}{$\m@th#1#2$}%
}
\makeatother

\begin{document}
$\dotr{(X+Y)}$
\end{document}

Result

Remarks:

  • The size of the small bullet can be configured by the number for \scalebox.
  • \mathpalette takes into account the current math style. It is further explained in the answers of question "The mysteries of \mathpalette". Therefore \@dotr has two arguments, the first argument is the math style.
  • \m@th is just a shortcut (defined in the LaTeX kernel) for \mathsurround=0pt for the case someone the feature of having additional white space around math formulas.
  • \sbox is the LaTeX version of setting a box register (first argument) with a horizontal box, whose contents is given in the second argument. It should be explained in a LaTeX manual. Even box numbers below 10 are free scratch registers for local assignments. The group is indirectly given by \mathpalette.