3

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

1 Answer 1

3

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}
2
  • 1
    Great, thanks a lot! I did some tweaking with the -1.25ex to get it exactly as I want but that is of course up to preference. Mar 13, 2022 at 16:58
  • 1
    @infinitezero - You're most welcome. The -1.25ex adjustment was purely intended for making the vertical distances between super- and subscript terms the same as in the other two macros. I'm glad you figured out how to tweak this parameter to better meet your formatting needs.
    – Mico
    Mar 13, 2022 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .