Vertically align super and subscript in columns

alignmentmath-modesubscriptssuperscripts

I have a symbol that always has two upper and two lower indices, so think of it like two index columns. I'd like to have them aligned with each other.

\newcommand{\cg}[5]{{\scriptstyle{#1}}^{#2 #4}_{#3 #5}}

This should be compatible with LuaLatex.

enter image description here

Best Answer

The \cgy variant of your macro may be what you're looking for.

enter image description here

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{array}
\newcommand{\cg}[5]{{\scriptstyle{#1}}^{#2 #3}_{#4{-}#5}}

%% \cgx provides left-alignment
\newcommand{\cgx}[5]{{\scriptstyle #1}^{#2}_{#4{-}}{}^{#3}_{#5}}

%% \cgy provides horizontal centering
\newcommand\myarray[2]{%
   \begin{array}{@{}>{\scriptstyle}c@{}} #1 \\[-1.25ex] #2 \end{array}}
\newcommand{\cgy}[5]{{\scriptstyle #1}\myarray{#2}{#4}\myarray{}{-}\myarray{#3}{#5}}

\begin{document}
$\cg{1/2}{1}{1}{1/2}{1/2}$
\quad 
$\cgx{1/2}{1}{1}{1/2}{1/2}$
\quad
$\cgy{1/2}{1}{1}{1/2}{1/2}$
\end{document}