]> code.delx.au - gnu-emacs-elpa/blob - auctex-11.86/style/amsmath.el
Initial repository contents
[gnu-emacs-elpa] / auctex-11.86 / style / amsmath.el
1 ;;; amsmath.el --- Style hook for the AMS-LaTeX amsmath package.
2
3 ;; Copyright (C) 2002, 2005 Free Software Foundation, Inc.
4 ;; FIXME: What about the copyright for <= 2001?
5
6 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
7 ;; Maintainer: auctex-devel@gnu.org
8
9 ;; This file is part of AUCTeX.
10
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)
14 ;; any later version.
15
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.
20
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
24 ;; 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;; This will also load the amstext, amsbsy and amsopn style files.
29
30 ;;; Code:
31
32 (TeX-add-style-hook "amsmath"
33 (function
34 (lambda ()
35
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*"
49 "split"
50 "cases"
51 "matrix" "smallmatrix" "pmatrix" "bmatrix" "Bmatrix" "vmatrix" "Vmatrix"
52 "subequations"
53 '("subarray" "Alignment"))
54
55 (TeX-add-symbols
56 '("eqref" TeX-arg-ref)
57 '("numberwithin" TeX-arg-counter "Section level")
58 '("raisetag" "Dimension")
59 '("intertext" t)
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")
65 '("dfrac" 2)
66 '("tfrac" 2)
67 '("binom" 2)
68 '("dbinom" 2)
69 '("tbinom" 2)
70 '("genfrac" "Left delimiter" "Right delimiter" "Thickness"
71 "Mathstyle" 2)
72 '("cfrac" ["position (l or r)"] t)
73 '("smash" ["where (t or b)"] t)
74 '("sideset" "Left" "Right")
75 '("tag" "(Tag)")
76 '("tag*" "Tag")
77 '("displaybreak" ["Weight (0..4)"])
78 '("allowdisplaybreaks" ["Weight (1..4)"])
79 '("substack" t)
80 '("leftroot" "Push root index left by")
81 '("uproot" "Push root index upward by")
82 '("boxed" t)
83 '("mspace" t)
84 '("mod" t)
85 '("pmod" t)
86 '("pod" t)
87 '("overleftrightarrow" t)
88 '("underleftarrow" t)
89 '("underrightarrow" t)
90 '("underleftrightarrow" t)
91 '("dddot" t)
92 '("ddddot" t)
93 "bmod" "notag"
94 "dots" "dotsb" "dotsc" "dotsi" "dotsm" "dotso" "nobreakdash"
95 "lvert" "rvert" "lVert" "rVert"
96 "iint" "iiint" "iiiint" "idotsint"
97 )
98
99 (setq LaTeX-item-list
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))
123 LaTeX-item-list))
124
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))
128
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))
136 LaTeX-label-alist))
137
138 ;; amsmath includes amstext, amsbsy, & amsopn.
139 ;; So we run their hooks, too.
140 (TeX-run-style-hooks "amstext" "amsbsy" "amsopn")
141
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))))))
145
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)))
151 (LaTeX-label env)
152 (newline-and-indent))))
153
154 (defun LaTeX-amsmath-env-aligned (env)
155 (let ((where (read-string "(optional) Vertical position (t or b): ")))
156 (if (string= where "")
157 (setq where "")
158 (setq where (concat "[" where "]")))
159 (LaTeX-insert-environment env where)))
160
161 (defun LaTeX-item-equation ()
162 (end-of-line 0)
163 (just-one-space)
164 (insert "\\\\")
165 (forward-line 1)
166 (indent-according-to-mode))
167
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))))
173
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.")
180
181 ;;; amsmath.el ends here.