10

Following this question, I'm having problems when using the accepted answer on subscripts.

\[ 
A_  {z {_{y}^{x}} {_{x}^{y}} } \qquad
    {z {_{y}^{x}} {_{x}^{y}} }
\]

I don't know why, when in a subscript, the alignement/centering messes up.

I've also tried other options. I'll comment them a bit.

  • \atop , \genfrac and \above
\[
A_  {z {x \atop y} {y \atop x} } \qquad
    {z {x \atop y} {y \atop x} }
\]
\[ 
A_  {z {\genfrac{}{}{0pt}{2}{x}{y}} {\genfrac{}{}{0pt}{2}{y}{x}} } \qquad
    {z {\genfrac{}{}{0pt}{2}{x}{y}} {\genfrac{}{}{0pt}{2}{y}{x}} }
\]
\[
A_  {z {x \above 0pt y} {y \above 0pt x} } \qquad
    {z {x \above 0pt y} {y \above 0pt x} }
\]

They seem to render exactly the same. They have too much blank space.

  • \stackanchor from "stackengine" package
\stackMath
\[
A_  {z {\stackanchor{x}{y}} {\stackanchor{y}{x}} } \qquad
    {z {\stackanchor{x}{y}} {\stackanchor{y}{x}} }
\]

In both cases, it's misaligned. In the subscript, it's not the right size,

  • \overset from "mathtools" package and \stackrel
\[
A_  {z {\overset{x}{y}} {\overset{y}{x}} } \qquad
    {z {\overset{x}{y}} {\overset{y}{x}} }
\]
\[
A_  {z {\stackrel{x}{y}} {\stackrel{y}{x}} } \qquad
    {z {\stackrel{x}{y}} {\stackrel{y}{x}} }
\]

They seem to render exactly the same. In both cases, not centered, neither the correct size.

By "aligned" I mean "$xy$ alignment", so "misaligned" refers to anything else. There's no need that it renders strictly perfect aligned, centered or sized: something close will do.

Desired output:

enter image description here

Gilgamesh
  • 267

2 Answers2

9

Something like this? (Observe: no need for \overset, \stackanchor, \atop, etc.)

enter image description here

\documentclass{article}
\newcommand\complicatedz{z_{yx}^{xy}}
\begin{document}
\[
\complicatedz \quad A_{\complicatedz} \quad A_{\complicatedz}^{}
\]
\end{document} 

The two A_{...} terms differ, very slightly, in the vertical positioning of the subscript term -- which I've called, not very imaginatively, \zcomplicated.

Mico
  • 506,678
  • Thanks for your answer! I can't believe I haven't thought of such simple approach. It renders perfectly for this cases. However, I apologize for not being clear enough on my purposes: both _x^y and _y^x are different objects. Therefore, I could use something like egreg's third example or having a z in between the x, y. – Gilgamesh Sep 24 '21 at 16:16
9

Do you want to stack the objects? In this case a version of \atop can do it (using \genfrac, of course). The trick is to force \textstyle when the object is found in \displaystyle, otherwise the standard action is good.

\documentclass{article}
\usepackage{amsmath}

\makeatletter \newcommand{\stk}[2]{\mathinner{!\mathpalette\stk@{{#1}{#2}}!}} \newcommand{\stk@}[2]{% \ifx#1\displaystyle \expandafter@firstoftwo \else \expandafter@secondoftwo \fi {\genfrac{}{}{0pt}{1}}% {\genfrac{}{}{0pt}{}}% #2% } \makeatother

\begin{document}

[ A_{z\stk{x}{y}\stk{y}{x}} \qquad z\stk{x}{y}\stk{y}{x}\ne z_{xy}^{yx} \qquad z\stk{aa}{b}\stk{b}{aa} ]

\end{document}

enter image description here

egreg
  • 1,121,712