[Tex/LaTex] Simple way to place an array of symbols above a letter

accentsformattingmath-mode

I would like to typset something similar to the symbol used for the "generalized spherical harmonics". This involves placing an array of dots above a letter. The array will have two columns, and the number of dots in each column can be different. I have tried the following, but it looks awful:

$\overset{\begin{matrix} . & \ \\ . & . \end{matrix}}{T}$

I would rather not have to fiddle with the array spacing manually, is there any way to do this simply? If not, how would I do it at all (even if it requires manual array spacing)?

An example of what it's supposed to look like can be found here (its the T symbol with the dots above it, but it shouldn't look like a triangle, it should distinctly be two columns with two dots on the left and one on the right):

enter image description here

Best Answer

Here is a possible way

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\def\spher@harm#1{%
  \vbox{\hbox{%
    \offinterlineskip
    \valign{&\hb@xt@2\p@{\hss$##$\hss}\vskip.2ex\cr#1\crcr}%
  }\vskip-.36ex}%
}
\def\gshone{\spher@harm{.}}
\def\gshtwo{\spher@harm{.&.}}
\def\gshthree{\spher@harm{.&.&.}}
\let\gsh\spher@harm
\makeatother

\begin{document}
$\displaystyle
\overset{\gshtwo\gshone}{T}
\overset{\gshthree\gshtwo\gshone}{T}
\dot{T}
$
\end{document}

I have defined only three combinations, you can say \gsh{.&.&.&.} for getting four dots (or define \gshfour).

enter image description here

New version

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

\makeatletter
\def\gsh#1{%
  \vbox{\hbox{%
    \let\\\cr
    \offinterlineskip
    \valign{&\hb@xt@2\p@{\hss$##$\hss}\vskip.2ex\cr#1\crcr}%
  }\vskip-.36ex}%
}
\def\gshsym{\@ifstar\gsh@ssym\gsh@sym}
\def\gsh@sym#1#2{\mathrlap{\overset{#1}{\phantom{#2}}}#2}
\def\gsh@ssym#1#2{\overset{#1}{#2}{\vphantom{#2}}}
\makeatother

\newcommand\gshone{\gsh{.}}
\newcommand\gshtwo{\gsh{.&.}}
\newcommand\gshthree{\gsh{.&.&.}}

\begin{document}
$\displaystyle
\gshsym{\gshtwo\gshone}{T}^m_n
\gshsym{\gshthree\gshtwo\gshone}{T}
\gshsym{\gsh{\scriptscriptstyle*&\scriptscriptstyle*}}{F}^2
\gshsym*{\gshthree\gshthree\gshtwo\gshtwo\gshtwo}{F}^2
$
\end{document}

You use \gshsym for "short" superscripts that don't go beyond the letter to which they are overset, \gshsym* for wider superscripts.

enter image description here

Related Question