auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] Changing caption insertion within longtable


From: Arash Esbati
Subject: Re: [AUCTeX-devel] Changing caption insertion within longtable
Date: Tue, 13 Dec 2016 08:25:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1

Arash Esbati <address@hidden> writes:

> Following up myself, I plan to append the following patch to
> longtable.el:

Please ignore my last message.  The patch should look like this:

--8<---------------cut here---------------start------------->8---
diff --git a/style/longtable.el b/style/longtable.el
index 76c397b..8340a0e 100644
--- a/style/longtable.el
+++ b/style/longtable.el
@@ -29,6 +29,23 @@

 ;;; Code:

+(defvar LaTeX-longtable-skipping-regexp
+  (regexp-opt '("[l]" "[r]" "[c]" ""))
+  "Regexp matching between \\begin{longtable} and column specification.
+For longtable environments only.")
+
+(defun LaTeX-item-longtable (&optional suppress)
+  "Insert line break macro on the last line and suitable number of &'s.
+For longtable environments.  If SUPPRESS is non-nil, do not
+insert line break macro."
+  (unless suppress
+    (save-excursion
+      (end-of-line 0)
+      (just-one-space)
+      (TeX-insert-macro "\\")))
+  (LaTeX-insert-ampersands
+   LaTeX-longtable-skipping-regexp 'LaTeX-array-count-columns))
+
 (TeX-add-style-hook
  "longtable"
  (lambda ()
@@ -64,7 +81,9 @@
                        (LaTeX-fill-paragraph)
                        ;; Insert a new line and indent
                        (LaTeX-newline)
-                       (indent-according-to-mode))))))
+                       (indent-according-to-mode))
+                     ;; Insert suitable number of &'s, suppress line break
+                     (LaTeX-item-longtable t)))))

    (TeX-add-symbols
     ;; Commands to end table rows
@@ -91,6 +110,9 @@
    ;; custome values.
    (add-to-list 'LaTeX-label-alist '("longtable" . LaTeX-table-label) t)

+   ;; Append longtable to `LaTeX-item-list' with `LaTeX-item-longtable'
+   (add-to-list 'LaTeX-item-list '("longtable" . LaTeX-item-longtable) t)
+
    ;; Fontification
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
--8<---------------cut here---------------end--------------->8---

> After that, suitable number of &'s are inserted when `C-c C-e longtable
> RET' is invoked and `M-RET' also does the right thing.
>
> Any comments welcome.

Best, Arash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]