emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Mathjax vs. problems with imagemagick
Date: Sun, 06 Jul 2014 17:25:30 -0400	[thread overview]
Message-ID: <87mwcm6uyd.fsf@gmail.com> (raw)
In-Reply-To: CAD-VTcHumycKQMdfT3X3T0Mb7oMcodgmsMosQrD9F1qzG4qivw@mail.gmail.com

Joseph Vidal-Rosset <joseph.vidal.rosset@gmail.com> 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)                                       <<<<<<<<<<<<<<ADDED THIS
    (if (not (file-exists-p pdffile))
	(progn (message "Failed to create pdf file from %s" texfile) nil)
      (ignore-errors
	(if (featurep 'xemacs)
	    (call-process "convert" nil nil nil
			  "-density" "96"
			  "-trim"
			  "-antialias"
			  pdffile
			  "-quality" "100"
			  ;; "-sharpen" "0x1.0"
			  pngfile)
	  (call-process "convert" nil nil nil
			"-density" dpi
			"-trim"
			"-antialias"
			pdffile
			"-quality" "100"
			;; "-sharpen" "0x1.0"
			pngfile)))
--8<---------------cut here---------------end--------------->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

  parent reply	other threads:[~2014-07-06 21:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-06  8:03 Mathjax vs. problems with imagemagick Joseph Vidal-Rosset
2014-07-06  8:39 ` briangpowell .
2014-07-06  8:59   ` Joseph Vidal-Rosset
2014-07-06 21:25 ` Nick Dokos [this message]
2014-07-08 13:01   ` Joseph Vidal-Rosset
2014-07-08 13:04     ` Joseph Vidal-Rosset
2014-07-08 13:44       ` Joseph Vidal-Rosset
2014-07-11  0:59     ` Nick Dokos
2014-07-11  7:38       ` Joseph Vidal-Rosset
2014-07-11 15:59         ` Nick Dokos
2014-07-11 16:06           ` Joseph Vidal-Rosset
2014-07-11 18:05             ` Nick Dokos
2014-07-11 18:24               ` Joseph Vidal-Rosset
2014-07-28 14:36               ` Sebastien Vauban

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=87mwcm6uyd.fsf@gmail.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).