public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Preserve math environment for mathjax?
@ 2019-08-01 15:13 David Roundy
       [not found] ` <097b8e79-fbf1-4a7c-b626-a50995b0752c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: David Roundy @ 2019-08-01 15:13 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

I'm wondering if there is any way to make pandoc preserve the math environment when compiling from latex to HTML? It seems to always forgot whether I used \begin{align} or \begin{equation}.  They aren't the same, and I know the difference and mathjax knows the difference.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/097b8e79-fbf1-4a7c-b626-a50995b0752c%40googlegroups.com.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Preserve math environment for mathjax?
       [not found] ` <097b8e79-fbf1-4a7c-b626-a50995b0752c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-08-05  4:28   ` John MacFarlane
  0 siblings, 0 replies; 2+ messages in thread
From: John MacFarlane @ 2019-08-05  4:28 UTC (permalink / raw)
  To: David Roundy, pandoc-discuss


Actually, pandoc does differentiate between
\begin{equation} and \begin{aligned}.

% pandoc -f latex -t native
\begin{align}
2+2
\end{align}
[Para [Math DisplayMath "\\begin{aligned}\n2+2\\end{aligned}"]]

% pandoc -f latex -t native
\begin{equation}
2+2
\end{equation}
[Para [Math DisplayMath "2+2"]]

It parses both as display math, but when 'align' is
used it adds an 'aligned' environment.

So, effectively pandoc treats

\begin{align}
...
\end{align}

like

\[\begin{aligned}
...
\end{aligned}\]

I realize that these are not the same in LaTeX, since
the former creates a numbered equation but the latter
does not.  Eventually we'd like to have a more
sophisticated system for labels and cross-references,
which would allow us to properly represent equation
numbers, but currently we do not.

As you note, when we're targeting html+mathjax we
could just pass through the 'align' environment
verbatim and let mathjax deal with it.  But the
latex -> html translation is the composition of
two independent translations, latex -> native and
native -> html, and the first of these tries to
produce something that will render properly in
any output format.

When looking into this, though, I noticed that the
markdown reader actually behaves differently.  When
you're going markdown -> mathjax, the markdown
(with embedded latex)

\begin{align} x \end{align}

is transformed into

<span class="math display">\[\begin{align} x
\end{align}\]</span>

which is essentially what you want.  This is perhaps
an odd inconsistency.  We could of course have the
LaTeX reader behave the same way, but this would give
worse results when converting to formats other than
HTML+MathJax.  So I'm not sure.

David Roundy <daveroundy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> I'm wondering if there is any way to make pandoc preserve the math environment when compiling from latex to HTML? It seems to always forgot whether I used \begin{align} or \begin{equation}.  They aren't the same, and I know the difference and mathjax knows the difference.
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/097b8e79-fbf1-4a7c-b626-a50995b0752c%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2sgqggrrw.fsf%40johnmacfarlane.net.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-05  4:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-01 15:13 Preserve math environment for mathjax? David Roundy
     [not found] ` <097b8e79-fbf1-4a7c-b626-a50995b0752c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-08-05  4:28   ` John MacFarlane

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 NNTP newsgroup(s).