Is it better to write subscripts or superscripts first (e.g. $x_a^i$ vs $x^i_a$)?

  • 2
    I say $x_{i}^{2}$, because in most cases you want to square the thing identified by a subscript, not identify a squared value with a subscript. – erik Oct 2 '15 at 20:30

The output by the TeX engine is the same in both situations. So the only question is whether one of them is more semantical than the other one. For example if $x_i^2$ means square of the $i$th item of a sequence $x$, then it's more semantical to write it this way, rather than as $x^2_i$. But this depends on the situation, and also on how much pedantic you are :-)

Also, you should be consistent in your choice, it easies the editing of your files, both if you need to modify them, and if some professional editor (i.e., a person) needs to do so.

Last but not least, official LaTeX syntax requires braces for all superscripts and subscripts: $x_{i}^{2}$. Needless to say, hardly anybody follows this convention.

| improve this answer | |
  • 4
    it's also a good idea to write all such expressions the same way throughout the document. – barbara beeton Oct 2 '15 at 20:04
  • @barbarabeeton Good point. – yo' Oct 2 '15 at 20:04
  • 1
    I totally agree with @barbara beeton. I have been asked by my supervisor to change some notations ( many many symbols). Without sticking with one notation, I couldn't use find and relpace all feature. Don't underestimate small stuff because you don't know when you have to modify your documents. – CroCo Oct 2 '15 at 20:17
  • 2
    @Brian the latex syntax as specified in the latex book by Leslie Lamport. – David Carlisle Oct 2 '15 at 21:52
  • 2
    I think you mean 'Needless to say...'? – cfr Oct 3 '15 at 2:52

Semantically speaking, you can consider them as postscript operators: the _a portion indexes into an array or vector or somesuch and the ^i portion applies an exponent to a value. If you write $x_a^i$, you imply that you are indexing, and then applying an exponent. If you write $x^i_a$, you imply that you are applying an exponent to an entire vector, and then indexing into the result. You probably mean the former, x_a^i.

Lexicographically, the distinction is lost, because both of them produce the same result. With an extra pair of brackets, you can make it clear to your reader what is intended. If you type ${x_a}^i$, the exponent is typeset so that it clearly applies to the x_a value.

| improve this answer | |
  • 2
    With the exception when $x$ is a sequence of sequences, $x^{(i)}$ is the $i$th sequence in it, and $x^{(i)}_j$ is the $j$th value in the $i$th sequence. Then, the superscript should go first, semantically speaking. – yo' Oct 3 '15 at 10:18
  • @yo' Excellent comment, as the ^ does not mean exponential in this case – Greg Hilston Dec 23 '19 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.