E.g. in emacs 25.1 with Auctex 11.90.0 $a_\mathrm{b}$ only lowers the \mathrm and the {b} is left unmoved.

Obviously I can add braces e.g. $a_{\mathrm{b}}, but I'm editing existing documents and don't want to have to go through changing them all just to get Auctex to display properly.

To be clear: this is just a problem with how Auctex shows the .tex file, the generated output is fine.

  • 1
    the fact that _\mathrm{b} works but (for example) _\mbox{b} doesn't requires rather more tex knowledge than even auctex has, although of course a list of common cases where this works is probably easy enough. Fixing the source not to have the missing braces it would be good though:-) – David Carlisle Jan 16 '17 at 13:59
  • You can disable this new feature (more accurate: old feature which now works correctly) in AUCTeX 11.90 with (setq font-latex-fontify-script nil) in your init file or via customize. I would also suggest you follow the advice given by @DavidCarlisle. – Arash Esbati Jan 16 '17 at 14:25
  • @ArashEsbati this bug is present also in previous versions ;-) – giordano Jan 16 '17 at 14:28
  • @giordano - Obviously I lost track on that long thread ;-) – Arash Esbati Jan 16 '17 at 14:34

I don't think this can be done in general in a reliable way, and the problem is more on the TeX side, than on the AUCTeX one. Consider for example:


In this case AUCTeX lowers only \alpha and not {i} and this correctly reflects the appearance of the output document, because \alpha is a command not taking arguments. In addition, David Carlisle pointed out that expressions like _\mbox{b} wouldn't work either, without wrapping them in a group.

The safest one to type superscripts and subscripts is using the syntax ^{...} and _{...} and AUCTeX provides the TeX-electric-sub-and-superscript option to automatically insert {} upon typing _ and ^ in math mode.

For your specific case, editing other people's code, sorry to say they should have written better code. Anyway, you could temporarily disable special fontification of superscripts and subscripts with this code in your Emacs init file:

(setq font-latex-fontify-script nil)

In this way scripts won't be raised or lowered. Remember to remove this setting when you come back to edit your own documents ;-)

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.