emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistent use of \ref and \eqref in ox-latex and ox-html


From: Nicolas Goaziou
Subject: Re: Inconsistent use of \ref and \eqref in ox-latex and ox-html
Date: Sun, 19 Apr 2020 12:46:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hello,

Brian Powell <address@hidden> writes:

> 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.

Thank you.

> 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.

You need to provide a commit message, using git format-patch
mechanism.

> +- =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.

I don't think this is required. We do not document every variable for
export back-ends.

>  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

This change is odd. You insert your sentence between an explanation and
its related example. Anyway, per above, this is not needed.

However, it would be nice to reference that variable in

  Publishing > Configuration > Options for the exporters > HTML specific 
properties

>  : #+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}\)\".

It might be useful to explicitly state this is a format control string,
expecting a single argument, the actual reference.

> +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")

It should be "9.4". 

> +            ;; environment.  Use "ref" or "eqref" macro, depending on user
> +               ;; preference to refer to those in the document.

Indentation problem?

> +               (format (plist-get info :html-equation-reference-format)
>                         (org-export-get-reference destination info))

OK.

As a side note that you can achieve the same without this variable,
using a link filter, e.g. (untested):

     (defun my-html-filter-references (text backend info)
       "Change \eqref{...} into \ref{...}."
       (when (org-export-derived-backend-p backend 'html)
         (replace-regexp-in-string "\\`\\\\eqref{" "\\\\ref{" text)))

     (add-to-list 'org-export-filter-link-functions
                  'my-html-filter-references)

Anyway, would you mind sending an updated patch?

Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]