Hey Ihor,

On 2025-10-18 10:01, Ihor Radchenko wrote:
> --8<--
> I prefer option 2.
> 
>> 2. Use a restricted-sexp to check membership:

Done in v2 (attached) along with the following changes from my other
email.

On 2025-10-13 16:49, Jacob S. Gordon wrote:
>> Why not simply leaving the guard check and then putting the rest into
>> the body?
> 
> --8<--
> Moved inside the body in v2.
> 
>> Also, we need to mark the change in the variable meaning via 
>> :package-version.
>> --8<--
>> :package-version, not :version. :version should only be used for
>> internal Emacs libraries.
> 
> Done in v2, both are marked with :package-version '(Org . "9.8") only.
> 
>> Also, please add a record announcing the new custom option in etc/ORG-NEWS.
> 
> Added this, and the change in org-odt-with-latex in v2.

Thanks,

-- 
Jacob S. Gordon
[email protected]
Please avoid sending me HTML emails and MS Office documents.
https://useplaintext.email/#etiquette
From c54cfa5237fb9b832f2df4fcbaf5ac73e64c017e Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Sat, 1 Nov 2025 02:07:37 -0400
Subject: [PATCH v2] ox-odt: Allow LaTeX fragment conversion from any preview method

Jacob S. Gordon (3):
  ox-odt: Align 'org-odt-with-latex' with export behavior
  ox-odt: Allow LaTeX fragment conversion from any preview method
  ox-odt: Add option to specify path of generated MathML files

 etc/ORG-NEWS   |  12 ++++++
 lisp/org.el    |   9 +++++
 lisp/ox-odt.el | 102 ++++++++++++++++++++++++++-----------------------
 3 files changed, 76 insertions(+), 47 deletions(-)

Range-diff against v1:
1:  e18f01480 ! 1:  a84d56a5e ox-odt: Align 'org-odt-with-latex' with export behavior
    @@ Commit message
         ox-odt: Align 'org-odt-with-latex' with export behavior
     
         * lisp/ox-odt.el (org-odt-with-latex): Remove 'mathjax', add missing
    -    'mathml' and 'dvisvgm' options, and clarify when 'verbatim' is used as
    -    a fallback.
    +    t, 'mathml', and 'dvisvgm' options, and clarify when 'verbatim' is
    +    used as a fallback.
         (org-odt--translate-latex-fragments): Update comment.
     
      ## lisp/ox-odt.el ##
    @@ lisp/ox-odt.el: When set, the exporter will process LaTeX environments and
     -`verbatim'     Keep everything in verbatim
     -`dvipng'       Process the LaTeX fragments to images.  This will also
     -               include processing of non-math environments.
    +-`imagemagick'  Convert the LaTeX fragments to pdf files and use
    +-               imagemagick to convert pdf files to png files.
    +-`mathjax'      Do MathJax preprocessing and arrange for MathJax.js to
    +-               be loaded.
     +t, `mathml'    Convert the LaTeX fragments to MathML if the
     +               `org-latex-to-mathml-convert-command' is usable.
     +`dvipng'       Process the LaTeX fragments to PNG images.  This will
     +               also include processing of non-math environments.
    - `imagemagick'  Convert the LaTeX fragments to pdf files and use
    -                imagemagick to convert pdf files to png files.
    --`mathjax'      Do MathJax preprocessing and arrange for MathJax.js to
    --               be loaded.
    ++`imagemagick'  Convert the LaTeX fragments to PDF files and use
    ++               imagemagick to convert PDF files to PNG files.
     +`dvisvgm'      Process the LaTeX fragments to SVG images.  This will
     +               also include processing of non-math environments.
     +`verbatim'     Keep everything in verbatim.
    @@ lisp/ox-odt.el: When set, the exporter will process LaTeX environments and
        :version "24.4"
        :package-version '(Org . "8.0")
        :type '(choice
    - 	  (const :tag "Do not process math in any way" nil)
    +-	  (const :tag "Do not process math in any way" nil)
     -	  (const :tag "Leave math verbatim" verbatim)
    -+	  (const :tag "Convert fragments to MathML" mathml)
    - 	  (const :tag "Use dvipng to make images" dvipng)
    - 	  (const :tag "Use imagemagick to make images" imagemagick)
    +-	  (const :tag "Use dvipng to make images" dvipng)
    +-	  (const :tag "Use imagemagick to make images" imagemagick)
     -	  (other :tag "Use MathJax to display math" mathjax)))
    -+	  (const :tag "Use dvisvgm to make images" dvisvgm)
    -+	  (const :tag "Leave math verbatim" verbatim)))
    ++          (const :tag "Do not process math in any way" nil)
    ++          (choice :tag "Convert fragments to MathML" :value t
    ++                  (const t)
    ++                  (const mathml))
    ++          (const :tag "Use dvipng to make images" dvipng)
    ++          (const :tag "Use imagemagick to make images" imagemagick)
    ++          (const :tag "Use dvisvgm to make images" dvisvgm)
    ++          (const :tag "Leave math verbatim" verbatim)))
      
      
      ;;;; Links
