[Top][All Lists]

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

[AUCTeX] Some hints for editing tables

From: Mosè Giordano
Subject: [AUCTeX] Some hints for editing tables
Date: Sun, 15 Nov 2015 18:55:56 +0100

Dear all,

as you all know, editing tables in LaTeX can be quite tedious.
Luckily in AUCTeX we got a couple of nice features, auto insertion of
the appropriate &s and a good indentation function in tabular-like
environments, but there is still much room for improvements.[1]

What I often want is to have the table aligned.  Emacs has the great
`align-current' function, by I get tired to manually call it every now
and then, and so I often don't run it all.  In addition, I have
`auto-fill-mode' on, but in order to have the table aligned
auto-filling doesn't really make sense.  So, why don't hack
auto-filling in order to run `align-current'?  Then I came up with
this simple solution:

    (defun mg/LaTeX-auto-fill-function ()
      (if (member (LaTeX-current-environment) '("tabular"))

    (add-hook 'LaTeX-mode-hook
          (lambda ()
            (setq auto-fill-function 'mg/LaTeX-auto-fill-function)))

So, if current environment is tabular, auto-fill-function, triggered
by SPC, RET, and so on, calls `align-current', otherwise the usual
filling function is used (replace `do-auto-fill' wit your favorite

In addition, in order to have tables really visually aligned (useful
for rectangular selection) you should also truncate lines and make
sup/subscript as large as normal characters, unless you already do so.
For this, take a look at

    (defun toggle-LaTeX-rectangular-edit-ready-mode ()
      (if (equal truncate-lines nil)
         'font-latex-subscript-face nil
         :height 1.0)
         'font-latex-superscript-face nil
         :height 1.0)
        (setq truncate-lines t)
        (message "LaTeX-rectangular-edit-ready-mode has been switched on"))
           'font-latex-subscript-face nil
           :height 0.8)
           'font-latex-superscript-face nil
           :height 0.8)
          (setq truncate-lines nil)
          (message "LaTeX-rectangular-edit-ready-mode has been switched off"))))


I want to make it clear I'm not going to include in AUCTeX any of this
features, they're just some hints for you, but they can be highly
inefficient, so use them at your own risk ;-)

Happy TeXing,

[1]  Suggestions welcome.

reply via email to

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