1 ;;; amsmath.el --- Style hook for the AMS-LaTeX amsmath package.
3 ;; Copyright (C) 2002, 2005 Free Software Foundation, Inc.
4 ;; FIXME: What about the copyright for <= 2001?
6 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
7 ;; Maintainer: auctex-devel@gnu.org
9 ;; This file is part of AUCTeX.
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 ;; This will also load the amstext, amsbsy and amsopn style files.
32 (TeX-add-style-hook "amsmath"
36 (LaTeX-add-environments
37 '("align" LaTeX-env-label)
38 '("gather" LaTeX-env-label)
39 '("flalign" LaTeX-env-label)
40 '("multline" LaTeX-env-label)
41 '("alignat" LaTeX-amsmath-env-alignat)
42 '("alignat*" LaTeX-amsmath-env-alignat)
43 '("xalignat" LaTeX-amsmath-env-alignat)
44 '("xalignat*" LaTeX-amsmath-env-alignat)
45 '("xxalignat" LaTeX-amsmath-env-alignat)
46 '("aligned" LaTeX-amsmath-env-aligned)
47 '("gathered" LaTeX-amsmath-env-aligned)
48 "align*" "gather*" "flalign*" "multline*" "equation*"
51 "matrix" "smallmatrix" "pmatrix" "bmatrix" "Bmatrix" "vmatrix" "Vmatrix"
53 '("subarray" "Alignment"))
56 '("eqref" TeX-arg-ref)
57 '("numberwithin" TeX-arg-counter "Section level")
58 '("raisetag" "Dimension")
60 '("hdotsfor" ["Stretch"] "Number of columns to cover")
61 '("xleftarrow" ["Below"] "Above")
62 '("xrightarrow" ["Below"] "Above")
63 '("overset" "Accent symbol" "Symbol")
64 '("underset" "Accent symbol" "Symbol")
70 '("genfrac" "Left delimiter" "Right delimiter" "Thickness"
72 '("cfrac" ["position (l or r)"] t)
73 '("smash" ["where (t or b)"] t)
74 '("sideset" "Left" "Right")
77 '("displaybreak" ["Weight (0..4)"])
78 '("allowdisplaybreaks" ["Weight (1..4)"])
80 '("leftroot" "Push root index left by")
81 '("uproot" "Push root index upward by")
87 '("overleftrightarrow" t)
89 '("underrightarrow" t)
90 '("underleftrightarrow" t)
94 "dots" "dotsb" "dotsc" "dotsi" "dotsm" "dotso" "nobreakdash"
95 "lvert" "rvert" "lVert" "rVert"
96 "iint" "iiint" "iiiint" "idotsint"
100 (append '(("split" . LaTeX-item-equation)
101 ("multline" . LaTeX-item-equation)
102 ("multline*" . LaTeX-item-equation)
103 ("gather" . LaTeX-item-equations)
104 ("gather*" . LaTeX-item-equation)
105 ("gathered" . LaTeX-item-equation)
106 ("align" . LaTeX-item-equations)
107 ("align*" . LaTeX-item-equation)
108 ("aligned" . LaTeX-item-equation)
109 ("alignat" . LaTeX-item-equations)
110 ("alignat*" . LaTeX-item-equation)
111 ("xalignat" . LaTeX-item-equations)
112 ("xalignat*" . LaTeX-item-equation)
113 ("xxalignat" . LaTeX-item-equation)
114 ("flalign" . LaTeX-item-equations)
115 ("flalign*" . LaTeX-item-equation)
116 ("matrix" . LaTeX-item-equation)
117 ("pmatrix" . LaTeX-item-equation)
118 ("bmatrix" . LaTeX-item-equation)
119 ("Bmatrix" . LaTeX-item-equation)
120 ("vmatrix" . LaTeX-item-equation)
121 ("Vmatrix" . LaTeX-item-equation)
122 ("cases" . LaTeX-item-equation))
125 ;; When `LaTeX-amsmath-label' is nil, use value of LaTeX-equation-label:
126 (unless LaTeX-amsmath-label
127 (setq LaTeX-amsmath-label LaTeX-equation-label))
129 (setq LaTeX-label-alist
130 (append '(("align" . LaTeX-amsmath-label)
131 ("alignat" . LaTeX-amsmath-label)
132 ("xalignat" . LaTeX-amsmath-label)
133 ("multline" . LaTeX-amsmath-label)
134 ("flalign" . LaTeX-amsmath-label)
135 ("gather" . LaTeX-amsmath-label))
138 ;; amsmath includes amstext, amsbsy, & amsopn.
139 ;; So we run their hooks, too.
140 (TeX-run-style-hooks "amstext" "amsbsy" "amsopn")
142 ;; If RefTeX is loaded, make it recognize the amsmath environments.
143 (when (fboundp 'reftex-add-to-label-alist)
144 (reftex-add-to-label-alist '(AMSTeX))))))
146 (defun LaTeX-amsmath-env-alignat (env)
147 (let ((ncols (read-string "Number of columns: ")))
148 (LaTeX-insert-environment env (concat TeX-grop ncols TeX-grcl))
149 (and (not (string= "xxalignat" env))
150 (not (string= "*" (substring env -1)))
152 (newline-and-indent))))
154 (defun LaTeX-amsmath-env-aligned (env)
155 (let ((where (read-string "(optional) Vertical position (t or b): ")))
156 (if (string= where "")
158 (setq where (concat "[" where "]")))
159 (LaTeX-insert-environment env where)))
161 (defun LaTeX-item-equation ()
166 (indent-according-to-mode))
168 (defun LaTeX-item-equations ()
169 (LaTeX-item-equation)
170 (let ((environment (LaTeX-current-environment 1)))
171 (and (LaTeX-label environment)
172 (newline-and-indent))))
174 (defvar LaTeX-amsmath-package-options '("intlimits" "nointlimits"
175 "sumlimits" "nosumlimits"
176 "namelimits" "nonamelimits"
177 "leqno" "reqno" "centertags"
178 "tbtags" "cmex10" "fleqn" "?")
179 "Package options for the amsmath package.")
181 ;;; amsmath.el ends here.