From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joseph Vidal-Rosset Subject: Re: latex equation and html export Date: Wed, 1 Jan 2014 10:11:15 +0100 Message-ID: References: <87zjng5i7k.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11360b7c506cb004eee5104f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyHpy-0002Ov-RY for emacs-orgmode@gnu.org; Wed, 01 Jan 2014 04:11:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VyHpw-0003EI-Rn for emacs-orgmode@gnu.org; Wed, 01 Jan 2014 04:11:38 -0500 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:48157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyHpw-0003EB-Et for emacs-orgmode@gnu.org; Wed, 01 Jan 2014 04:11:36 -0500 Received: by mail-wg0-f51.google.com with SMTP id b13so11422317wgh.6 for ; Wed, 01 Jan 2014 01:11:35 -0800 (PST) In-Reply-To: <87zjng5i7k.fsf@alphaville.bos.redhat.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nick Dokos Cc: emacs-orgmode list --001a11360b7c506cb004eee5104f Content-Type: text/plain; charset=UTF-8 Dear Nick, Many thanks to have taken time of writing this long email to try to help me. That's very kind of you. Here are my results. If I want to use MathJax , I have to write something like \[ equation \] it works well in my computer. For labelling, I should follow this documentation: http://orgmode.org/worg/org-tutorials/org-jsmath.html but I do not succeed to write correctly the loadFile code in my org file. Your help is welcome. Nevertheless, I am afraid to give up the hope to use only MathJax. Reason: in LaTeX there are a lot of very useful packages for logicians , like bussproofs, fitch, and so on, and I am not stronger enough to adapt them in oder to use them both with MathJax and with LaTeX. But Imagemagick seems doing the right thing. Again, happy new year and thanks for your kind help. Jo. 2014/1/1 Nick Dokos > Joseph Vidal-Rosset writes: > > > 2013/12/30 Thomas S. Dye > > > > get this LaTeX, which works as expected: > > > > \begin{equation} > > \label{eq:2} > > A \to \neg{} B > > \end{equation} > > % Emacs 24.3.1 (Org mode 8.2.4) > > > > Bonsoir Thomas, > > > > Indeed, the code works correctly. I do not understand why > > #+NAME: eq:2 > > #+BEGIN_EQUATION > > > > #+END_EQUATION > > does not produce the same thing when I export it into latex. > > > > I have this list of preambules: > > > ...snip... > > > > Could you send to me your configuration files and your preambles please, > it would be certainly helpful. > > > > The best way to proceed is to start with *no* configuration at all: > start with a minimal init file that just loads org and sets up the > absolute minimum. Then try the exports. Here is my minimal file, > min.org.el, although you will need to modify the paths to suit your > environment: > > --8<---------------cut here---------------start------------->8--- > (add-to-list 'load-path "~/src/emacs/org/org-mode/lisp") > (add-to-list 'load-path "~/src/emacs/org/org-mode/contib/lisp") > > (require 'org-loaddefs) > > (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) > > (global-set-key "\C-cl" 'org-store-link) > (global-set-key "\C-cc" 'org-capture) > (global-set-key "\C-ca" 'org-agenda) > > --8<---------------cut here---------------end--------------->8--- > > I start emacs like this to use it: > > emacs -q -l /path/to/min.org.el > > > Then try exporting a small example like this: > > --8<---------------cut here---------------start------------->8--- > * Numbered displayed equations > > #+BEGIN_EQUATION > A \to \neg B > #+END_EQUATION > --8<---------------cut here---------------end--------------->8--- > > This example works for both latex and html export for me but it's > somewhat misleading: both \to and \neg are org entities and they > go through the org-entity translation which produces this > for html: > > ,---- > |

> | A → ¬ B > |

> `---- > > and this for latex: > > ,---- > | \begin{equation} > | A \(\to\) \(\neg{}\) B > | \end{equation} > `---- > > [The latex result could be simplified in this particular case: because > it's in an equation environment, TeX is already in math mode so the > inline delimiters \(...\) could be deleted, as could the {} - which I > think is unnecessary in any case for \neg - or any entity that requires > tex math mode. But since org does not know that TeX is in math mode, it > just makes sure by using \(..\) - it would probably be better to use > \ensuremath but that's a nit]. > > But let's take a look at something that is not just org-entities. > Here is the square root of pi divided by 2 in latex: > > --8<---------------cut here---------------start------------->8--- > #+BEGIN_EQUATION > \frac{\sqrt\pi}{2} > #+END_EQUATION > --8<---------------cut here---------------end--------------->8--- > > Exporting that to latex gives > > ,---- > | \begin{equation} > | \frac{\sqrt\pi}{2} > | \end{equation} > `---- > > and to html: > > > ,---- > |
> |

> | \frac{\sqrt\pi}{2} > |

> | > |
> `---- > > The latex result is perfect, but the html result is a disaster. The > reason for that is that the special EQUATION block is translated by the > latex exporter to a reasonable latex construct, but the html exporter > does not have a similar html construct at its disposal: so it does the > generic thing and adds an equation div around it - which accomplishes > nothing. > > OTOH, if you are using mathjax for displaying math in html (which is > the default for the html exporter), then I think going whole-hog to > latex notation works better. Using this in your org file > > --8<---------------cut here---------------start------------->8--- > \begin{equation} > \frac{\sqrt\pi}{2} > \end{equation} > --8<---------------cut here---------------end--------------->8--- > > does the right thing for both latex and html (with mathjax) export. And > you can add a mathjax option to org-html-mathjax-template to produce > numbered equations (and omit the number with > \begin{equation*}...\end{equation*} just as in latex). > > I may be missing something but using a BEGIN/END_EQUATION special block > just does not seem to do the right thing for both latex and html (let > alone any other backend, which is not handled by the other method either). > > I should point out that using > > --8<---------------cut here---------------start------------->8--- > #+BEGIN_EQUATION > \[ > \frac{\sqrt\pi}{2} > \] > #+END_EQUATION > --8<---------------cut here---------------end--------------->8--- > > with html/mathjax does the right thing (except for not numbering the > equation): the \[...\] delimiters signal mathjax to process the math > inside. But they break latex in the sense that you no longer get a > numbered equation. > > So if you want latex and html export to do right by your math, I would > recommend the > > --8<---------------cut here---------------start------------->8--- > \begin{equation} > ... > \end{equation} > --8<---------------cut here---------------end--------------->8--- > > form. > > All this is with latest org. org-7.x is probably different but I have > not gone back to check. And if I've got things wrong, I'd love to be > corrected. > > Nick > > > > > > --001a11360b7c506cb004eee5104f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dear Nick,=C2=A0

Many thanks to have ta= ken time of writing this long email to try to help me. That's very kind= of you.=C2=A0

Here are my results.=C2=A0

If I want to use MathJax , I have to write something like=C2=A0
<= br>
\[

equation

\]

it works well in my computer. For labelling, I= should follow this documentation:

http://orgmode.org/worg/org-tutorials/org-jsmath.html

but I do not succeed to write correctly the loadFile= code in my org file. Your help is welcome.=C2=A0

Nevertheless, I am afraid to give up the hope to use on= ly MathJax. Reason: in LaTeX there are a lot of very useful packages =C2=A0= for logicians , like bussproofs, fitch, and so on, and I am not stronger en= ough to adapt them in oder to use them both with MathJax and with LaTeX. Bu= t Imagemagick seems doing the right thing.=C2=A0

Again, happy new year and thanks for your kind help.

Jo.=C2=A0


2014/1/1 Nick Dokos <ndokos@gmail.com>
Joseph Vidal-Rosset <joseph.vidal.rosset@gmail.co= m> writes:

> 2013/12/30 Thomas S. Dye <tsd@tsdy= e.com>
>
> =C2=A0 =C2=A0 get this LaTeX, which works as expected:
>
> =C2=A0 =C2=A0 \begin{equation}
> =C2=A0 =C2=A0 \label{eq:2}
> =C2=A0 =C2=A0 A \to =C2=A0 =C2=A0 =C2=A0\neg{} =C2=A0 B
> =C2=A0 =C2=A0 \end{equation}
> =C2=A0 =C2=A0 % Emacs 24.3.1 (Org mode 8.2.4)
>
> Bonsoir Thomas,
>
> Indeed, the code works correctly. I do not understand why
> =C2=A0#+NAME: eq:2
> #+BEGIN_EQUATION
>
> #+END_EQUATION
> does not produce the same thing when I export it into latex.=C2=A0
>
> I have this list of preambules:=C2=A0
>
...snip...
>
> Could you send to me your configuration files and your preambles pleas= e, it would be certainly helpful.=C2=A0
>

The best way to proceed is to start with *no* configuration at all: start with a minimal init file that just loads org and sets up the
absolute minimum. Then try the exports. Here is my minimal file,
min.org.el, although you will need to modify the paths to suit your environ= ment:

--8<---------------cut here---------------start------------->8---
(add-to-list 'load-path "~/src/emacs/org/org-mode/lisp")
(add-to-list 'load-path "~/src/emacs/org/org-mode/contib/lisp"= ;)

(require 'org-loaddefs)

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mod= e))

(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'org-agenda)

--8<---------------cut here---------------end--------------->8---

I start emacs like this to use it:

=C2=A0 =C2=A0emacs -q -l /path/to/min.org.el


Then try exporting a small example like this:

--8<---------------cut here---------------start------------->8---
* Numbered displayed equations

#+BEGIN_EQUATION
A \to \neg B
#+END_EQUATION
--8<---------------cut here---------------end--------------->8-= --

This example works for both latex and html export for me but it's
somewhat misleading: both \to and \neg are org entities and they
go through the org-entity translation which produces this
for html:

,----
| <p>
| A &rarr; &not; B
| </p>
`----

and this for latex:

,----
| \begin{equation}
| A \(\to\) \(\neg{}\) B
| \end{equation}
`----

[The latex result could be simplified in this particular case: because
it's in an equation environment, TeX is already in math mode so the
inline delimiters \(...\) could be deleted, as could the {} - which I
think is unnecessary in any case for \neg - or any entity that requires
tex math mode. But since org does not know that TeX is in math mode, it
just makes sure by using \(..\) - it would probably be better to use
\ensuremath but that's a nit].

But let's take a look at something that is not just org-entities.
Here is the square root of pi divided by 2 in latex:

--8<---------------cut here---------------start------------->8---
#+BEGIN_EQUATION
\frac{\sqrt\pi}{2}
#+END_EQUATION
--8<---------------cut here---------------end--------------->8---

Exporting that to latex gives

,----
| \begin{equation}
| \frac{\sqrt\pi}{2}
| \end{equation}
`----

and to html:


,----
| <div class=3D"equation">
| <p>
| \frac{\sqrt\pi}{2}
| </p>
|
| </div>
`----

The latex result is perfect, but the html result is a disaster. =C2=A0The reason for that is that the special EQUATION block is translated by the
latex exporter to a reasonable latex construct, but the html exporter
does not have a similar html construct at its disposal: so it does the
generic thing and adds an equation div around it - which accomplishes
nothing.

OTOH, if you are using mathjax for displaying math in html (which is
the default for the html exporter), then I think going whole-hog to
latex notation works better. Using this in your org file

--8<---------------cut here---------------start------------->8---
\begin{equation}
\frac{\sqrt\pi}{2}
\end{equation}
--8<---------------cut here---------------end--------------->8---

does the right thing for both latex and html (with mathjax) export. =C2=A0A= nd
you can add a mathjax option to org-html-mathjax-template to produce
numbered equations (and omit the number with
\begin{equation*}...\end{equation*} just as in latex).

I may be missing something but using a BEGIN/END_EQUATION special block
just does not seem to do the right thing for both latex and html (let
alone any other backend, which is not handled by the other method either).<= br>
I should point out that using

--8<---------------cut here---------------start------------->8---
#+BEGIN_EQUATION
\[
\frac{\sqrt\pi}{2}
\]
#+END_EQUATION
--8<---------------cut here---------------end--------------->8---

with html/mathjax does the right thing (except for not numbering the
equation): the \[...\] delimiters signal mathjax to process the math
inside. But they break latex in the sense that you no longer get a
numbered equation.

So if you want latex and html export to do right by your math, I would
recommend the

--8<---------------cut here---------------start------------->8---
\begin{equation}
=C2=A0 =C2=A0...
\end{equation}
--8<---------------cut here---------------end--------------->8---

form.

All this is with latest org. org-7.x is probably different but I have
not gone back to check. And if I've got things wrong, I'd love to b= e
corrected.

Nick






--001a11360b7c506cb004eee5104f--