all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Vladimir Nikishkin <lockywolf@gmail.com>
To: 55329@debbugs.gnu.org
Subject: bug#55329: [PATCH] Choose latex environment for table.el export
Date: Mon, 09 May 2022 10:30:57 +0800	[thread overview]
Message-ID: <87ee13wi72.fsf@laptop.lockywolf.net> (raw)

Dear Emacs Developers,

Please, consider this patch for inclusion.
This patch slightly generalises the way Emacs' table.el handles
latex export.
Currently, the export always uses the "tabular" environment.
This patch adds a customize option to select a different one, and
adds one built-in suggestion of "longtable", which should be
perfectly compatible with "tabular".

The patch creates 1 new customize variable:
1. table-latex-environment

And changes the following 2 functions:
1. table--generate-source-epilogue
2. table--generate-source-prologue

#+begin_src patch
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 2175900194..eafa3e7b3c 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -753,6 +753,18 @@ table-html-cell-attribute
   :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)
+  :group 'table
+  :local t)
+
 (defcustom table-cals-thead-rows 1
   "Number of top rows to become header rows in CALS table."
   :tag "CALS Header Rows"
@@ -3025,7 +3037,7 @@ table--generate-source-prologue
 		"")))
      ((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 "<!-- This CALS table template is generated by emacs %s -->\n" emacs-version)
@@ -3051,7 +3063,7 @@ table--generate-source-epilogue
      ((eq language 'html)
       (insert "</table>\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
#+end_patch

The copyright disclaimer has been signed by me and submitted to FSF
last August.

-- 
Your sincerely,
Vladimir Nikishkin (MiEr, lockywolf)
(Laptop)





             reply	other threads:[~2022-05-09  2:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  2:30 Vladimir Nikishkin [this message]
2022-05-09 10:05 ` bug#55333: [PATCH] Choose latex environment for table.el export Lars Ingebrigtsen
2022-05-09 11:25 ` bug#55329: " Eli Zaretskii
2022-05-09 11:28   ` Vladimir Nikishkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ee13wi72.fsf@laptop.lockywolf.net \
    --to=lockywolf@gmail.com \
    --cc=55329@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.