From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id IM2yBTz8m16NawAA0tVLHw (envelope-from ) for ; Sun, 19 Apr 2020 07:22:36 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 6JLZBUH8m14XfgAAbx9fmQ (envelope-from ) for ; Sun, 19 Apr 2020 07:22:41 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9A40F940021 for ; Sun, 19 Apr 2020 07:22:39 +0000 (UTC) Received: from localhost ([::1]:38658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQ4Hm-000145-Uw for larch@yhetil.org; Sun, 19 Apr 2020 03:22:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59080) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQ4HQ-00013z-4j for emacs-orgmode@gnu.org; Sun, 19 Apr 2020 03:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQ4HP-0001st-1L for emacs-orgmode@gnu.org; Sun, 19 Apr 2020 03:22:15 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:44792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jQ4HO-0001pt-Dy for emacs-orgmode@gnu.org; Sun, 19 Apr 2020 03:22:14 -0400 Received: by mail-pl1-x635.google.com with SMTP id h11so2718979plr.11 for ; Sun, 19 Apr 2020 00:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hawaii-edu.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=F/AsWQnAu+ZbnKQkz+cv/3uixuqKeCgIvQFFdxBBFXc=; b=zdRm+pi01r0tEM8D7demR4ZicH55lvhByNIaA586jG07tE7aZeNmuiBPx3hMBI0Qw1 PJYD34tvURmlDJRILrf5aj1WgNRzfy7V56kmswUzKULeZihdVTus0TTrd0usImOwHS0G uPgLSx2qknXSCKDXp112eoWdk4ScJM3X7IVM+mlMbk3jfRDYpUHp3Pq6FehXD3SxPCce xnZAyNusP8ippZeLX16bzXzI0zh9Tgxu/7FkD6u+Zp2CaC8WayYEUwMF0o/4q0bdBiqj XR7y6c981wwdvOH9yfPBok5PQLn99bR9tN3bkCCvm+IRB1W1qPInP17eiywGxq46WtKc RGhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=F/AsWQnAu+ZbnKQkz+cv/3uixuqKeCgIvQFFdxBBFXc=; b=uIRAbki6YKYiF/p65i+5BckltZxH3zoFQe3Gl2mbB+9B6IM2qxCobbmNyj+mGbegP2 ml93OlAhbCuVKXD5dQE/nSex3MZ4QRZu1jWGiTBh51KJYQHY+eRfaqSqoJa97n7e+vf5 Rl9rwaCnCNQgCt5tuANJbBv5rTw8aojKQPaUKkDN7Ma+5RZ/y7LDf6gR1co1SxgyLNaf fvi4PnzdZdiQ7tqPCLke1NsAEjXjxSi3pnX5+bUV3SjLOHaz8cqWrjU0VUby7nyOniTB hQXuE9GAceKBrgYGNN12wKp1BviVSAb+CLlUBFooXipNqejQuv5VYrni4Op8MHBkTjei VpDA== X-Gm-Message-State: AGi0PuYwWTUSZtdClieNywVNcuhL/I9Y0QGV9S1GJMFGSQ3ErBLxZiBd eD2IWdL9AKAOeFxast20Jbi2qKSpklU= X-Google-Smtp-Source: APiQypKZPQEBMGIXITyqwIWUpb8jXmTVdhzwAeR4/V/zoQxecs5t/3gtFwjcPSGHEDWMGv4NwEAFLg== X-Received: by 2002:a17:902:bd89:: with SMTP id q9mr1427998pls.161.1587280931577; Sun, 19 Apr 2020 00:22:11 -0700 (PDT) Received: from localhost ([132.160.7.3]) by smtp.gmail.com with ESMTPSA id nk12sm10518133pjb.41.2020.04.19.00.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 00:22:10 -0700 (PDT) References: <87h7xhxlyt.fsf@nicolasgoaziou.fr> User-agent: mu4e 1.2.0; emacs 28.0.50 From: Brian Powell To: Nicolas Goaziou Subject: Re: Inconsistent use of \ref and \eqref in ox-latex and ox-html In-reply-to: <87h7xhxlyt.fsf@nicolasgoaziou.fr> Date: Sat, 18 Apr 2020 21:22:05 -1000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=powellb@hawaii.edu; helo=mail-pl1-x635.google.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::635 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -1.31 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=hawaii-edu.20150623.gappssmtp.com header.s=20150623 header.b=zdRm+pi0; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.31 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.57231053765931]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.24), country: US(-0.01), ip: 209.51.188.17(-0.57)]; HAS_ATTACHMENT(0.00)[]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[hawaii-edu.20150623.gappssmtp.com:+]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[209.51.188.17:from]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[powellb@hawaii.edu,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[hawaii-edu.20150623.gappssmtp.com:s=20150623]; URIBL_BLOCKED(0.00)[org-manual.org:url,hawaii.edu:email,hawaii-edu.20150623.gappssmtp.com:dkim]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; DMARC_NA(0.00)[hawaii.edu]; HAS_LIST_UNSUB(-0.01)[]; RCVD_COUNT_SEVEN(0.00)[7]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: qjhxKC5OkmZm --=-=-= Content-Type: text/plain Nicolas, Thank you for the message. I spent about 2 hours on it today learning more about lisp and the internals to explain your email to me. I learned a lot. I have modified ox-html.el to include a local OPTION as well as a customizable setting. I tested with both as well as with an export option. All three worked correctly. I also updated the org-manual.org. Please find my patch attached. Cheers, Brian --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=equation-ref.diff diff --git a/doc/org-manual.org b/doc/org-manual.org index 6d5a34e56..69a36d6c7 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -12531,6 +12531,15 @@ settings described in [[*Export Settings]]. to typeset LaTeX math in HTML documents. See [[*Math formatting in HTML export]], for an example. +- =HTML_EQUATION_REFERENCE_FORMAT= :: + + #+cindex: @samp{HTML_EQUATION_REFERENCE_FORMAT}, keyword + #+vindex: org-html-equation-reference-format + Specify the MathJax command for referencing equations + (~org-html-equation-reference-format~). The default is to wrap in + parentheses using "\\eqref{%s}". Setting to "\\ref{%s}" is consistent + with LaTeX export. + - =HTML_HEAD= :: #+cindex: @samp{HTML_HEAD}, keyword @@ -12898,6 +12907,9 @@ files. This method requires that the dvipng program, dvisvgm or ImageMagick suite is available on your system. You can still get this processing with +The command for formatting equation references can be configured via +~org-html-equation-reference-format~. + : #+OPTIONS: tex:dvipng : #+OPTIONS: tex:dvisvgm diff --git a/lisp/ox-html.el b/lisp/ox-html.el index e70b8279b..4848028a2 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -121,6 +121,7 @@ (:html-link-home "HTML_LINK_HOME" nil org-html-link-home) (:html-link-up "HTML_LINK_UP" nil org-html-link-up) (:html-mathjax "HTML_MATHJAX" nil "" space) + (:html-equation-reference-format "HTML_EQUATION_REFERENCE_FORMAT" nil org-html-equation-reference-format t) (:html-postamble nil "html-postamble" org-html-postamble) (:html-preamble nil "html-preamble" org-html-preamble) (:html-head "HTML_HEAD" nil org-html-head newline) @@ -761,6 +762,20 @@ The function should return the string to be exported." ;;;; LaTeX +(defcustom org-html-equation-reference-format "\\eqref{%s}" + "MathJax command to use when referencing equations. + +Default is to wrap equations in parentheses (using \"\\eqref{%s}\)\". + +Most common values are: + + \"\\eqref{%s}\" Wrap the equation in parentheses + \"\\ref{%s}\" Do not wrap the equation in parentheses" + :group 'org-export-html + :package-version '(Org . "9.3") + :type 'string + :safe t) + (defcustom org-html-with-latex org-export-with-latex "Non-nil means process LaTeX math snippets. @@ -3113,9 +3128,9 @@ INFO is a plist holding contextual information. See (eq 'latex-environment (org-element-type destination)) (eq 'math (org-latex--environment-type destination))) ;; Caption and labels are introduced within LaTeX - ;; environment. Use "eqref" macro to refer to those in - ;; the document. - (format "\\eqref{%s}" + ;; environment. Use "ref" or "eqref" macro, depending on user + ;; preference to refer to those in the document. + (format (plist-get info :html-equation-reference-format) (org-export-get-reference destination info)) (let* ((ref (org-export-get-reference destination info)) (org-html-standalone-image-predicate --=-=-= Content-Type: text/plain On Fri, Apr 17 2020, Nicolas Goaziou wrote: > Hello, > > Brian Powell writes: > >> The issue is that when exporting equation numbers with ox-html, it uses MathJax's \eqref that wraps the equation in parentheses, for example: >> >> "Refer to (3) for more." >> >> However, when exporting the same document with ox-latex, it uses Latex's \ref that does not wrap the equation in parentheses. Would it be possible to add an option or variable to ox-html for the user to select whether to use \ref or \eqref on export? >> >> For those of us that publish to HTML and PDF, it is very difficult because you end up with either double or no parentheses. >> >> My proposed fix would be a change to ox-html from: >> >> (format "\\eqref{%s}" >> (org-export-get-reference destination info)) >> >> to >> >> (format (if org-html-export-mathjax-ref "\\ref{%s}" "\\eqref{%s}") >> (org-export-get-reference destination info)) >> >> The variable org-html-export-mathjax-ref is non-nil to use \ref vs. >> nil to be the default \eqref. > > The variable could be more general, e.g., > org-html-export-equation-reference-format, and default to "\\ref{%s}". > Note the export back-ends do not use variables directly. It would be > > (format (plist-get info :html-equation-reference-format) > (org-export-get-reference destination info)) > > where the correspondence between :html-equation-reference-format is set > in back-end definition. > > Also, it needs to be referenced in "HTML specific properties" section of > the manual. > > Would you want to propose a patch ? > > Regards, --=-=-=--