# Write text (or symbol) vertically below another symbol in latex

I have to write some equations in latex, my Latex equation:

    \begin{align}
G _{a_{1},\ldots ,a_{k}}\ast_{b_{1},\ldots ,b_{k}} G^{\prime }=G^{\prime \prime }
\end{align}


How can I make the text like this:

I have to write an equations in latex like this:

• Where do you want the baseline? – John Kormylo Mar 12 '15 at 15:08
• You can use this approach by egreg and only change \mathcal{S} to \ast. – yo' Mar 12 '15 at 15:29

I use a \Centerstack to accomplish the stack. I place the top and bottom items in a \mathsf wrapper, and I introduce \coresym[scale]{symbol}{subscript/superscript} to center the core symbol and scale it as needed.

\documentclass{article}
\usepackage{graphicx}
\usepackage[usestackEOL]{stackengine}
\newcommand\coresym[3][1]{\phantom{#3}\scalebox{#1}{$#2$}#3}
\setstackgap{L}{.9\baselineskip}
\stackMath
\begin{document}
$\Centerstack{\mathsf{G} \\ \coresym[1.3]{*}{^1_2} \\ \mathsf{G}} = ax + b$
\end{document}


I also shrunk the stacking gap between items to .9\baselineskip, but that can be changed to suit. Here it is shrunk to .7\baselineskip.

You will probably want to make a macro to simplify. I wasn't sure what to make an argument and what to leave fixed.

\documentclass{standalone}
\usepackage{mathtools}
\usepackage{mathabx}% for \Asterisk

\begin{document}
$\displaystyle A = \vcenter{\baselineskip=0pt\hbox{$G$}\hbox{$\displaystyle *_{\scriptscriptstyle 2}^{\scriptscriptstyle 1}$}\hbox{$G$}} = \vcenter{\baselineskip=0pt\hbox{$G$}\hbox{$\displaystyle \Asterisk_{\scriptscriptstyle 2}^{\scriptscriptstyle 1}$}\hbox{$G$}}$
\end{document}


\documentclass{article}
\usepackage{amsmath}

\newcommand{\xasterisk}[4]{%
{\mathop{*^{#1}_{#2}}\limits^{#3}_{#4}}%
}

\begin{document}
$\xasterisk{1}{2}{\mathsf{G}}{\mathsf{G}}=ax+b$
\end{document}


Maybe something like this?

\documentclass{article}
\newcommand{\asteriskG}[4]{{\mathop{\ast}\limits
_{\textsf{\bfseries\scriptsize#1}}
^{\textsf{\bfseries\scriptsize#2}} \mkern-2mu
{}_{\scriptscriptstyle#3}
^{\scriptscriptstyle#4}}
}
\begin{document}
$\asteriskG{G}{G}{2}{1}=ax+b$
\end{document}


If you need a five-pointed instead of six-pointed star, use \star instead of \ast. How important is it that the two letters G be typeset in bold sans-serif style?