2:  9da7d0417 ! 2:  c13647630 ox-odt: Allow LaTeX fragment conversion from any preview method
    @@ Commit message
         user-defined symbols.  Any symbol in 'org-preview-latex-process-alist'
         can now be used.
     
    -    * lisp/ox-odt.el (org-odt-with-latex): Replace specific conversion
    -    methods with a generic symbol, mirroring 'org-html-with-latex'.
    +    * etc/ORG-NEWS (New and changed options): Announce change.
    +    * lisp/ox-odt.el (org-odt-with-latex): Replace image conversion
    +    methods with a restricted-sexp that checks membership in
    +    'org-preview-latex-process-alist'.
         (org-odt--translate-latex-fragments): Replace hard-coded symbols with
         those from 'org-preview-latex-process-alist', and check all external
         commands from the same.  Generalize comments.
     
    + ## etc/ORG-NEWS ##
    +@@ etc/ORG-NEWS: considered.  For example, setting ~org-refile-targets~ to ~((nil
    + . t))~ will allow one to refile to any heading within the current
    + buffer.
    + 
    ++*** ~org-odt-with-latex~ accepts any method from ~org-preview-latex-process-alist~
    ++
    ++Previously, only a few conversion methods (~dvipng~, ~imagemagick~,
    ++~dvisvgm~) could be used to render LaTeX fragments as images when
    ++exporting to ODT.  Now any method in ~org-preview-latex-process-alist~
    ++can be used.
    ++
    + ** New functions and changes in function arguments
    + 
    + # This also includes changes in function behavior from Elisp perspective.
    +
      ## lisp/ox-odt.el ##
     @@ lisp/ox-odt.el: e.g. \"tex:dvipng\".  Allowed values are:
      nil            Ignore math snippets.
    @@ lisp/ox-odt.el: e.g. \"tex:dvipng\".  Allowed values are:
                     `org-latex-to-mathml-convert-command' is usable.
     -`dvipng'       Process the LaTeX fragments to PNG images.  This will
     -               also include processing of non-math environments.
    --`imagemagick'  Convert the LaTeX fragments to pdf files and use
    --               imagemagick to convert pdf files to png files.
    +-`imagemagick'  Convert the LaTeX fragments to PDF files and use
    +-               imagemagick to convert PDF files to PNG files.
     -`dvisvgm'      Process the LaTeX fragments to SVG images.  This will
     -               also include processing of non-math environments.
     +SYMBOL         Convert the LaTeX fragments to images using any symbol
    @@ lisp/ox-odt.el: e.g. \"tex:dvipng\".  Allowed values are:
      `verbatim'     Keep everything in verbatim.
      
      If the desired converter is not available or any other symbol is
    -@@ lisp/ox-odt.el: provided, process as `verbatim'."
    -   :type '(choice
    - 	  (const :tag "Do not process math in any way" nil)
    - 	  (const :tag "Convert fragments to MathML" mathml)
    --	  (const :tag "Use dvipng to make images" dvipng)
    --	  (const :tag "Use imagemagick to make images" imagemagick)
    --	  (const :tag "Use dvisvgm to make images" dvisvgm)
    -+	  (symbol :tag "Convert fragments to images" :value dvipng)
    - 	  (const :tag "Leave math verbatim" verbatim)))
    + provided, process as `verbatim'."
    +   :version "24.4"
    +-  :package-version '(Org . "8.0")
    +-  :type '(choice
    ++  :package-version '(Org . "9.8")
    ++  :type `(choice
    +           (const :tag "Do not process math in any way" nil)
    +           (choice :tag "Convert fragments to MathML" :value t
    +                   (const t)
    +                   (const mathml))
    +-          (const :tag "Use dvipng to make images" dvipng)
    +-          (const :tag "Use imagemagick to make images" imagemagick)
    +-          (const :tag "Use dvisvgm to make images" dvisvgm)
    ++          (restricted-sexp :tag "Convert fragments to images"
    ++                           :value ,(caar org-preview-latex-process-alist)
    ++                           :match-alternatives
    ++                           (,(lambda (v)
    ++                               (assq v org-preview-latex-process-alist))))
    +           (const :tag "Leave math verbatim" verbatim)))
      
      
     @@ lisp/ox-odt.el: contextual information."
    @@ lisp/ox-odt.el: contextual information."
     -                       (imagemagick "convert"))
     -		     "" t))
     -	 (setq warning "`org-odt-with-latex': LaTeX to PNG converter not available.  Falling back to verbatim.")
    -+      ((and s
    -+	    (guard (memq s preview-symbols))
    -+	    (let ext-commands
    -+	      (plist-get
    -+	       (cdr (assq s org-preview-latex-process-alist))
    -+	       :programs))
    -+	    (let ext-commands-check
    -+	      (seq-reduce (lambda (result cmd)
    -+			    (and result
    -+				 (not (null
    -+				       (org-check-external-command cmd "" t)))))
    -+			  ext-commands t)))
    -+       (unless ext-commands-check
    -+	 (setq warning "`org-odt-with-latex': LaTeX to image converter not available.  Falling back to verbatim.")
    - 	 (setq processing-type 'verbatim)))
    +-	 (setq processing-type 'verbatim)))
     -      (verbatim) ;; nothing to do
     -      (otherwise
    ++      ((and s (guard (memq s preview-symbols)))
    ++       (let* ((ext-commands (plist-get
    ++                             (cdr (assq s org-preview-latex-process-alist))
    ++                             :programs))
    ++              (ext-commands-available
    ++               (seq-reduce (lambda (result cmd)
    ++                             (and result
    ++                                  (not
    ++                                   (null
    ++                                    (org-check-external-command cmd "" t)))))
    ++                           ext-commands t)))
    ++         (unless ext-commands-available
    ++           (setq warning "`org-odt-with-latex': LaTeX to image converter not available.  Falling back to verbatim.")
    ++           (setq processing-type 'verbatim))))
     +      ('verbatim) ;; nothing to do
     +      (_
             (setq warning "`org-odt-with-latex': Unknown LaTeX option.  Forcing verbatim.")
3:  11152f575 ! 3:  c54cfa523 ox-odt: Add variable to specify path of generated MathML files
    @@ Metadata
     Author: Jacob S. Gordon <[email protected]>
     
      ## Commit message ##
    -    ox-odt: Add variable to specify path of generated MathML files
    +    ox-odt: Add option to specify path of generated MathML files
     
    -    * lisp/org.el (org-latex-mathml-directory): Add custom variable.
    +    * etc/ORG-NEWS: (New and changed options): Announce option.
    +    * lisp/org.el (org-latex-mathml-directory): Add option.
         * lisp/ox-odt.el (org-odt--translate-latex-fragments): Replace
    -    hard-coded MathML directory with the new variable.
    +    hard-coded MathML directory with the option.
    +
    + ## etc/ORG-NEWS ##
    +@@ etc/ORG-NEWS: Previously, only a few conversion methods (~dvipng~, ~imagemagick~,
    + exporting to ODT.  Now any method in ~org-preview-latex-process-alist~
    + can be used.
    + 
    ++*** New option ~org-latex-mathml-directory~
    ++
    ++This option specifies the path where MathML files generated from LaTeX
    ++fragments are stored.
    ++
    + ** New functions and changes in function arguments
    + 
    + # This also includes changes in function behavior from Elisp perspective.
     
      ## lisp/org.el ##
     @@ lisp/org.el: images at the same place."
    @@ lisp/org.el: images at the same place."
     +processed Org files paths.  An absolute path puts all files
     +in the same place."
     +  :group 'org-latex
    -+  :version "31.1"
    ++  :package-version '(Org . "9.8")
     +  :type 'string)
     +
      (defun org-format-latex-mathml-available-p ()

base-commit: df5628041dd2317f458e2903bc61fb985849c328
-- 
Jacob S. Gordon
[email protected]
Please avoid sending me HTML emails and MS Office documents.
https://useplaintext.email/#etiquette

From a84d56a5e5ad4c42c867addf0c718971f473d39c Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Thu, 16 Oct 2025 16:20:00 -0400
Subject: [PATCH v2 1/3] ox-odt: Align 'org-odt-with-latex' with export
 behavior

* lisp/ox-odt.el (org-odt-with-latex): Remove 'mathjax', add missing
t, 'mathml', and 'dvisvgm' options, and clarify when 'verbatim' is
used as a fallback.
(org-odt--translate-latex-fragments): Update comment.
---
 lisp/ox-odt.el | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 8fb026247..97cf8a037 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -722,26 +722,32 @@ When set, the exporter will process LaTeX environments and
 fragments.
 
 This option can also be set with the +OPTIONS line,
-e.g. \"tex:mathjax\".  Allowed values are:
+e.g. \"tex:dvipng\".  Allowed values are:
 
 nil            Ignore math snippets.
-`verbatim'     Keep everything in verbatim
-`dvipng'       Process the LaTeX fragments to images.  This will also
-               include processing of non-math environments.
-`imagemagick'  Convert the LaTeX fragments to pdf files and use
-               imagemagick to convert pdf files to png files.
-`mathjax'      Do MathJax preprocessing and arrange for MathJax.js to
-               be loaded.
+t, `mathml'    Convert the LaTeX fragments to MathML if the
+               `org-latex-to-mathml-convert-command' is usable.
+`dvipng'       Process the LaTeX fragments to PNG images.  This will
+               also include processing of non-math environments.
+`imagemagick'  Convert the LaTeX fragments to PDF files and use
+               imagemagick to convert PDF files to PNG files.
+`dvisvgm'      Process the LaTeX fragments to SVG images.  This will
+               also include processing of non-math environments.
+`verbatim'     Keep everything in verbatim.
 
-Any other symbol is a synonym for `mathjax'."
+If the desired converter is not available or any other symbol is
+provided, process as `verbatim'."
   :version "24.4"
   :package-version '(Org . "8.0")
   :type '(choice
-	  (const :tag "Do not process math in any way" nil)
-	  (const :tag "Leave math verbatim" verbatim)
-	  (const :tag "Use dvipng to make images" dvipng)
-	  (const :tag "Use imagemagick to make images" imagemagick)
-	  (other :tag "Use MathJax to display math" mathjax)))
+          (const :tag "Do not process math in any way" nil)
+          (choice :tag "Convert fragments to MathML" :value t
+                  (const t)
+                  (const mathml))
+          (const :tag "Use dvipng to make images" dvipng)
+          (const :tag "Use imagemagick to make images" imagemagick)
+          (const :tag "Use dvisvgm to make images" dvisvgm)
+          (const :tag "Leave math verbatim" verbatim)))
 
 
 ;;;; Links
@@ -3779,9 +3785,9 @@ contextual information."
   (let ((processing-type (plist-get info :with-latex))
 	(count 0)
         (warning nil))
-    ;; Normalize processing-type to one of dvipng, mathml or verbatim.
-    ;; If the desired converter is not available, force verbatim
-    ;; processing.
+    ;; Normalize processing-type to one of mathml, dvipng,
+    ;; imagemagick, dvisvgm, or verbatim.  If the desired converter is
+    ;; not available, force verbatim processing.
     (cl-case processing-type
       ((t mathml)
        (if (and (fboundp 'org-format-latex-mathml-available-p)
-- 
Jacob S. Gordon
[email protected]
Please avoid sending me HTML emails and MS Office documents.
https://useplaintext.email/#etiquette

From c1364763075cfa3f43007f6d49b8b4a9364ca590 Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Thu, 16 Oct 2025 16:21:00 -0400
Subject: [PATCH v2 2/3] ox-odt: Allow LaTeX fragment conversion from any
 preview method

Previously, only 'dvipng', 'imagemagick' and 'dvisvgm' could be used
to convert LaTeX fragments to images.  This missed 'xelatex' and any
user-defined symbols.  Any symbol in 'org-preview-latex-process-alist'
can now be used.

* etc/ORG-NEWS (New and changed options): Announce change.
* lisp/ox-odt.el (org-odt-with-latex): Replace image conversion
methods with a restricted-sexp that checks membership in
'org-preview-latex-process-alist'.
(org-odt--translate-latex-fragments): Replace hard-coded symbols with
those from 'org-preview-latex-process-alist', and check all external
commands from the same.  Generalize comments.
---
 etc/ORG-NEWS   |  7 ++++
 lisp/ox-odt.el | 86 ++++++++++++++++++++++++++------------------------
 2 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e767bae00..1d60826d9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -418,6 +418,13 @@ considered.  For example, setting ~org-refile-targets~ to ~((nil
 . t))~ will allow one to refile to any heading within the current
 buffer.
 
+*** ~org-odt-with-latex~ accepts any method from ~org-preview-latex-process-alist~
+
+Previously, only a few conversion methods (~dvipng~, ~imagemagick~,
+~dvisvgm~) could be used to render LaTeX fragments as images when
+exporting to ODT.  Now any method in ~org-preview-latex-process-alist~
+can be used.
+
 ** New functions and changes in function arguments
 
 # This also includes changes in function behavior from Elisp perspective.
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 97cf8a037..ef747a925 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -727,26 +727,25 @@ e.g. \"tex:dvipng\".  Allowed values are:
 nil            Ignore math snippets.
 t, `mathml'    Convert the LaTeX fragments to MathML if the
                `org-latex-to-mathml-convert-command' is usable.
-`dvipng'       Process the LaTeX fragments to PNG images.  This will
-               also include processing of non-math environments.
-`imagemagick'  Convert the LaTeX fragments to PDF files and use
-               imagemagick to convert PDF files to PNG files.
-`dvisvgm'      Process the LaTeX fragments to SVG images.  This will
-               also include processing of non-math environments.
+SYMBOL         Convert the LaTeX fragments to images using any symbol
+               defined in `org-preview-latex-process-alist', e.g.,
+               `dvipng'.
 `verbatim'     Keep everything in verbatim.
 
 If the desired converter is not available or any other symbol is
 provided, process as `verbatim'."
   :version "24.4"
-  :package-version '(Org . "8.0")
-  :type '(choice
+  :package-version '(Org . "9.8")
+  :type `(choice
           (const :tag "Do not process math in any way" nil)
           (choice :tag "Convert fragments to MathML" :value t
                   (const t)
                   (const mathml))
-          (const :tag "Use dvipng to make images" dvipng)
-          (const :tag "Use imagemagick to make images" imagemagick)
-          (const :tag "Use dvisvgm to make images" dvisvgm)
+          (restricted-sexp :tag "Convert fragments to images"
+                           :value ,(caar org-preview-latex-process-alist)
+                           :match-alternatives
+                           (,(lambda (v)
+                               (assq v org-preview-latex-process-alist))))
           (const :tag "Leave math verbatim" verbatim)))
 
 
@@ -3783,30 +3782,35 @@ contextual information."
 
 (defun org-odt--translate-latex-fragments (tree _backend info)
   (let ((processing-type (plist-get info :with-latex))
+	(preview-symbols (mapcar #'car org-preview-latex-process-alist))
 	(count 0)
         (warning nil))
-    ;; Normalize processing-type to one of mathml, dvipng,
-    ;; imagemagick, dvisvgm, or verbatim.  If the desired converter is
-    ;; not available, force verbatim processing.
-    (cl-case processing-type
-      ((t mathml)
+    ;; Normalize processing-type to one of mathml, verbatim, or a
+    ;; symbol in org-preview-latex-process-alist.  If the desired
+    ;; converter is not available, force verbatim processing.
+    (pcase processing-type
+      ((or 't 'mathml)
        (if (and (fboundp 'org-format-latex-mathml-available-p)
 		(org-format-latex-mathml-available-p))
 	   (setq processing-type 'mathml)
          (setq warning "`org-odt-with-latex': LaTeX to MathML converter not available.  Falling back to verbatim.")
 	 (setq processing-type 'verbatim)))
-      ((dvipng imagemagick dvisvgm)
-       (unless (and (org-check-external-command "latex" "" t)
-		    (org-check-external-command
-                     (cl-case processing-type
-                       (dvipng "dvipng")
-                       (dvisvgm "dvisvgm")
-                       (imagemagick "convert"))
-		     "" t))
-	 (setq warning "`org-odt-with-latex': LaTeX to PNG converter not available.  Falling back to verbatim.")
-	 (setq processing-type 'verbatim)))
-      (verbatim) ;; nothing to do
-      (otherwise
+      ((and s (guard (memq s preview-symbols)))
+       (let* ((ext-commands (plist-get
+                             (cdr (assq s org-preview-latex-process-alist))
+                             :programs))
+              (ext-commands-available
+               (seq-reduce (lambda (result cmd)
+                             (and result
+                                  (not
+                                   (null
+                                    (org-check-external-command cmd "" t)))))
+                           ext-commands t)))
+         (unless ext-commands-available
+           (setq warning "`org-odt-with-latex': LaTeX to image converter not available.  Falling back to verbatim.")
+           (setq processing-type 'verbatim))))
+      ('verbatim) ;; nothing to do
+      (_
        (setq warning "`org-odt-with-latex': Unknown LaTeX option.  Forcing verbatim.")
        (setq processing-type 'verbatim)))
 
@@ -3823,34 +3827,32 @@ contextual information."
     (message "Formatting LaTeX using %s" processing-type)
 
     ;; Convert `latex-fragment's and `latex-environment's.
-    (when (memq processing-type '(mathml dvipng dvisvgm imagemagick))
+    (when (memq processing-type (append '(mathml) preview-symbols))
       (org-element-map tree '(latex-fragment latex-environment)
 	(lambda (latex-*)
 	  (cl-incf count)
 	  (let* ((latex-frag (org-element-property :value latex-*))
 		 (input-file (plist-get info :input-file))
+                 (is-image (memq processing-type preview-symbols))
 		 (cache-dir (file-name-directory input-file))
 		 (cache-subdir (concat
-				(cl-case processing-type
-				  ((dvipng dvisvgm imagemagick)
-				   org-preview-latex-image-directory)
-				  (mathml "ltxmathml/"))
+				(if is-image
+				    org-preview-latex-image-directory
+				  "ltxmathml/")
 				(file-name-sans-extension
 				 (file-name-nondirectory input-file))))
 		 (display-msg
-		  (cl-case processing-type
-		    ((dvipng dvisvgm imagemagick)
-		     (format "Creating LaTeX Image %d..." count))
-		    (mathml (format "Creating MathML snippet %d..." count))))
-		 ;; Get an Org-style link to PNG image or the MathML
-		 ;; file.
+		  (if is-image
+		      (format "Creating LaTeX image %d..." count)
+		    (format "Creating MathML snippet %d..." count)))
+		 ;; Get an Org-style link to image or the MathML file.
 		 (link
 		  (with-temp-buffer
 		    (insert latex-frag)
                     (delay-mode-hooks (let ((org-inhibit-startup t)) (org-mode)))
-		    ;; When converting to a PNG image, make sure to
-		    ;; copy all LaTeX header specifications from the
-		    ;; Org source.
+		    ;; When converting to an image, make sure to copy
+		    ;; all LaTeX header specifications from the Org
+		    ;; source.
 		    (unless (eq processing-type 'mathml)
 		      (let ((h (plist-get info :latex-header)))
 			(when h
-- 
Jacob S. Gordon
[email protected]
Please avoid sending me HTML emails and MS Office documents.
https://useplaintext.email/#etiquette

From c54cfa5237fb9b832f2df4fcbaf5ac73e64c017e Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Thu, 16 Oct 2025 16:22:00 -0400
Subject: [PATCH v2 3/3] ox-odt: Add option to specify path of generated MathML
 files

* etc/ORG-NEWS: (New and changed options): Announce option.
* lisp/org.el (org-latex-mathml-directory): Add option.
* lisp/ox-odt.el (org-odt--translate-latex-fragments): Replace
hard-coded MathML directory with the option.
---
 etc/ORG-NEWS   | 5 +++++
 lisp/org.el    | 9 +++++++++
 lisp/ox-odt.el | 2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 1d60826d9..0c9ddbab4 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -425,6 +425,11 @@ Previously, only a few conversion methods (~dvipng~, ~imagemagick~,
 exporting to ODT.  Now any method in ~org-preview-latex-process-alist~
 can be used.
 
+*** New option ~org-latex-mathml-directory~
+
+This option specifies the path where MathML files generated from LaTeX
+fragments are stored.
+
 ** New functions and changes in function arguments
 
 # This also includes changes in function behavior from Elisp perspective.
diff --git a/lisp/org.el b/lisp/org.el
index 6b8d02b87..da8e29879 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3513,6 +3513,15 @@ images at the same place."
   :package-version '(Org . "9.0")
   :type 'string)
 
+(defcustom org-latex-mathml-directory "ltxmathml/"
+  "Path to store MathML files converted from LaTeX fragments.
+A relative path here creates many directories relative to the
+processed Org files paths.  An absolute path puts all files
+in the same place."
+  :group 'org-latex
+  :package-version '(Org . "9.8")
+  :type 'string)
+
 (defun org-format-latex-mathml-available-p ()
   "Return t if `org-latex-to-mathml-convert-command' is usable."
   (save-match-data
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index ef747a925..a8f6fe4ac 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -3838,7 +3838,7 @@ contextual information."
 		 (cache-subdir (concat
 				(if is-image
 				    org-preview-latex-image-directory
-				  "ltxmathml/")
+				  org-latex-mathml-directory)
 				(file-name-sans-extension
 				 (file-name-nondirectory input-file))))
 		 (display-msg
-- 
Jacob S. Gordon
[email protected]
Please avoid sending me HTML emails and MS Office documents.
https://useplaintext.email/#etiquette

Reply via email to