From 6b6b2c11edc46517a3a1ac9f869bdd40adf8a3df Mon Sep 17 00:00:00 2001 From: Vladimir Nikishkin Date: Mon, 9 May 2022 12:03:33 +0200 Subject: [PATCH] Add new user option table-latex-environment * lisp/textmodes/table.el (table-latex-environment): New user option (bug#55333). (table--generate-source-prologue): Use it. --- etc/NEWS | 6 ++++++ lisp/textmodes/table.el | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 5860010f022..92a956c176d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2135,6 +2135,12 @@ This holds the value of the previous call to 'set-locale-environment'. This macro can be used to change the locale temporarily while executing code. +** table.el + +--- +*** New user option 'table-latex-environment'. +This allows switching between "table" and "tabular". + ** Tabulated List Mode +++ diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 2175900194c..5093a994423 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -753,6 +753,16 @@ the cell contents dynamically." :type 'string :group 'table) +(defcustom table-latex-environment "tabular" + "Which tabular-compatible environment to use when generating latex. +\"tabular\" and \"longtable\" are known to work." + :tag "Latex environment used to export tables" + :type '(choice + (const :tag "tabular" "tabular") + (const :tag "longtable" "longtable") + string) + :version "29.1") + (defcustom table-cals-thead-rows 1 "Number of top rows to become header rows in CALS table." :tag "CALS Header Rows" @@ -3025,7 +3035,8 @@ CALS (DocBook DTD): ""))) ((eq language 'latex) (insert (format "%% This LaTeX table template is generated by emacs %s\n" emacs-version) - "\\begin{tabular}{|" (apply #'concat (make-list (length col-list) "l|")) "}\n" + "\\begin{" table-latex-environment "}{|" + (apply #'concat (make-list (length col-list) "l|")) "}\n" "\\hline\n")) ((eq language 'cals) (insert (format "\n" emacs-version) @@ -3051,7 +3062,7 @@ CALS (DocBook DTD): ((eq language 'html) (insert "\n")) ((eq language 'latex) - (insert "\\end{tabular}\n")) + (insert "\\end{" table-latex-environment "}\n")) ((eq language 'cals) (set-marker-insertion-type (table-get-source-info 'colspec-marker) t) ;; insert before (save-excursion -- 2.39.2