emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ox-latex.el: Fix the case of latex-caption-above t
@ 2024-01-15 21:07 Mads Bach Villadsen
  2024-01-15 21:18 ` Mads Bach Villadsen
  2024-01-16 11:34 ` Ihor Radchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Mads Bach Villadsen @ 2024-01-15 21:07 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2241 bytes --]

Hi,

The documentation for `org-latex-caption-above’ seems to imply that it can be set to a non-nil value to always place captions at the start of environments, instead of the end. However, with a non-nil value which is not a sequence, exporting something like the following from org causes an error:

[latexpCfhTz_350451aa2511e1a6f5ea1cf164b4329f062726cb.png]

The issue is that in `org-latex-latex-environment’, in the expression (memq type (append (plist-get info :latex-caption-above) ’(math))))) the first argument to `append’ gets expanded to the value of `org-latex-caption-above’ (at least for this example), which may not be a sequence.

I think the attached patch fixes this, but I don’t write much lisp, so maybe there’s a better way to handle this.

Best, Mads

From f28da9e3c80f03d70a9a6eced5029e12fc75ab99 Mon Sep 17 00:00:00 2001 From: Mads Bach Villadsen <mbvilladsen@pm.me> Date: Mon, 15 Jan 2024 15:37:29 -0500 Subject: [PATCH] ox-latex.el: Fix the case of latex-caption-above t

lisp/ox-latex.el: (org-latex-latex-environment): Check whether the property

`:latex-caption-above’ is a sequence or not, and handle them separately.

Correctly handle the case where org-latex-caption-above is non-nil and not a list of symbols. The documentation of org-latex-caption-above implies that it can be set to a non-nil value to place captions at the beginning of all environments.

TINYCHANGE — lisp/ox-latex.el | 4 +- 1 file changed, 3 insertions(+), 1 deletion(-)

diff –git a/lisp/ox-latex.el b/lisp/ox-latex.el index b36c46f13..4f2a94a20 100644 — a/lisp/ox-latex.el + b/lisp/ox-latex.el @@ -2682,7 +2682,9 @@ CONTENTS is nil. INFO is a plist holding contextual information.“ (org-latex–label latex-environment info nil t) (org-latex–caption/label-string latex-environment info))) (caption-above-p

- (memq type (append (plist-get info :latex-caption-above) ’(math)))))
- (let ((latex-caption-above (plist-get info :latex-caption-above)))
- (if (sequencep latex-caption-above) (memq type (append latex-caption-above ’(math)))
- latex-caption-above)))) (if (not (or (org-element-property :name latex-environment) (org-element-property :caption latex-environment))) value

– 2.39.3 (Apple Git-145)

[-- Attachment #1.2: Type: text/html, Size: 6205 bytes --]

[-- Attachment #2: latexpCfhTz_350451aa2511e1a6f5ea1cf164b4329f062726cb.png --]
[-- Type: image/png, Size: 224 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ox-latex.el: Fix the case of latex-caption-above t
  2024-01-15 21:07 [PATCH] ox-latex.el: Fix the case of latex-caption-above t Mads Bach Villadsen
@ 2024-01-15 21:18 ` Mads Bach Villadsen
  2024-01-16 11:34 ` Ihor Radchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Mads Bach Villadsen @ 2024-01-15 21:18 UTC (permalink / raw)
  To: emacs-orgmode

#+OPTIONS: html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil 
 email:nil tex:dvipng d:nil
#+STARTUP: hidestars indent inlineimages
:PROPERTIES:
:reply-to: 
("/var/folders/b9/gky2rvnj4xxd0gl0x7n92j8r0000gn/T/mm-kl9uCr.html" 
"/var/folders/b9/gky2rvnj4xxd0gl0x7n92j8r0000gn/T/cidvUcUMz")
:attachment: nil
:alternatives: (utf-8 html)
:END:

My message seems to have been HTML-ified by mistake, so I'm 
sending it again.

The documentation for `org-latex-caption-above’ seems to imply 
that it can be set to a non-nil value to always place captions at 
the start of environments, instead of the end. However, with a 
non-nil value which is not a sequence, exporting something like 
the following from org causes an error:
\begin{align*}
x
\end{align*}

The issue is that in `org-latex-latex-environment’, in the 
expression
  (memq type (append (plist-get info :latex-caption-above) 
  ’(math)))))
the first argument to `append’ gets expanded to the value of 
`org-latex-caption-above’ (at least for this example), which may 
not be a sequence.

I think the attached patch fixes this, but I don’t write much 
lisp, so maybe there’s a better way to handle this.

Best,
Mads


From f28da9e3c80f03d70a9a6eced5029e12fc75ab99 Mon Sep 17 00:00:00 
2001
From: Mads Bach Villadsen <mbvilladsen@pm.me>
Date: Mon, 15 Jan 2024 15:37:29 -0500
Subject: [PATCH] ox-latex.el: Fix the case of latex-caption-above 
t

* lisp/ox-latex.el: (org-latex-latex-environment): Check whether 
  the property
`:latex-caption-above' is a sequence or not, and handle them 
separately.

