* [PATCH] LaTeX export: arbitrary float environments
@ 2021-04-04 18:46 Thomas S. Dye
2021-05-01 11:08 ` Timothy
2021-05-15 13:22 ` Bastien
0 siblings, 2 replies; 5+ messages in thread
From: Thomas S. Dye @ 2021-04-04 18:46 UTC (permalink / raw)
To: org-mode
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
Aloha all,
LaTeX users are able to define arbitrary float types, e.g. with
the float package. The attached patch makes them accessible from
Org mode.
This is a follow on to my efforts several years ago to support the
Tufte-LaTeX package in Org mode, and a suggestion at the time (by
Rasmus iirc) to implement an :environment attribute for LaTeX
export. This patch achieves a similar goal, but is a bit lighter
imo.
Let me know if you have questions.
All the best,
Tom
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 3545 bytes --]
From 5154901b781f93d08851f96431c976f010fc420c Mon Sep 17 00:00:00 2001
From: "Thomas S. Dye" <tsd@tsdye.online>
Date: Sun, 4 Apr 2021 08:11:40 -1000
Subject: [PATCH] LaTeX export: arbitrary float environments
* lisp/ox-latex.el (`org-latex--inline-image', `org-latex--decorate
table'): recognize arbitrary :float value.
LaTeX users are able to define arbitrary float types. This patch
makes them accessible from Org mode.
* etc/ORG-NEWS: Announce new :float capability.
---
etc/ORG-NEWS | 6 +++++-
lisp/ox-latex.el | 16 +++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 9fc126b2f..cdfb1c727 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -12,6 +12,10 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.5 (not yet released)
** New options and settings
+*** LaTeX attribute ~:float~ now passes through arbitrary values
+
+LaTeX users are able to define arbitrary float types, e.g. with the float package. The Org mode LaTeX exporter is now able to process and export arbitrary float types. The user is responsible for ensuring that Org mode configures LaTeX to process any new float type.
+
*** Option ~org-hidden-keywords~ now also applies to #+SUBTITLE:
The option ~org-hidden-keywords~ previously applied
@@ -106,7 +110,7 @@ behavior.
By default ox-html now inlines webp images.
** New features
-*** =ob-python= improvements to =:return= header argument
+*** =ob-python= improvements to =:return= header argument
The =:return= header argument in =ob-python= now works for session
blocks as well as non-session blocks. Also, it now works with the
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 376d27a07..514801d7c 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2377,6 +2377,7 @@ used as a communication channel."
((string= float "sideways") 'sideways)
((string= float "multicolumn") 'multicolumn)
((and (plist-member attr :float) (not float)) 'nonfloat)
+ (float float)
((or float
(org-element-property :caption parent)
(org-string-nw-p (plist-get attr :caption)))
@@ -2470,6 +2471,18 @@ used as a communication channel."
nil t))))
;; Return proper string, depending on FLOAT.
(pcase float
+ ((and (pred stringp) env-string)
+ (format "\\begin{%s}%s
+%s%s
+%s%s
+%s\\end{%s}"
+ env-string
+ placement
+ (if caption-above-p caption "")
+ (if center "\\centering" "")
+ comment-include image-code
+ (if caption-above-p "" caption)
+ env-string))
(`wrap (format "\\begin{wrapfigure}%s
%s%s
%s%s
@@ -3200,7 +3213,7 @@ centered."
(defun org-latex--decorate-table (table attributes caption above? info)
"Decorate TABLE string with caption and float environment.
-ATTRIBUTES is the plist containing is LaTeX attributes. CAPTION
+ATTRIBUTES is the plist containing LaTeX attributes. CAPTION
is its caption, as a string or nil. It is located above the
table if ABOVE? is non-nil. INFO is the plist containing current
export parameters.
@@ -3211,6 +3224,7 @@ Return new environment, as a string."
(cond ((and (not float) (plist-member attributes :float)) nil)
((member float '("sidewaystable" "sideways")) "sidewaystable")
((equal float "multicolumn") "table*")
+ (float float)
((or float (org-string-nw-p caption)) "table")
(t nil))))
(placement
--
2.25.1
[-- Attachment #3: Type: text/plain, Size: 45 bytes --]
--
Thomas S. Dye
https://tsdye.online/tsdye
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] LaTeX export: arbitrary float environments
2021-04-04 18:46 [PATCH] LaTeX export: arbitrary float environments Thomas S. Dye
@ 2021-05-01 11:08 ` Timothy
2021-05-01 17:20 ` Thomas S. Dye
2021-05-15 13:22 ` Bastien
1 sibling, 1 reply; 5+ messages in thread
From: Timothy @ 2021-05-01 11:08 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: emacs-orgmode
Hi Thomas,
On the surface, this looks reasonable to me :)
Just commenting on some technicalities with the patch itself:
- In ORG-NEWS it would be good to wrap the content over multiple lines
instead of having a single 270 char line :)
- You seem to have an anomalous change to the ob-python :return entry
- I don't think your patch subject follows the convention for Org, it
should be:
"main file/feature: overall change summary"
so, something like
"ox-latex: allow for arbitrary float environments"
rather than
"LaTeX export: arbitrary float environments"
Thanks for the patch :)
Timothy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] LaTeX export: arbitrary float environments
2021-05-01 11:08 ` Timothy
@ 2021-05-01 17:20 ` Thomas S. Dye
2021-05-01 17:31 ` Timothy
0 siblings, 1 reply; 5+ messages in thread
From: Thomas S. Dye @ 2021-05-01 17:20 UTC (permalink / raw)
To: Timothy; +Cc: emacs-orgmode
Aloha Timothy,
Thanks for your kind response.
Sorry for the clumsy patch, which I guess would also benefit from
an addition to the manual, as well?
Larger question: do we really want to tinker with ob-latex in this
way? Or, should changes like this patch follow a path indicated
by Tim Cross and into their own package, say ob-latex-ex, which
might someday replace ob-latex if it proved useful and stable?
All the best,
Tom
Timothy <tecosaur@gmail.com> writes:
> Hi Thomas,
>
> On the surface, this looks reasonable to me :)
>
> Just commenting on some technicalities with the patch itself:
> - In ORG-NEWS it would be good to wrap the content over multiple
> lines
> instead of having a single 270 char line :)
> - You seem to have an anomalous change to the ob-python :return
> entry
> - I don't think your patch subject follows the convention for
> Org, it
> should be:
> "main file/feature: overall change summary"
> so, something like
> "ox-latex: allow for arbitrary float environments"
> rather than
> "LaTeX export: arbitrary float environments"
>
> Thanks for the patch :)
>
> Timothy
--
Thomas S. Dye
https://tsdye.online/tsdye
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] LaTeX export: arbitrary float environments
2021-05-01 17:20 ` Thomas S. Dye
@ 2021-05-01 17:31 ` Timothy
0 siblings, 0 replies; 5+ messages in thread
From: Timothy @ 2021-05-01 17:31 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: emacs-orgmode
Thomas S. Dye <tsd@tsdye.online> writes:
> Aloha Timothy,
:waves:
> Sorry for the clumsy patch, which I guess would also benefit from an addition to
> the manual, as well?
No problem, we all start somewhere :) (and I know I'm still making mistakes)
An update to the manual to describe the changed behaviour would be good.
If you'd like you could wait till a core maintainer says this looks good
before going to that effort, or you could add it in now so it's all in a
single patch --- as long as something happens.
> Larger question: do we really want to tinker with ob-latex in this way? Or,
> should changes like this patch follow a path indicated by Tim Cross and into
> their own package, say ob-latex-ex, which might someday replace ob-latex if it
> proved useful and stable?
I don't think LaTeX support is likely to leave Org any time soon, so at
least until a core maintainer tells you otherwise I'd be inclined to
proceed with your current patch.
If this was a huge/transformational change I may be more uncertain, but
this looks fairly simple to me at least.
--
Timothy
> All the best,
> Tom
>
> Timothy <tecosaur@gmail.com> writes:
>
>> Hi Thomas,
>>
>> On the surface, this looks reasonable to me :)
>>
>> Just commenting on some technicalities with the patch itself:
>> - In ORG-NEWS it would be good to wrap the content over multiple lines
>> instead of having a single 270 char line :)
>> - You seem to have an anomalous change to the ob-python :return entry
>> - I don't think your patch subject follows the convention for Org, it
>> should be:
>> "main file/feature: overall change summary"
>> so, something like
>> "ox-latex: allow for arbitrary float environments"
>> rather than
>> "LaTeX export: arbitrary float environments"
>>
>> Thanks for the patch :)
>>
>> Timothy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] LaTeX export: arbitrary float environments
2021-04-04 18:46 [PATCH] LaTeX export: arbitrary float environments Thomas S. Dye
2021-05-01 11:08 ` Timothy
@ 2021-05-15 13:22 ` Bastien
1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2021-05-15 13:22 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: org-mode
Hi Thomas,
"Thomas S. Dye" <tsd@tsdye.online> writes:
> LaTeX users are able to define arbitrary float types, e.g. with the
> float package. The attached patch makes them accessible from Org
> mode.
Applied in master with minor enhancements in the commit message and
the code (removing a useless check against the value of float.)
Thanks,
--
Bastien
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-15 13:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-04 18:46 [PATCH] LaTeX export: arbitrary float environments Thomas S. Dye
2021-05-01 11:08 ` Timothy
2021-05-01 17:20 ` Thomas S. Dye
2021-05-01 17:31 ` Timothy
2021-05-15 13:22 ` Bastien
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).