TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With help from the question How to add custom math-environments I taught AUCTeX that IEEEeqnarray and its starred counterpart are math environments. I added the following to my .emacs

;; teach auctex IEEEeqnarray
(add-hook 'LaTeX-mode-hook 'add-my-latex-environments) 
(defun add-my-latex-environments () 
     '("IEEEeqnarray" LaTeX-env-label)
     '("IEEEeqnarray*" LaTeX-env-label)))

In the custom-set-variables section I added

'(font-latex-math-environments (quote ("display" "displaymath" "equation" "eqnarray" "gather" "multline" "align" "alignat" "xalignat" "IEEEeqnarray" "IEEEeqnarray*")))

And finally made reftex aware of it

;; Additionally, reftex code to recognize this environment as an equation 
(setq reftex-label-alist 
  '(("IEEEeqnarray" ?e nil nil t)
    ("IEEEeqnarray*" ?e nil nil t)))

There's some more emacs customisation stuff found at How to Typeset Equations in LaTeX

Now my question is:

How can I teach AUCTeX that it should also auto-expand the sub- and superscripts in these custom environments?

At the beginning of my .emacs I set

(setq TeX-electric-sub-and-superscript t) ; auto-expand sub- and superscript

But even though I integrated the IEEEeqnarray environments into AUCTeX with the above customisations, it doesn't auto-expand the _ and ^ symbols in these environments, as it does in, e.g. eqnarray. I love this functionality, and need it in my custom math environments as well.

share|improve this question
up vote 4 down vote accepted

Electric super and subscripts uses texmathp to determine when they should be run. This function is controlled by the texmathp-tex-commands variable which you can customize. You will need to call texmathp-compile if you set it outside of the customize interface.

Adding the following to your custom-set-variables and restarting Emacs should do the trick.

'(texmathp-tex-commands (quote (("IEEEeqnarray" env-on) ("IEEEeqnarray*" env-on))))
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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