emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] bugfix: fix previewing latex fragments with imagemagick
@ 2013-07-14  7:02 feng shu
  2013-07-14  7:06 ` feng shu
  0 siblings, 1 reply; 7+ messages in thread
From: feng shu @ 2013-07-14  7:02 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 129 bytes --]

Previewing and exporting latex fragments with imagemagick has been broken
when new export system merged.  This is the fix patch.

[-- Attachment #2: Type: text/html, Size: 156 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick
  2013-07-14  7:02 [PATCH] bugfix: fix previewing latex fragments with imagemagick feng shu
@ 2013-07-14  7:06 ` feng shu
  2013-07-14  8:29   ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: feng shu @ 2013-07-14  7:06 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 205 bytes --]

On Sun, Jul 14, 2013 at 3:02 PM, feng shu <tumashu@gmail.com> wrote:

> Previewing and exporting latex fragments with imagemagick has been broken
> when new export system merged.  This is the fix patch.
>

[-- Attachment #1.2: Type: text/html, Size: 532 bytes --]

[-- Attachment #2: 0001-bugfix-fix-generating-formula-image-with-imagemagick.patch --]
[-- Type: application/octet-stream, Size: 8864 bytes --]

From e8ad1f089d381b2fa02480370ccaa316ac44e22e Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
Date: Sun, 14 Jul 2013 14:18:53 +0800
Subject: [PATCH] bugfix: fix generating formula image with imagemagick when
 previewing and exporting

* lisp/ox-odt.el (org-odt--translate-latex-fragments): Fix imagemagick support.
* lisp/ox-html.el (org-html-latex-environment)
(org-html-latex-fragment): Fix imagemagick support.
* org.el (org-create-formula-image-with-imagemagick): Generate correct
size formula image.
* doc/org.texi (@LaTeX{} fragments)
(Previewing @LaTeX{} fragments)
(Math formatting in HTML export)
(Working with @LaTeX{} math snippets): Add document about creating
formula image with imagemagick.
---
 doc/org.texi    |   46 +++++++++++++++++++++++++++++++---------------
 lisp/org.el     |    2 +-
 lisp/ox-html.el |    4 ++--
 lisp/ox-odt.el  |   11 ++++++-----
 4 个文件被修改,插入 40 行(+),删除 23 行(-)

diff --git a/doc/org.texi b/doc/org.texi
index 8db410c..4d13db9 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10156,10 +10156,10 @@ snippets will be identified as @LaTeX{} source code:
 @item
 Environments of any kind@footnote{When @file{MathJax} is used, only the
 environments recognized by @file{MathJax} will be processed.  When
-@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
 
 @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
 @code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{}
 fragments can be processed to produce preview images of the typeset
 expressions:
@@ -11256,7 +11257,7 @@ You could use @code{http} addresses just as well.
 @node Math formatting in HTML export, Text areas in HTML export, Images in HTML export, HTML export
 @subsection Math formatting in HTML export
 @cindex MathJax
-@cindex dvipng
+@cindex dvipng or imagemagick
 
 @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
 
 @example
 #+OPTIONS: tex:dvipng
 @end example
 
+or:
+
+@example
+#+OPTIONS: tex:imagemagick
+@end example
+
+
+
 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
 @subsection Text areas in HTML export
 
@@ -12264,7 +12273,7 @@ Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file
 and open the formula file with the system-registered application.
 @end table
 
-@cindex dvipng
+@cindex dvipng or imagemagick
 @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
+
 With this option, @LaTeX{} fragments are processed into PNG images and the
 resulting images are embedded in the exported document.  This method requires
-that the @file{dvipng} program be available on your system.
+that the @file{dvipng} program  or @file{imagemagick} suite be available on
+your system.
 @end enumerate
 
 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export
diff --git a/lisp/org.el b/lisp/org.el
index f8cd447..536c98a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18609,7 +18609,7 @@ share a good deal of logic."
                   (font-height (face-font 'default))
                 (face-attribute 'default :height nil)))
 	 (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
-	 (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))))))
+	 (dpi (number-to-string (* scale (floor (if buffer fnh 120.)))))
 	 (fg (or (plist-get options (if buffer :foreground :html-foreground))
 		 "black"))
 	 (bg (or (plist-get options (if buffer :background :html-background))
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 9843d98..d1abe15 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2497,7 +2497,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
     (case processing-type
       ((t mathjax)
        (org-html-format-latex latex-frag 'mathjax))
-      (dvipng
+      ((or dvipng imagemagick)
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	   ;; Do not provide a caption or a name to be consistent with
@@ -2517,7 +2517,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
     (case processing-type
       ((t mathjax)
        (org-html-format-latex latex-frag 'mathjax))
-      (dvipng
+      ((or dvipng imagemagick)
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	   (org-html--format-image (match-string 1 formula-link) nil info))))
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index e89306e..f6f9e04 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -3772,9 +3772,10 @@ contextual information."
 	   (setq processing-type 'mathml)
 	 (message "LaTeX to MathML converter not available.")
 	 (setq processing-type 'verbatim)))
-      (dvipng
+      ((or dvipng imagemagick)
        (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))
 	 (message "LaTeX to PNG converter not available.")
 	 (setq processing-type 'verbatim)))
       (otherwise
@@ -3787,7 +3788,7 @@ contextual information."
     (message "Formatting LaTeX using %s" processing-type)
 
     ;; Convert `latex-fragment's and `latex-environment's.
-    (when (memq processing-type '(mathml dvipng))
+    (when (memq processing-type '(mathml dvipng imagemagick))
       (org-element-map tree '(latex-fragment latex-environment)
 	(lambda (latex-*)
 	  (incf count)
@@ -3796,13 +3797,13 @@ contextual information."
 		 (cache-dir (file-name-directory input-file))
 		 (cache-subdir (concat
 				(case processing-type
-				  (dvipng "ltxpng/")
+				  ((or dvipng imagemagick) "ltxpng/")
 				  (mathml "ltxmathml/"))
 				(file-name-sans-extension
 				 (file-name-nondirectory input-file))))
 		 (display-msg
 		  (case processing-type
-		    (dvipng (format "Creating LaTeX Image %d..." count))
+		    ((or dvipng imagemagick) (format "Creating LaTeX Image %d..." count))
 		    (mathml (format "Creating MathML snippet %d..." count))))
 		 ;; Get an Org-style link to PNG image or the MathML
 		 ;; file.
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick
  2013-07-14  7:06 ` feng shu
@ 2013-07-14  8:29   ` Nicolas Goaziou
  2013-07-14  8:35     ` Nicolas Goaziou
  2013-07-14 13:03     ` Feng Shu
  0 siblings, 2 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2013-07-14  8:29 UTC (permalink / raw)
  To: feng shu; +Cc: emacs-orgmode@gnu.org

Hello,

feng shu <tumashu@gmail.com> 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').

>  @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".

> -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?

> -      (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))

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,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick
  2013-07-14  8:29   ` Nicolas Goaziou
@ 2013-07-14  8:35     ` Nicolas Goaziou
  2013-07-14 13:08       ` Feng Shu
  2013-07-14 13:03     ` Feng Shu
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2013-07-14  8:35 UTC (permalink / raw)
  To: feng shu; +Cc: emacs-orgmode@gnu.org

Correcting myself:

Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
> feng shu <tumashu@gmail.com> writes:
>
>>         (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))
>
> There's a missing `or':
>
>   (or (org-check-external-command "dvipng" "" t)
>       (org-check-external-command "convert" "" t))

Err. This is still wrong.

Use 

  (and (org-check-external-command "latex" "" t)
       (org-check-external-command
        (if (eq processing-type 'dvipng) "dvipng" "convert") "" t))

instead.

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick
  2013-07-14  8:29   ` Nicolas Goaziou
  2013-07-14  8:35     ` Nicolas Goaziou
@ 2013-07-14 13:03     ` Feng Shu
  1 sibling, 0 replies; 7+ messages in thread
From: Feng Shu @ 2013-07-14 13:03 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> feng shu <tumashu@gmail.com> 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,

-- 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick
  2013-07-14  8:35     ` Nicolas Goaziou
@ 2013-07-14 13:08       ` Feng Shu
  2013-07-15  7:43         ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Feng Shu @ 2013-07-14 13:08 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 21 bytes --]


This is version 2,


[-- Attachment #2: 0001-Fix-generating-LaTeX-formula-images.patch --]
[-- Type: text/x-diff, Size: 8125 bytes --]

From 1ea9620cd3051cb982a4fb7ddb6f8a68fd0df4a6 Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
Date: Sun, 14 Jul 2013 14:18:53 +0800
Subject: [PATCH] Fix generating LaTeX formula images

* lisp/ox-odt.el (org-odt--translate-latex-fragments): Fix imagemagick support.
* lisp/ox-html.el (org-html-latex-environment)
(org-html-latex-fragment): Fix imagemagick support.
* org.el (org-create-formula-image-with-imagemagick): Generate correct
size formula image.
(org-format-latex-header): Change pagestyle command position.
* doc/org.texi (@LaTeX{} fragments)
(Previewing @LaTeX{} fragments)
(Math formatting in HTML export)
(Working with @LaTeX{} math snippets): Add document about creating
formula image with imagemagick.
---
 doc/org.texi    |   32 +++++++++++++++++++++++---------
 lisp/org.el     |    4 ++--
 lisp/ox-html.el |    4 ++--
 lisp/ox-odt.el  |   11 ++++++-----
 4 个文件被修改,插入 33 行(+),删除 18 行(-)

diff --git a/doc/org.texi b/doc/org.texi
index 8db410c..97e6ef6 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10156,10 +10156,10 @@ snippets will be identified as @LaTeX{} source code:
 @item
 Environments of any kind@footnote{When @file{MathJax} is used, only the
 environments recognized by @file{MathJax} will be processed.  When
-@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
@@ -10197,7 +10197,6 @@ 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}
 @end example
@@ -11257,6 +11256,7 @@ You could use @code{http} addresses just as well.
 @subsection Math formatting in HTML export
 @cindex MathJax
 @cindex dvipng
+@cindex imagemagick
 
 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
 different ways on HTML pages.  The default is to use the
@@ -11282,13 +11282,19 @@ 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
 
 @example
 #+OPTIONS: tex:dvipng
 @end example
 
+or:
+
+@example
+#+OPTIONS: tex:imagemagick
+@end example
+
 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
 @subsection Text areas in HTML export
 
@@ -12265,17 +12271,25 @@ and open the formula file with the system-registered application.
 @end table
 
 @cindex dvipng
+@cindex imagemagick
 @item PNG images
 
 This option is activated on a per-file basis with
 
 @example
-#+OPTIONS: LaTeX:dvipng
+#+OPTIONS: tex:dvipng
+@end example
+
+or:
+
+@example
+#+OPTIONS: tex:imagemagick
 @end example
 
 With this option, @LaTeX{} fragments are processed into PNG images and the
 resulting images are embedded in the exported document.  This method requires
-that the @file{dvipng} program be available on your system.
+that the @file{dvipng} program or @file{imagemagick} suite be available on
+your system.
 @end enumerate
 
 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export
diff --git a/lisp/org.el b/lisp/org.el
index f8cd447..fb5099e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3764,9 +3764,9 @@ images at the same place."
 \\usepackage[usenames]{color}
 \\usepackage{amsmath}
 \\usepackage[mathscr]{eucal}
-\\pagestyle{empty}             % do not remove
 \[PACKAGES]
 \[DEFAULT-PACKAGES]
+\\pagestyle{empty}             % do not remove
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
 \\addtolength{\\textwidth}{-3cm}
@@ -18609,7 +18609,7 @@ share a good deal of logic."
                   (font-height (face-font 'default))
                 (face-attribute 'default :height nil)))
 	 (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
-	 (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))))))
+	 (dpi (number-to-string (* scale (floor (if buffer fnh 120.)))))
 	 (fg (or (plist-get options (if buffer :foreground :html-foreground))
 		 "black"))
 	 (bg (or (plist-get options (if buffer :background :html-background))
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 9843d98..9fc53f1 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2497,7 +2497,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
     (case processing-type
       ((t mathjax)
        (org-html-format-latex latex-frag 'mathjax))
-      (dvipng
+      ((dvipng imagemagick)
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	   ;; Do not provide a caption or a name to be consistent with
@@ -2517,7 +2517,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
     (case processing-type
       ((t mathjax)
        (org-html-format-latex latex-frag 'mathjax))
-      (dvipng
+      ((dvipng imagemagick)
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	   (org-html--format-image (match-string 1 formula-link) nil info))))
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index e89306e..0b7a653 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -3772,9 +3772,10 @@ contextual information."
 	   (setq processing-type 'mathml)
 	 (message "LaTeX to MathML converter not available.")
 	 (setq processing-type 'verbatim)))
-      (dvipng
+      ((dvipng imagemagick)
        (unless (and (org-check-external-command "latex" "" t)
-		    (org-check-external-command "dvipng" "" t))
+		    (org-check-external-command
+		     (if (eq processing-type 'dvipng) "dvipng" "convert") "" t))
 	 (message "LaTeX to PNG converter not available.")
 	 (setq processing-type 'verbatim)))
       (otherwise
@@ -3787,7 +3788,7 @@ contextual information."
     (message "Formatting LaTeX using %s" processing-type)
 
     ;; Convert `latex-fragment's and `latex-environment's.
-    (when (memq processing-type '(mathml dvipng))
+    (when (memq processing-type '(mathml dvipng imagemagick))
       (org-element-map tree '(latex-fragment latex-environment)
 	(lambda (latex-*)
 	  (incf count)
@@ -3796,13 +3797,13 @@ contextual information."
 		 (cache-dir (file-name-directory input-file))
 		 (cache-subdir (concat
 				(case processing-type
-				  (dvipng "ltxpng/")
+				  ((dvipng imagemagick) "ltxpng/")
 				  (mathml "ltxmathml/"))
 				(file-name-sans-extension
 				 (file-name-nondirectory input-file))))
 		 (display-msg
 		  (case processing-type
-		    (dvipng (format "Creating LaTeX Image %d..." count))
+		    ((dvipng imagemagick) (format "Creating LaTeX Image %d..." count))
 		    (mathml (format "Creating MathML snippet %d..." count))))
 		 ;; Get an Org-style link to PNG image or the MathML
 		 ;; file.
-- 
1.7.10.4


[-- Attachment #3: Type: text/plain, Size: 6 bytes --]



-- 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] bugfix: fix previewing latex fragments with imagemagick
  2013-07-14 13:08       ` Feng Shu
@ 2013-07-15  7:43         ` Nicolas Goaziou
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2013-07-15  7:43 UTC (permalink / raw)
  To: Feng Shu; +Cc: emacs-orgmode@gnu.org

Hello,

Feng Shu <tumashu@gmail.com> writes:

> This is version 2,

Thanks for the update. It looks mostly good. I have just one question
about it.

>  \\usepackage[usenames]{color}
>  \\usepackage{amsmath}
>  \\usepackage[mathscr]{eucal}
> -\\pagestyle{empty}             % do not remove
>  \[PACKAGES]
>  \[DEFAULT-PACKAGES]
> +\\pagestyle{empty}             % do not remove
>  % The settings below are copied from fullpage.sty
>  \\setlength{\\textwidth}{\\paperwidth}
>  \\addtolength{\\textwidth}{-3cm}


Is there a reason for that change?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-07-15  7:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-14  7:02 [PATCH] bugfix: fix previewing latex fragments with imagemagick feng shu
2013-07-14  7:06 ` feng shu
2013-07-14  8:29   ` Nicolas Goaziou
2013-07-14  8:35     ` Nicolas Goaziou
2013-07-14 13:08       ` Feng Shu
2013-07-15  7:43         ` Nicolas Goaziou
2013-07-14 13:03     ` Feng Shu

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).