From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Thibault Marin <thibault.marin@gmx.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Equation references in HTML export
Date: Tue, 16 Jan 2018 19:09:09 +0100 [thread overview]
Message-ID: <87efmpy8u2.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87h8rtf3bo.fsf@dell-desktop.WORKGROUP> (Thibault Marin's message of "Wed, 10 Jan 2018 22:04:59 -0600")
Hello,
Thibault Marin <thibault.marin@gmx.com> writes:
>> You may be right. In this case, we may use \eqref if MathJax is
>> going to be used (like your initial patch did), and do the above
>> otherwise.
>
> OK, I think that would work. To summarize, here are the different
> outputs under MathJax and the other modes:
>
> - MathJax mode:
> - Environment:
> ,----
> | \begin{align}
> | \label{eq:org19c7f92}
> | 1 + 1 = 0
> | \end{align}
> `----
> - Link:
> ,----
> | link to \eqref{eq:org19c7f92}
> `----
> - other modes, e.g. verbatim: (it is similar for the rest: dvipng,
> imagemagick, etc).:
> - Environment
> ,----
> | <div id="org19c7f92" class="equation-container">
> | <span class="equation">
> | \begin{align}
> | 1 + 1 = 0
> | \end{align}
> |
> | </span>
> | <span class="equation-label">
> | 1
> | </span>
> | </div>
> `----
> - Link:
> ,----
> | link to equation <a href="#org19c7f92">1</a>
> `----
>
> The attached patch produces this on my test cases.
It looks good. Thank you.
> I looked at other structures:
> - for figures, the caption is in a `figcaption' tag if HTML5 is used or
> in a paragraph, both under the figure,
> - for tables, the caption is in a `caption' tag, at the top or bottom of
> the environment depending on `:html-table-caption-above',
> - As far as I can tell, source blocks get no caption.
>
> Since there does not appear to have a common convention, I think the
> proposed output (see above with "equation-container", "equation" and
> "equation-label" tags) would be fine, if nobody objects. Some CSS puts
> the label on the right side, as with LaTeX export or MathJax. This only
> applies to the non-MathJax modes.
As a first step, it sounds acceptable, indeed. However, I assume it
would be useful to make all approaches converge on a single solution.
> I think I misunderstood what the caption does in ox-latex. Here, in the
> MathJax case, just I need to insert the `\label' inside the latex
> environment, e.g. `\begin{equation}\label{org21321}' similar to what
> `org-latex-latex-environment' does. The caption itself (the equation
> number) is always on the right of the equation, regardless of the mode
> (MathJax or other), so this is variable is not needed anymore.
OK.
> I hope the patch looks better now. I have a few remaining questions:
>
> - The `org-html--is-math-environment' function relies on
> `org-latex-math-environments-re' from ox-latex for the numbering
> (numbering only equations, ignoring other environments). Is it
> acceptable?
I guess so. OTOH, I assume latex environments are always math
environments. One can use LaTex export blocks for "regular" LaTeX.
Nitpick: since this is a predicate, it should be named
`org-html--math-environment-p'.
> - In non-MathJax modes, I currently pre-process the latex environment to
> change equation environments to their * version,
> e.g. "\begin{equation}" -> "\begin{equation*}". This is to prevent
> the latex environment from adding its own labeling to the rendered
> image. This feels like a hack. Is there a better way to achieve
> this?
No idea. I hope a LaTeX expert can chime it.
Meanwhile, I think the implementation is a bit convoluted. What about
the following?
(replace-regexp-in-string
"\\`[ \t]*\\\\begin{\\([^*]+?\\)}"
"\\1*"
(replace-regexp-in-string "^[ \t]*\\\\end{\\([^*]+?\\)}[ \r\t\n]*\\'"
"\\1*"
latex-frag nil nil 1)
nil nil 1)
> - The `org-html--insert-latex-environment-label' (the function that
> inserts `\label' inside the environment also feels like a hack. I
> originally wanted to re-use the equivalent latex code, but maybe this
> is simpler. Do you think we can do better?
IMO, this doesn't deserve to be a function, you can just use something
like this:
(if (org-string-nw-p label)
(replace-regexp-in-string "\\`.*"
(format "\\&\n\\\\label{%s}" label)
latex-frag)
latex-frag)
> - In the image modes (e.g. dvipng), I removed the following comment: ";;
> Do not provide a caption or a name to be consistent with `mathjax'
> handling." I am not sure what it means and whether I should be
> concerned about it.
IIUC, so far, Mathjax doesn't provide any caption, neither does dvipng.
> - I think I have been with messing this file enough now that I should
> add tests. I didn't see any tests for ox-latex or ox-html. Is there
> a reason for that?
They are not a priority. Bugs in export back-ends are usually visible
enough. Anyway this doesn't mean you cannot write some tests. Tests are
nice. However they are not mandatory in this case.
Regards,
--
Nicolas Goaziou 0x80A93738
next prev parent reply other threads:[~2018-01-16 18:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-05 5:30 Equation references in HTML export Thibault Marin
2018-01-06 10:41 ` Nicolas Goaziou
2018-01-07 9:11 ` Thibault Marin
2018-01-09 21:27 ` Nicolas Goaziou
2018-01-11 4:04 ` Thibault Marin
2018-01-16 18:09 ` Nicolas Goaziou [this message]
2018-01-17 4:39 ` Thibault Marin
2018-01-17 21:27 ` Nicolas Goaziou
2018-01-18 3:25 ` Thibault Marin
2018-01-19 17:39 ` Nicolas Goaziou
2018-01-17 7:35 ` Eric S Fraga
2018-01-19 4:09 ` Thibault Marin
2018-01-19 7:39 ` Eric S Fraga
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=87efmpy8u2.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=thibault.marin@gmx.com \
/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).