From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Question on latex source block Date: Sun, 09 Sep 2012 13:44:21 -0400 Message-ID: <13524.1347212661@alphaville> References: <40C7B1BFC291ED4E9D10436D07736A3347089E653C@EXMAIL7.haas.uc.berkeley.edu> <8243.1347174432@alphaville> <87bohfywdt.fsf@gmx.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:60782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAlYZ-0007gd-T7 for emacs-orgmode@gnu.org; Sun, 09 Sep 2012 13:44:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TAlYY-0002P3-Dy for emacs-orgmode@gnu.org; Sun, 09 Sep 2012 13:44:27 -0400 Received: from g5t0008.atlanta.hp.com ([15.192.0.45]:20360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAlYY-0002Oz-8S for emacs-orgmode@gnu.org; Sun, 09 Sep 2012 13:44:26 -0400 In-Reply-To: Message from Eric Schulte of "Sun, 09 Sep 2012 10:49:18 MDT." <87bohfywdt.fsf@gmx.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: Eric Schulte Cc: Richard Stanton , "emacs-orgmode@gnu.org" Eric Schulte wrote: > > > > Nothing - it's a bug introduced by commit a9d3ce0bcd3492eb0cd2aa7b0d1f6ee93276114b: > > > > ,---- > > | commit a9d3ce0bcd3492eb0cd2aa7b0d1f6ee93276114b > > | Author: Feng Shu > > | Date: Fri Apr 20 19:21:43 2012 +0200 > > | > > | Allow to use imagemagick for previewing LaTeX fragements. > > | > > | * org.el (org-latex-create-formula-image-program): New option > > | to use either dvipng or imagemagick to convert and preview > > | LaTeX fragments. > > | (org-preview-latex-fragment, org-format-latex): Handle the new > > | option. > > | (org-create-formula-image-with-dvipng): Rename from > > | `org-create-formula-image'. > > | (org-create-formula-image-with-imagemagick): New defun to > > | handle LaTeX preview with imagemagick. > > | (org-latex-color, org-latex-color-format): New defuns to > > | handle color conversions. > > | > > | * org-latex.el (org-latex-to-pdf-process, org-export-as-pdf): > > | Allow to use imagemagick to convert LaTeX fragments. > > | > > | * org-html.el (org-export-html-preprocess): Ditto. > > | > > | * org-exp.el (org-export-with-LaTeX-fragments): Ditto. > > | > > | * org.texi (@LaTeX{} fragments): Document imagemagick as an > > | alternative to dvipng. > > | > > `---- > > > > org-create-formula-image got renamed, but the reference in ob-latex.el > > to the original name was not changed. > > > > The quick-and-dirty "fix" is to change the reference in ob-latex.el to > > org-create-formula-image-dvipng or org-create-formula-image-imagemagick, > > depending on which method you happen to be using. But one would resort > > to that only in the direst emergency in order to get something working > > as quickly as possible. > > > > IMO, it would be better to have split the dvipng/imagemagick decision at > > a lower level in the code. That way, both org-format-latex and > > org-babel-execute:latex would use the common function. As it is, > > org-format-latex is a fairly "dirty" function and with the split, it got > > even dirtier. > > > > But there may be difficulties that my quick glance through the code has > > not uncovered: it needs a deeper look. > > > > So, what would you recommend as a full fix in ob-latex.el? The attached > commit selects an alternate function based on the value of the > `org-latex-create-formula-image-program' variable. Does this seem like > an appropriate fix to the problem? > For the time being, yes: I think this fix is entirely appropriate (nb: haven't tested it yet though). In the longer run, I would like to see a single function (org-create-formula-image redux) be called from the two call sites (org-format-latex and org-babel-execute:latex) and have the dvipng/imagemagick/etc split be entirely within that function. It's bound to happen that more methods of creating images (the etc part above) will need to be added in the future and it behooves one to arrange it so that only one place in the code is affected. Thanks, Nick > Thanks, > > From 4ad24215f86f24d44439e013c16a4d78e1df68b6 Mon Sep 17 00:00:00 2001 > From: Eric Schulte > Date: Sun, 9 Sep 2012 10:48:02 -0600 > Subject: [PATCH] replace org-create-formula-image w/new functions > > A previous commit deleted the definition of `org-create-formula-image' > without removing all calls to the function. This commit fixes the > resultant bug in ob-latex by replacing the deleted function with a > conditional call to one of the two replacement functions. > --- > lisp/ob-latex.el | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el > index 43f673e..339584e 100644 > --- a/lisp/ob-latex.el > +++ b/lisp/ob-latex.el > @@ -86,7 +86,12 @@ This function is called by `org-babel-execute-src-block'." > org-export-latex-packages-alist))) > (cond > ((and (string-match "\\.png$" out-file) (not imagemagick)) > - (org-create-formula-image > + (funcall > + (case org-latex-create-formula-image-program > + ('dvipng #'org-create-formula-image-with-dvipng) > + ('imagemagick #'org-create-formula-image-with-imagemagick) > + (t (error > + "invalid value of `org-latex-create-formula-image-program'"))) > body out-file org-format-latex-options in-buffer)) > ((or (string-match "\\.pdf$" out-file) imagemagick) > (require 'org-latex) > -- > 1.7.12 > > > -- > Eric Schulte > http://cs.unm.edu/~eschulte