[Tex/LaTex] Automatically Raising Subscripts

math-modesubscriptssuperscriptsvertical alignment

I have the following expression

J_{ne}\boldsymbol{\mathsf{J}}_{ne}^{-1}

which is awkward in the sense that as the second (sans-serif) J has a superscript that the subscripted indices are lower than usual. Using the subdepth package has the effect of aligning the indices by lowering them even in the absence of a superscript. However, I would prefer to raise the subscripts which have been lowered by the presence of a superscript.

Although How to raise a subscript? describes how one can accomplish this it requires knowing the specific amount to raise the relevant subscripts by. Ideally, I am looking for an automatic way of accomplishing this (albeit one that only needs to work for the specific case outlined above as opposed to arbitrary sub/superscripts).

Best Answer

Here's an emulation of what you'd get by raising the superscript. In the first line the result of

$J_{ne}\bm{\mathsf{J}}_{ne}^{-1}$
$J^{}_{ne}\bm{\mathsf{J}}_{ne}^{-1}$

showing left the bad output and on the right the recommended one; in the second line the emulation of raising the superscript (obtained by pretending that the subscript has zero width and adding a superscript to \mathstrut:

$J_{ne}\bm{\mathsf{J}}_{ne}^{-1}$
$J_{ne}\bm{\mathsf{J}}_{\mathrlap{ne}}{\mathstrut}^{-1}$

enter image description here

Next the two examples embedded in text, in the same order; I've no doubt in choosing the first one (lowering the subscript).

enter image description here