Correctly handle the case where org-latex-caption-above is non-nil 
and
not a list of symbols. The documentation of 
org-latex-caption-above
implies that it can be set to a non-nil value to place captions at 
the
beginning of all environments.

TINYCHANGE
---
 lisp/ox-latex.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index b36c46f13..4f2a94a20 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2682,7 +2682,9 @@ CONTENTS is nil.  INFO is a plist holding 
contextual information."
 			(org-latex--label latex-environment info nil t)
 		      (org-latex--caption/label-string latex-environment 
 info)))
 	   (caption-above-p
-	    (memq type (append (plist-get info :latex-caption-above) 
         '(math)))))
+            (let ((latex-caption-above (plist-get info 
:latex-caption-above)))
+              (if (sequencep latex-caption-above) (memq type 
(append latex-caption-above '(math)))
+                latex-caption-above))))
       (if (not (or (org-element-property :name latex-environment)
 		   (org-element-property :caption latex-environment)))
 	  value
--
2.39.3 (Apple Git-145)



--citation follows this line (read-only)--
Mads Bach Villadsen <mbvilladsen@pm.me> writes:

Hi,

The documentation for `org-latex-caption-above’ seems to imply 
that it can be set to a non-nil value to always place captions at 
the start of
environments, instead of the end. However, with a non-nil value 
which is not a sequence, exporting something like the following 
from org causes
an error:

latexpCfhTz_350451aa2511e1a6f5ea1cf164b4329f062726cb.png

The issue is that in `org-latex-latex-environment’, in the 
expression (memq type (append (plist-get info 
:latex-caption-above) ’(math))))) the first
argument to `append’ gets expanded to the value of 
`org-latex-caption-above’ (at least for this example), which may 
not be a sequence.

I think the attached patch fixes this, but I don’t write much 
lisp, so maybe there’s a better way to handle this.

Best, Mads

From f28da9e3c80f03d70a9a6eced5029e12fc75ab99 Mon Sep 17 00:00:00 
2001 From: Mads Bach Villadsen <mbvilladsen@pm.me> Date: Mon,
15 Jan 2024 15:37:29 -0500 Subject: [PATCH] ox-latex.el: Fix the 
case of latex-caption-above t

lisp/ox-latex.el: (org-latex-latex-environment): Check whether the 
property

`:latex-caption-above’ is a sequence or not, and handle them 
separately.

Correctly handle the case where org-latex-caption-above is non-nil 
and not a list of symbols. The documentation of 
org-latex-caption-above implies
that it can be set to a non-nil value to place captions at the 
beginning of all environments.

TINYCHANGE — lisp/ox-latex.el | 4 +- 1 file changed, 3 
insertions(+), 1 deletion(-)

diff –git a/lisp/ox-latex.el b/lisp/ox-latex.el index 
b36c46f13..4f2a94a20 100644 — a/lisp/ox-latex.el + 
b/lisp/ox-latex.el @@ -2682,7 +2682,9 @@
CONTENTS is nil. INFO is a plist holding contextual information.“ 
(org-latex–label latex-environment info nil t) 
(org-latex–caption/label-string
latex-environment info))) (caption-above-p

,* (memq type (append (plist-get info :latex-caption-above) 
’(math)))))
,* (let ((latex-caption-above (plist-get info 
:latex-caption-above)))
,* (if (sequencep latex-caption-above) (memq type (append 
latex-caption-above ’(math)))
,* latex-caption-above)))) (if (not (or (org-element-property 
:name latex-environment) (org-element-property :caption 
latex-environment))) value

– 2.39.3 (Apple Git-145)



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ox-latex.el: Fix the case of latex-caption-above t
  2024-01-15 21:07 [PATCH] ox-latex.el: Fix the case of latex-caption-above t Mads Bach Villadsen
  2024-01-15 21:18 ` Mads Bach Villadsen
@ 2024-01-16 11:34 ` Ihor Radchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2024-01-16 11:34 UTC (permalink / raw)
  To: Mads Bach Villadsen; +Cc: emacs-orgmode

Mads Bach Villadsen <mbvilladsen@pm.me> writes:

> The documentation for `org-latex-caption-above’ seems to imply that it can be set to a non-nil value to always place captions at the start of environments, instead of the end. However, with a non-nil value which is not a sequence, exporting something like the following from org causes an error:

Thanks for reporting!
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d51723102
I used a different approach to fix the problem.
Canceled; (patch)

-- 
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:[~2024-01-17  7:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15 21:07 [PATCH] ox-latex.el: Fix the case of latex-caption-above t Mads Bach Villadsen
2024-01-15 21:18 ` Mads Bach Villadsen
2024-01-16 11:34 ` 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).