* [patch] give tables their own default placement in LaTeX export
@ 2022-02-18 12:37 Eric S Fraga
2022-11-10 2:19 ` Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: Eric S Fraga @ 2022-02-18 12:37 UTC (permalink / raw)
To: Emacs Org mode mailing list
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox-latex.el-give-tables-their-own-placement-def.patch --]
[-- Type: text/x-diff, Size: 2514 bytes --]
From 77d94298beb3a1b215e7602beba46b81e827b3a1 Mon Sep 17 00:00:00 2001
From: Eric S Fraga <e.fraga@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] give tables their own default placement in LaTeX export
2022-02-18 12:37 [patch] give tables their own default placement in LaTeX export Eric S Fraga
@ 2022-11-10 2:19 ` Ihor Radchenko
2023-04-05 9:33 ` Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2022-11-10 2:19 UTC (permalink / raw)
To: Eric S Fraga; +Cc: Emacs Org mode mailing list
Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> 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.
Thanks for the patch, and sorry for the late reply.
This looks like a useful addition.
> 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.
There is a way to avoid this. See the comments below.
> 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.
Please start sentences from capital letter and quote `symbols'.
> +*** Tables now have separate default placement option for LaTeX export
> +
> +Tables and figures now have separate settings for the default
> +placement in LaTeX export.
Please mention the new variable name.
> +(defcustom org-latex-default-table-position "htbp"
You can use
(defcustom org-latex-default-table-position nil
as the default value. Then, you can fallback for figure position in the
code when the value is nil. Need to update docstring accordingly.
> + "Default position for LaTeX tables."
> + :group 'org-export-latex
> + :type 'string
> + :version "26.1"
:version is not needed.
> + :package-version '(Org . "9.0")
9.6
> (or (plist-get attributes :placement)
> - (format "[%s]" (plist-get info :latex-default-figure-position))))
> + (format "[%s]" (plist-get info :latex-default-table-position))))
Can use
(or (plist-get info :latex-default-table-position)
(plist-get info :latex-default-figure-position))
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-05 9:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18 12:37 [patch] give tables their own default placement in LaTeX export Eric S Fraga
2022-11-10 2:19 ` Ihor Radchenko
2023-04-05 9:33 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).