Browse Source

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.
Feng Shu 11 years ago
parent
commit
2a94fca6ca
4 changed files with 33 additions and 18 deletions
  1. 23 9
      doc/org.texi
  2. 2 2
      lisp/org.el
  3. 2 2
      lisp/ox-html.el
  4. 6 5
      lisp/ox-odt.el

+ 23 - 9
doc/org.texi

@@ -10156,10 +10156,10 @@ snippets will be identified as @LaTeX{} source code:
 @item
 @item
 Environments of any kind@footnote{When @file{MathJax} is used, only the
 Environments of any kind@footnote{When @file{MathJax} is used, only the
 environments recognized by @file{MathJax} will be processed.  When
 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
 @item
 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 currency specifications, single @samp{$} characters are only recognized as
 currency specifications, single @samp{$} characters are only recognized as
@@ -10197,7 +10197,6 @@ lines:
 
 
 @example
 @example
 #+OPTIONS: tex:t          @r{Do the right thing automatically (MathJax)}
 #+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:nil        @r{Do not process @LaTeX{} fragments at all}
 #+OPTIONS: tex:verbatim   @r{Verbatim export, for jsMath or so}
 #+OPTIONS: tex:verbatim   @r{Verbatim export, for jsMath or so}
 @end example
 @end example
@@ -11257,6 +11256,7 @@ You could use @code{http} addresses just as well.
 @subsection Math formatting in HTML export
 @subsection Math formatting in HTML export
 @cindex MathJax
 @cindex MathJax
 @cindex dvipng
 @cindex dvipng
+@cindex imagemagick
 
 
 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
 different ways on HTML pages.  The default is to use the
 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
 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
 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
 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
 @example
 #+OPTIONS: tex:dvipng
 #+OPTIONS: tex:dvipng
 @end example
 @end example
 
 
+or:
+
+@example
+#+OPTIONS: tex:imagemagick
+@end example
+
 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
 @subsection Text areas in HTML export
 @subsection Text areas in HTML export
 
 
@@ -12265,17 +12271,25 @@ and open the formula file with the system-registered application.
 @end table
 @end table
 
 
 @cindex dvipng
 @cindex dvipng
+@cindex imagemagick
 @item PNG images
 @item PNG images
 
 
 This option is activated on a per-file basis with
 This option is activated on a per-file basis with
 
 
 @example
 @example
-#+OPTIONS: LaTeX:dvipng
+#+OPTIONS: tex:dvipng
+@end example
+
+or:
+
+@example
+#+OPTIONS: tex:imagemagick
 @end example
 @end example
 
 
 With this option, @LaTeX{} fragments are processed into PNG images and the
 With this option, @LaTeX{} fragments are processed into PNG images and the
 resulting images are embedded in the exported document.  This method requires
 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
 @end enumerate
 
 
 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export
 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export

+ 2 - 2
lisp/org.el

@@ -3764,9 +3764,9 @@ images at the same place."
 \\usepackage[usenames]{color}
 \\usepackage[usenames]{color}
 \\usepackage{amsmath}
 \\usepackage{amsmath}
 \\usepackage[mathscr]{eucal}
 \\usepackage[mathscr]{eucal}
-\\pagestyle{empty}             % do not remove
 \[PACKAGES]
 \[PACKAGES]
 \[DEFAULT-PACKAGES]
 \[DEFAULT-PACKAGES]
+\\pagestyle{empty}             % do not remove
 % The settings below are copied from fullpage.sty
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
 \\setlength{\\textwidth}{\\paperwidth}
 \\addtolength{\\textwidth}{-3cm}
 \\addtolength{\\textwidth}{-3cm}
@@ -18609,7 +18609,7 @@ share a good deal of logic."
                   (font-height (face-font 'default))
                   (font-height (face-font 'default))
                 (face-attribute 'default :height nil)))
                 (face-attribute 'default :height nil)))
 	 (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
 	 (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))
 	 (fg (or (plist-get options (if buffer :foreground :html-foreground))
 		 "black"))
 		 "black"))
 	 (bg (or (plist-get options (if buffer :background :html-background))
 	 (bg (or (plist-get options (if buffer :background :html-background))

+ 2 - 2
lisp/ox-html.el

@@ -2497,7 +2497,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
     (case processing-type
     (case processing-type
       ((t mathjax)
       ((t mathjax)
        (org-html-format-latex latex-frag 'mathjax))
        (org-html-format-latex latex-frag 'mathjax))
-      (dvipng
+      ((dvipng imagemagick)
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	   ;; Do not provide a caption or a name to be consistent with
 	   ;; 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
     (case processing-type
       ((t mathjax)
       ((t mathjax)
        (org-html-format-latex latex-frag 'mathjax))
        (org-html-format-latex latex-frag 'mathjax))
-      (dvipng
+      ((dvipng imagemagick)
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
        (let ((formula-link (org-html-format-latex latex-frag processing-type)))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
 	   (org-html--format-image (match-string 1 formula-link) nil info))))
 	   (org-html--format-image (match-string 1 formula-link) nil info))))

+ 6 - 5
lisp/ox-odt.el

@@ -3772,9 +3772,10 @@ contextual information."
 	   (setq processing-type 'mathml)
 	   (setq processing-type 'mathml)
 	 (message "LaTeX to MathML converter not available.")
 	 (message "LaTeX to MathML converter not available.")
 	 (setq processing-type 'verbatim)))
 	 (setq processing-type 'verbatim)))
-      (dvipng
+      ((dvipng imagemagick)
        (unless (and (org-check-external-command "latex" "" t)
        (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.")
 	 (message "LaTeX to PNG converter not available.")
 	 (setq processing-type 'verbatim)))
 	 (setq processing-type 'verbatim)))
       (otherwise
       (otherwise
@@ -3787,7 +3788,7 @@ contextual information."
     (message "Formatting LaTeX using %s" processing-type)
     (message "Formatting LaTeX using %s" processing-type)
 
 
     ;; Convert `latex-fragment's and `latex-environment's.
     ;; 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)
       (org-element-map tree '(latex-fragment latex-environment)
 	(lambda (latex-*)
 	(lambda (latex-*)
 	  (incf count)
 	  (incf count)
@@ -3796,13 +3797,13 @@ contextual information."
 		 (cache-dir (file-name-directory input-file))
 		 (cache-dir (file-name-directory input-file))
 		 (cache-subdir (concat
 		 (cache-subdir (concat
 				(case processing-type
 				(case processing-type
-				  (dvipng "ltxpng/")
+				  ((dvipng imagemagick) "ltxpng/")
 				  (mathml "ltxmathml/"))
 				  (mathml "ltxmathml/"))
 				(file-name-sans-extension
 				(file-name-sans-extension
 				 (file-name-nondirectory input-file))))
 				 (file-name-nondirectory input-file))))
 		 (display-msg
 		 (display-msg
 		  (case processing-type
 		  (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))))
 		    (mathml (format "Creating MathML snippet %d..." count))))
 		 ;; Get an Org-style link to PNG image or the MathML
 		 ;; Get an Org-style link to PNG image or the MathML
 		 ;; file.
 		 ;; file.