From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: latex equation and html export Date: Wed, 01 Jan 2014 01:28:31 -0500 Message-ID: <87zjng5i7k.fsf@alphaville.bos.redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyFIT-0006dY-87 for emacs-orgmode@gnu.org; Wed, 01 Jan 2014 01:28:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VyFIN-0003TK-1s for emacs-orgmode@gnu.org; Wed, 01 Jan 2014 01:28:53 -0500 Received: from plane.gmane.org ([80.91.229.3]:49795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyFIM-0003Se-Nw for emacs-orgmode@gnu.org; Wed, 01 Jan 2014 01:28:46 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VyFIK-0004IZ-Ut for emacs-orgmode@gnu.org; Wed, 01 Jan 2014 07:28:44 +0100 Received: from pool-98-110-175-184.bstnma.fios.verizon.net ([98.110.175.184]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Jan 2014 07:28:44 +0100 Received: from ndokos by pool-98-110-175-184.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Jan 2014 07:28:44 +0100 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: emacs-orgmode@gnu.org 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