5

I use Latex primarily to write tensor algebra, typically with a variety of latin and greek indices depending on the context. Normally this is fine, but I have noticed that occasionally some of the character heights (I assume) are different enough to be noticeable. In particular, when we have a pair of indices that are "(anti)symmetrised", which means we include a () or [] with the indices. Then the brackets are clearly miss-aligned. Here is an illustration of a minimal setup:

A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}

I have tried to find a solution to this, but haven't come across anything

2
  • Welcome to TeX.SE.
    – Mico
    Feb 26, 2023 at 16:38
  • You should add a phantom superscript to the second term, like A_{\kappa]\nu}^{\mathstrut}. (I was going to suggest the tensor package as I thought its recent versions dealt with this issue but apparently the problem is still there...)
    – campa
    Feb 26, 2023 at 16:38

3 Answers 3

4

If you use luatex, you can play with \mathscriptsmode. See section 7.5.7 for what the different modes mean.

\documentclass{article}

\begin{document}
$A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}$\par

\mathscriptsmode 0
0: $A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}$\par

\mathscriptsmode 1
1: $A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}$\par

\mathscriptsmode 2
2: $A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}$\par

\mathscriptsmode 3
3: $A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}$\par

\mathscriptsmode 4
4: $A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}$\par

\mathscriptsmode 5
5: $A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}$\par

\end{document}

Compiled with lualatex, this gives here this result:

scripts in different modes

Small update: Since it looks like (with the notation from the luatex manual) s and d are set to the same value in Latin Modern Math, we do not see any difference between case 1, 2, 3, 4 and 5. I therefore paste the result I get with the similar test file in ConTeXt, where \Umathsubshiftdown was altered a bit, to imitate the behavior of Computer Modern.

same example with context

4
  • It doesn't make a great deal of difference here, but if this were a real document, and these expressions embedded in continuous text, there's a real danger of a collision when what is done with line 0 is applied. (I'm assuming that the subscript is made to appear as if it is not as low as it really is; I can't believe that the height of the first A in line 1 is decreased.) Feb 26, 2023 at 19:23
  • Given that 0 looks like the first line, I thought it was the default. I agree it looks too close to line 1. (It does not look like that in ConTeXt.)
    – mickep
    Feb 26, 2023 at 19:31
  • Yes this does seem like the easiest one and done fix. Though annoyingly I had a hard time compiling lualatex correctly with vimtex. I can compile it separately, just directly in the terminal and it works, just not as conveniently. Feb 27, 2023 at 10:08
  • 1
    Although a bit off-topic here, I have a specific latexmkrc that I use with vimtex to compile lualatex projects. I can share it tomorrow if you're interested (not at the computer now, and too late...)
    – Rmano
    Feb 27, 2023 at 22:12
3

A solution might be to use \tensor or \indices from the tensor package. I'm not sure the alignment is perfect but it's certainly better.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tensor}
\begin{document}
\(A^{\rho}_{\sigma[\lambda} A_{\kappa]\nu}\)

\(\tensor*{A}{^\rho_{\sigma[\lambda}}\tensor{A}{_{\kappa]\nu}}\)
\end{document}
3

If you don't want to use a specialized package to fix the vertical positioning issues, you could fix the issues yourself, either by providing "empty exponents" or, for the utmost in positioning fidelity, \vphantom, i.e, invisible instructions inside the exponent terms.

enter image description here

\documentclass{article}
\begin{document}
\[
A^{\rho}_{\sigma[\lambda} 
A_{\kappa]\nu} 
A^{}_{\kappa]\nu}
A^{\vphantom{\rho}}_{\kappa]\nu}
\]
\end{document}
2
  • My only issue with this fix is its very manual, and my document is pretty big. plus typing out an extra 10-15 characters every time this crops up would be frustrating Feb 27, 2023 at 10:09
  • 1
    @LilyKavanagh You can create a custom command for A^{\vphantom{\rho}} (or something shorter from the left, to generalize).
    – J.G.
    Feb 27, 2023 at 13:00

You must log in to answer this question.

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