Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have recently been trying to use the breqn package to automatically break up my equations. However, I use emacs (and/or Aquamacs, depending on the machine I'm on) with Auctex, and it does not recognize these environments as math environments which is a bit of a headache.

Is there a list somewhere or a lisp command I can put in a .emacs file that tells auctex to recognize the math environments introduced by breqn as math environments?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

You can tell auctex about additional math environments using LaTeX-add-environments. For example, I sometimes use math environments named thm, prop, lem, cor, defn, not, rem, ex, notation, and equation*, and I tell auctex about them with the following lines in my .xemacs/init.el file:

(add-hook 'LaTeX-mode-hook 'add-my-latex-environments)
(defun add-my-latex-environments ()
  (LaTeX-add-environments
   '("thm" LaTeX-env-label)
   '("prop" LaTeX-env-label)
   '("lem" LaTeX-env-label)
   '("cor" LaTeX-env-label)
   '("defn" LaTeX-env-label)
   '("not" LaTeX-env-label)
   '("rem" LaTeX-env-label)
   '("ex" LaTeX-env-label)
   '("notation" LaTeX-env-label)
   '("equation*" LaTeX-env-label)))

Edit: In addition, here's some code suggested by thequark to have proper syntax highlighting for the dmath environment under auctex, plus a couple of other improvements:

(add-hook 'LaTeX-mode-hook 'add-my-latex-environments) 
(defun add-my-latex-environments () 
  (LaTeX-add-environments 
     '("dmath" LaTeX-env-label))) 

;; Code I added to make syntax highlighting work in Auctex 

(custom-set-variables 
 '(font-latex-math-environments (quote  
     ("display" "displaymath" "equation" "eqnarray" "gather" "multline"  
      "align" "alignat" "xalignat" "dmath"))) 
  '(TeX-insert-braces nil)) ;;Stops putting {} on argumentless commands to "save" whitespace 

;; Additionally, reftex code to recognize this environment as an equation 
(setq reftex-label-alist 
  '(("dmath" ?e nil nil t))) 
share|improve this answer
    
Thanks! This is definitely a step in the right direction; Now LaTeX recognizes the environments, but they still don't show up highlighted for math (and backtick-a still outputs \alpha{} not \alpha, so auctex thinks I'm inserting text, not math). Is there a way to have auctex recognize these environments as math? –  thequark Sep 5 '11 at 17:09
    
I had to had a few more lines to get this to work as a math environment. If you edit your answer to include these lines of code, I'd be happy to accept it. (This example is for dmath in particular.) gist.github.com/1195737 –  thequark Sep 5 '11 at 19:37

Your Answer

 
discard

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.