How can I tell AUCTeX that breqn is a math environment?
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)))
If you want the environment to be recognized by texmathp
(used for instance by company-auctex), you can do it the following way.
(add-to-list 'texmathp-tex-commands '("breqn" env-on))
(texmathp-compile)