Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to override LaTeX's errors about double subscripts and superscripts?

Minor point about LaTeX that bothers me. When one writes

a^b^c, a_b_c  

or

a'^b  

in math mode, LaTeX gives an error message complaining about multiple super/subscripts. This is particularly annoying after replacing a string containing a super/subscript or when using the apostrophe, '.

Is there a way to override the error and have LaTeX simply output

a^{bc} a_{bc} {a'}^b  

and so on?

like image 289
Dmitry Vaintrob Avatar asked May 27 '10 12:05

Dmitry Vaintrob


2 Answers

The following is what you wish

\catcode`\^ = 13 \def^#1{\sp{#1}{}}
\catcode`\_ = 13 \def_#1{\sb{#1}{}}
like image 54
Alexey Malistov Avatar answered Nov 12 '22 09:11

Alexey Malistov


This is one of those cases where you really should be warned, and have to place the braces the way you want them - or write something without a double sub/superscript, if that's what you mean. Generally, when you're using superscript to indicate exponentiation, not indexing, a^b^c = a^{b^c}, so the output you describe is definitely incorrect in some cases. Sure, if they're superscript indices, you might mean a^{bc}, but how's LaTeX to know? And for subscripts, what if you really do mean a_{n_k}, not a_{nk}? (that is, double-indexing vs. a sequence of indices)

(And of course, if this crops up as part of a substitution, you can probably figure out a way to fix it as part of the substitution.)

like image 3
Cascabel Avatar answered Nov 12 '22 07:11

Cascabel