# Simple way to place an array of symbols above a letter?

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):

-
are there ever more than two "columns" of dots? (i've just looked at the wikipedia site on "generalized spherical harmonics", and, while the notation you describe doesn't appear there in that form, some examples appear to invite as many as five columns.) –  barbara beeton Dec 13 '12 at 19:00
@barbarabeeton: For my purposes I will only need two columns, but the number of symbols in each column needs to be arbitrary, and the symbols themselves should also be arbitrary. I envision defining a macro at the beginning of my document that is something like: \newcommand{\GSH}[6]{ \overset{\begin{matrix} #5 & \ \\ #5 & #6 \end{matrix}}{#1_{#2}^{#3 #4}} } except I would want to have the matrix size customizable at the time of use rather than having it hardcoded in as 2 on the left and one on the right. –  okj Dec 13 '12 at 19:10
I would then use this macro to create the above symbol by: \GSH{T}{l}{m}{n}{.}{.} –  okj Dec 13 '12 at 19:12

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).

# 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.

-
@egreg: This is great, but I'm having trouble getting the subscripts and superscripts on the T. If I do it directly then either the dots are not centered appropriately (i.e. it is centered wrt the entire symbol rather than just the T) or the superscript is above the dots. I tried \sideset too, but it gives me errors for some reason. –  okj Dec 13 '12 at 22:26
@okj \sideset only works with math operators. Define a math operator like in my example. –  azetina Dec 13 '12 at 22:28
@azetina: I defined the following math operators: \DeclareMathOperator*{\specialz}{\mathit{Z}} \DeclareMathOperator*{\symz}{\overset{\gshtwo\gshone}{\specialz}} and then tried to use \sideset{}{_{lm}^n}\symz, but it puts the n way above the Z since it thinks the entire symbol is the operator. If instead I try \overset{\gshtwo\gshone}{\sideset{}{_{lm}^n}\specialz} then the superscript is in the right place but the dots are not centered over the Z, they're centered over the entire symbol including the sub and superscripts –  okj Dec 13 '12 at 22:42
@okj I added a newer version –  egreg Dec 13 '12 at 22:45
@egreg: Awesome! Thank you so much! One other question, if i replace the periods with other symbols, for example \triangle or \circ they are too large and overlap. Is there a way to shrink these symbols so they fit as well? –  okj Dec 13 '12 at 22:50
show 1 more comment