1 ;;; longtable.el --- AUCTeX style for `longtable.sty'.
3 ;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
5 ;; Maintainer: auctex-devel@gnu.org
6 ;; Author: Mosè Giordano <giordano.mose@libero.it>
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 file adds support for `longtable.sty'.
35 (LaTeX-add-environments
36 '("longtable" (lambda (environment)
37 (let ((pos (completing-read (TeX-argument-prompt t nil "Position")
38 '(("l") ("r") ("c"))))
39 (fmt (read-string "Format: " LaTeX-default-format))
40 (caption (read-string "Caption: ")))
41 (setq LaTeX-default-format fmt)
42 (LaTeX-insert-environment environment
44 (unless (zerop (length pos))
45 (concat LaTeX-optop pos LaTeX-optcl))
46 (concat TeX-grop fmt TeX-grcl)))
47 ;; top caption -- do nothing if user skips caption
48 (unless (zerop (length caption))
49 ;; the longtable `\caption' is equivalent to a
50 ;; `\multicolumn', so it needs a `\\' at the
52 (insert TeX-esc "caption" TeX-grop caption TeX-grcl " \\\\")
54 (indent-according-to-mode)
55 ;; ask for a label and insert a new line only
56 ;; if a label is actually inserted
57 (when (LaTeX-label environment 'environment)
59 (indent-according-to-mode)))))))
68 ;; Commands to end table rows
76 ;; Use the enhanced table formatting
77 (add-to-list 'LaTeX-indent-environment-list
78 '("longtable" LaTeX-indent-tabular))
80 ;; Append longtable to `LaTeX-label-alist', in order not to override possible
82 (add-to-list 'LaTeX-label-alist '("longtable" . LaTeX-table-label) t)
85 (when (and (featurep 'font-latex)
86 (eq TeX-install-font-lock 'font-latex-setup))
87 ;; Actually, `\caption*{}' macro takes only one mandatory
88 ;; argument, not an optional one, the following is a workaround
89 ;; to fontify correctly also the standard `\caption[]{}' macro.
90 (font-latex-add-keywords '(("caption" "*[{"))
94 ;; longtable.el ends here