From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Mathjax vs. problems with imagemagick Date: Sun, 06 Jul 2014 17:25:30 -0400 Message-ID: <87mwcm6uyd.fsf@gmail.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]:44863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3twY-0000w2-LH for emacs-orgmode@gnu.org; Sun, 06 Jul 2014 17:26:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X3twQ-0005Mi-Vh for emacs-orgmode@gnu.org; Sun, 06 Jul 2014 17:25:54 -0400 Received: from plane.gmane.org ([80.91.229.3]:45841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3twQ-0005MR-LU for emacs-orgmode@gnu.org; Sun, 06 Jul 2014 17:25:46 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1X3twO-0003gx-L5 for emacs-orgmode@gnu.org; Sun, 06 Jul 2014 23:25:44 +0200 Received: from pool-98-110-160-12.bstnma.fios.verizon.net ([98.110.160.12]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Jul 2014 23:25:44 +0200 Received: from ndokos by pool-98-110-160-12.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 Jul 2014 23:25:44 +0200 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: > To convert equations from *.orgĀ  into *.html, Mathjax is certainly the > best solution but unfortunately, this solution does not work as soons > as one need to use some texlive package convenient to produce easily > proofs in specific format (for example if one uses bussproofs.sty of > fitch.sty ). > > That is why imagemagick is useful. Unfortunately, the produced png > images in my ltxpng/ have a very bad quality and if the browser load > them, the result is terrible. I met already this problem and I do not > remind what was the solution... > > I you have suggestions... > The process by which images are produced (for imagemagick: dvipng follows a slightly different path) is to wrap the latex fragment into a complete latex file, run pdflatex (or whatever your org-latex-pdf-process says) to produce a pdf file and then run the imagemagick `convert' program to produce the png. I'd suggest that you duplicate this process by hand and see where it goes wrong. I usually do that by adding a (debug) call into org-create-formula-image-with-imagemagick like this: --8<---------------cut here---------------start------------->8--- (let ((latex-header (org-create-formula--latex-header))) (with-temp-file texfile (insert latex-header) (insert "\n\\begin{document}\n" "\\definecolor{fg}{rgb}{" fg "}\n" "\\definecolor{bg}{rgb}{" bg "}\n" "\n\\pagecolor{bg}\n" "\n{\\color{fg}\n" string "\n}\n" "\n\\end{document}\n"))) (org-latex-compile texfile t) (debug) <<<<<<<<<<<<<8--- I then reload the file (M-x load-file RET /path/to/org.el RET) to pick up the modified function and proceed normally to export the file. When the (debug) is executed, I get a debug buffer and I can examine things like `texfile' and `dpi', using the debugger's `e' command. I then copy the latex file named by `texfile' to some private directory and run pdflatex on it and then (using the dpi value the debugger showed me - in my case, it was "120.0"), I convert to png using the same command as the function does: cp /tmp/orgtex3771B9p.tex foo.tex pdflatex foo.tex convert -density 120.0 -trim -antialias foo.pdf -quality 100 foo.png The whole thing is a bit fiddly but not really difficult: it takes more time to explain than to do. BTW, if you go this way, don't forget to delete the (debug) afterwards. HTH. -- Nick