From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick Date: Sun, 14 Jul 2013 21:03:04 +0800 Message-ID: <877ggt70qf.fsf@gmail.com> References: <87ehb1lf31.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyLxM-0006f6-UI for emacs-orgmode@gnu.org; Sun, 14 Jul 2013 09:03:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyLxJ-0004LQ-H4 for emacs-orgmode@gnu.org; Sun, 14 Jul 2013 09:03:16 -0400 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]:62195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyLxJ-0004L3-6n for emacs-orgmode@gnu.org; Sun, 14 Jul 2013 09:03:13 -0400 Received: by mail-pd0-f182.google.com with SMTP id r10so9934573pdi.13 for ; Sun, 14 Jul 2013 06:03:12 -0700 (PDT) Received: from smtp.gmail.com ([2001:c08:2600::713]) by mx.google.com with ESMTPSA id ht5sm9862343pbb.29.2013.07.14.06.03.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 14 Jul 2013 06:03:10 -0700 (PDT) In-Reply-To: <87ehb1lf31.fsf@gmail.com> (Nicolas Goaziou's message of "Sun, 14 Jul 2013 10:29:22 +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 Nicolas Goaziou writes: > Hello, > > feng shu writes: > >> Previewing and exporting latex fragments with imagemagick has been broken >> when new export system merged. This is the fix patch. > > Thanks for the patch. Here are a few comments. > >> Subject: [PATCH] bugfix: fix generating formula image with imagemagick when >> previewing and exporting > > Prefer "Fix generating LaTeX formula images" as subject. > >> -@file{dvipng} is used to create images, any @LaTeX{} environment will be >> -handled.}. The only requirement is that the @code{\begin} and @code{\end} >> -statements appear on a new line, at the beginning of the line or after >> -whitespaces only. >> +@file{dvipng} program or @file{imagemagick} suite is used to create images, >> +any @LaTeX{} environment will be handled.}. The only requirement is that the >> +@code{\begin} and @code{\end} statements appear on a new line, at the >> +beginning of the line or after whitespaces only. >> @item >> Text within the usual @LaTeX{} math delimiters. To avoid conflicts with >> currency specifications, single @samp{$} characters are only recognized as >> @@ -10196,10 +10196,11 @@ You can also set this variable on a >> per-file basis using one of these >> lines: >> >> @example >> -#+OPTIONS: tex:t @r{Do the right thing automatically (MathJax)} >> -#+OPTIONS: tex:dvipng @r{Force using dvipng images} >> -#+OPTIONS: tex:nil @r{Do not process @LaTeX{} fragments at all} >> -#+OPTIONS: tex:verbatim @r{Verbatim export, for jsMath or so} >> +#+OPTIONS: tex:t @r{Do the right thing automatically (MathJax)} >> +#+OPTIONS: tex:dvipng @r{Force using dvipng images} >> +#+OPTIONS: tex:imagemagick @r{Force using images converted by imagemagick} >> +#+OPTIONS: tex:nil @r{Do not process @LaTeX{} fragments at all} >> +#+OPTIONS: tex:verbatim @r{Verbatim export, for jsMath or so} >> @end example > > It should be: > > @example > #+OPTIONS: tex:t @r{Do the right thing automatically (MathJax)} > #+OPTIONS: tex:nil @r{Do not process @LaTeX{} fragments at all} > #+OPTIONS: tex:verbatim @r{Verbatim export, for jsMath or so} > @end example > > because `org-export-with-latex' provides neither `dvipng' nor > `imagemagick' options. Those are added by some back-ends (e.g., > `org-html-with-latex'). > I just find "dvipng" and add a similar "imagemagick" line below..... Good luck.... >> @node Previewing @LaTeX{} fragments, CDLaTeX mode, @LaTeX{} >> fragments, Embedded @LaTeX{} >> @@ -10207,8 +10208,8 @@ lines: >> @cindex @LaTeX{} fragments, preview >> >> @vindex org-latex-create-formula-image-program >> -If you have @file{dvipng} or @file{imagemagick} installed@footnote{Choose the >> -converter by setting the variable >> +If you have @file{dvipng} program or @file{imagemagick} suite >> +installed@footnote{Choose the converter by setting the variable > > Does this change really matter? > >> -@cindex dvipng >> +@cindex dvipng or imagemagick > > Use > > @cindex dvipng > @cindex imagemagick > > instead. > >> @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two >> different ways on HTML pages. The default is to use the >> @@ -11282,13 +11283,21 @@ this line. >> If you prefer, you can also request that @LaTeX{} fragments are processed >> into small images that will be inserted into the browser page. Before the >> availability of MathJax, this was the default method for Org files. This >> -method requires that the @file{dvipng} program is available on your system. >> -You can still get this processing with >> +method requires that the @file{dvipng} program or @file{imagemagick} suite is >> +available on your system.You can still get this processing with > > Mind the spaces: too many before "or", not enough before "You". > >> +or: >> + >> +@example >> +#+OPTIONS: tex:imagemagick >> +@end example >> + >> + >> + > > Nitpick: No need for so many blank lines. > >> -@cindex dvipng >> +@cindex dvipng or imagemagick > > See above. > >> @item PNG images >> >> This option is activated on a per-file basis with >> @@ -12273,9 +12282,16 @@ This option is activated on a per-file basis with >> #+OPTIONS: LaTeX:dvipng >> @end example >> >> +or: >> + >> +@example >> +#+OPTIONS: LaTeX:imagemagick >> +@end example >> + > > OK. But documentation is still wrong here. It should be "tex:dvipng" and > "tex:imagemagick". Good luck +1 > >> -that the @file{dvipng} program be available on your system. >> +that the @file{dvipng} program or @file{imagemagick} suite be available on >> +your system. > > Check white spaces. > >> - (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.)))))) >> + (dpi (number-to-string (* scale (floor (if buffer fnh 120.))))) > > Note sure about this change. Why do you think it is needed? Compared with buffer font height, The font height in image generated seemd too small, This may be a bug I introduced when I coded imagemagick feature a year ago. > >> - (dvipng >> + ((or dvipng imagemagick) > > It should be: > > ((dvipng imagemagick) > > See `case' documentation. > >> - (dvipng >> + ((or dvipng imagemagick) > > Ditto. > >> - (dvipng >> + ((or dvipng imagemagick) > > Ditto. > >> (unless (and (org-check-external-command "latex" "" t) >> - (org-check-external-command "dvipng" "" t)) >> + (org-check-external-command "dvipng" "" t) >> + (org-check-external-command "convert" "" t)) > The imagemagick feature use (car org-latex-pdf-process) to generate pdf file , then convert it to image. check "latex" may be no effort, but it has no harm too. > There's a missing `or': > > (or (org-check-external-command "dvipng" "" t) > (org-check-external-command "convert" "" t)) > >> (case processing-type >> - (dvipng "ltxpng/") >> + ((or dvipng imagemagick) "ltxpng/") > > See above. > >> (case processing-type >> - (dvipng (format "Creating LaTeX Image %d..." count)) >> + ((or dvipng imagemagick) (format "Creating LaTeX Image %d..." count)) > > See above. > > > Regards, --