emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Brian Powell <powellb@hawaii.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: Inconsistent use of \ref and \eqref in ox-latex and ox-html
Date: Sun, 19 Apr 2020 12:46:15 +0200	[thread overview]
Message-ID: <87k12bwy6g.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <m2a738ym76.fsf@hawaii.edu> (Brian Powell's message of "Sat, 18 Apr 2020 21:22:05 -1000")

Hello,

Brian Powell <powellb@hawaii.edu> 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	other threads:[~2020-04-19 10:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 21:56 Inconsistent use of \ref and \eqref in ox-latex and ox-html Brian Powell
2020-04-18  8:00 ` Nicolas Goaziou
2020-04-19  7:22   ` Brian Powell
2020-04-19 10:46     ` Nicolas Goaziou [this message]
2020-04-19 23:13       ` [PATCH] " Brian Powell
2020-04-20 16:40         ` Nicolas Goaziou
2020-04-20 19:52           ` Brian Powell
2020-04-21 17:46             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k12bwy6g.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=powellb@hawaii.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).