Hello,

attached is a small patch to give tables their own default placement in
LaTeX export.  Up to now, tables have used the default placement for
figures but figures and tables are very different creatures so it does
not make sense to have just one default for both.

This patch unfortunately could break documents (if people have changed
the default for figures, expecting that change to apply to tables as
well) but I see no way to avoid this.  So maybe not worth incorporating
but I leave that decision to others.

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.5.2-385-g37d8bc in Emacs 29.0.50
>From 77d94298beb3a1b215e7602beba46b81e827b3a1 Mon Sep 17 00:00:00 2001
From: Eric S Fraga <e.fr...@ucl.ac.uk>
Date: Fri, 18 Feb 2022 12:23:01 +0000
Subject: [PATCH] lisp/ox-latex.el: give tables their own placement default

* ox-latex.el (org-latex--org-table): define and use a new variable,
org-latex-default-table-position, for setting the default placement
option for the export of tables.
---
 etc/ORG-NEWS     |  5 +++++
 lisp/ox-latex.el | 11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5a94e737e..506161937 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -100,6 +100,11 @@ argument.
 
 ** Miscellaneous
 
+*** Tables now have separate default placement option for LaTeX export
+
+Tables and figures now have separate settings for the default
+placement in LaTeX export.
+
 *** Styles are customizable in ~biblatex~ citation processor
 
 It is now possible to add new styles or modify old ones in ~biblatex~
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5dda9b3ab..48efc7d98 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -120,6 +120,7 @@
     (:latex-caption-above nil nil org-latex-caption-above)
     (:latex-classes nil nil org-latex-classes)
     (:latex-default-figure-position nil nil org-latex-default-figure-position)
+    (:latex-default-table-position nil nil org-latex-default-table-position)
     (:latex-default-table-environment nil nil org-latex-default-table-environment)
     (:latex-default-quote-environment nil nil org-latex-default-quote-environment)
     (:latex-default-table-mode nil nil org-latex-default-table-mode)
@@ -753,6 +754,14 @@ environment."
   :package-version '(Org . "9.0")
   :safe #'stringp)
 
+(defcustom org-latex-default-table-position "htbp"
+  "Default position for LaTeX tables."
+  :group 'org-export-latex
+  :type 'string
+  :version "26.1"
+  :package-version '(Org . "9.0")
+  :safe #'stringp)
+
 (defcustom org-latex-inline-image-rules
   `(("file" . ,(rx "."
                    (or "pdf" "jpeg" "jpg" "png" "ps" "eps" "tikz" "pgf" "svg")
@@ -3274,7 +3283,7 @@ Return new environment, as a string."
 		  (t nil))))
 	 (placement
 	  (or (plist-get attributes :placement)
-	      (format "[%s]" (plist-get info :latex-default-figure-position))))
+	      (format "[%s]" (plist-get info :latex-default-table-position))))
 	 (center? (if (plist-member attributes :center)
 		      (plist-get attributes :center)
 		    (plist-get info :latex-tables-centered)))
-- 
2.30.2

Reply via email to