Hi, I think I wrote some of that code, I was not trying to support "unnumbered" environments. If I understand correctly, this is what you are trying to get.
The attached patch attempts to solve this. Currently, `displaymath' and `*' environments do not get numbers, I am not sure if there are other environments that should not get numbers; please let me know if you have others in mind. If you (and others) could test and/or review the patch, we could probably get it merged at some point. Thanks, thibault On 2019-11-01T09:55:49-0400, Uwe Brauer wrote: >>> "FE" == Fraga, Eric <e.fr...@ucl.ac.uk> writes: > On Friday, 1 Nov 2019 at 08:52, Uwe Brauer wrote: >> As the attached screenshots show, the png contain unwanted equations >> numbers (displaymath adn equation* have been used which should not >> generate those numbers). > Uwe, > when I invoke org-mime-htmlize with your equations, as written, I do not get any equation numbers. Thanks, so it is my setting. I wounder how can I debug this?
From d66392545762f0ed890a772e08dad3655ea7e522 Mon Sep 17 00:00:00 2001 From: thibault <thibault.ma...@gmx.com> Date: Sat, 2 Nov 2019 02:12:38 -0400 Subject: [PATCH] ox-html: Add equation numbers only for numbered environments * lisp/ox-html.el (org-html-latex-environment): Add caption to numbered environments only (org-html--latex-environment-numbered-p): Determine whether a latex environment should be numbered. --- lisp/ox-html.el | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 83d0fd2e9..55983ff2f 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2914,19 +2914,35 @@ For instance, change an 'equation' environment to 'equation*'." latex-frag nil nil 1) nil nil 1)) +(defun org-html--latex-environment-numbered-p (latex-frag) + "Return t if LATEX-ENV contains a numbered environment. + +Environments with a star (*) character and displaymath are not numbered." + (not (some 'identity + (mapcar (lambda (el) + (string-match el latex-frag)) + '("\\`[ \t]*\\\\begin{[^*}]+?[*]}" + "\\`[ \t]*\\\\begin{displaymath}"))))) + (defun org-html-latex-environment (latex-environment _contents info) "Transcode a LATEX-ENVIRONMENT element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." - (let ((processing-type (plist-get info :with-latex)) - (latex-frag (org-remove-indentation - (org-element-property :value latex-environment))) - (attributes (org-export-read-attribute :attr_html latex-environment)) - (label (and (org-element-property :name latex-environment) - (org-export-get-reference latex-environment info))) - (caption (number-to-string - (org-export-get-ordinal - latex-environment info nil - #'org-html--math-environment-p)))) + (let* ((processing-type (plist-get info :with-latex)) + (latex-frag (org-remove-indentation + (org-element-property :value latex-environment))) + (attributes (org-export-read-attribute :attr_html latex-environment)) + (label (and (org-element-property :name latex-environment) + (org-export-get-reference latex-environment info))) + (caption (when (org-html--latex-environment-numbered-p + latex-frag) + (number-to-string + (org-export-get-ordinal + latex-environment info nil + (lambda (l info) + (and (org-html--math-environment-p l) + (org-html--latex-environment-numbered-p + (org-remove-indentation + (org-element-property :value l)))))))))) (cond ((memq processing-type '(t mathjax)) (org-html-format-latex -- 2.23.0