* [patch] ob-latex: htlatex and imagemagick
@ 2015-03-21 22:22 Andreas Leha
2015-03-23 23:43 ` Nicolas Goaziou
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Leha @ 2015-03-21 22:22 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 299 bytes --]
Hi all,
please find attached a small patch that fixes a problem discussed
in [1].
In short, when executing a latex src block and htlatex is a valid
option, it should be used even if imagemagick is part of the headers.
Regards,
Andreas
[1] http://permalink.gmane.org/gmane.emacs.orgmode/96257
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 4392 bytes --]
From 2986826441c24e2f0d6cf5efe6bf8aca75c4bdbb Mon Sep 17 00:00:00 2001
From: Andreas Leha <andreas.leha@gmx.de>
Date: Sat, 21 Mar 2015 22:11:37 +0000
Subject: [PATCH] ob-latex: htlatex preferred over imagemagick
* ob-latex.el (org-babel-execute:latex): change the order of the handlers
When `imagemagick' is given this entry acts as an else option.
So, it should always come last.
---
lisp/ob-latex.el | 80 ++++++++++++++++++++++++++++----------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index ba83bf9..2727a2a 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -99,46 +99,6 @@ This function is called by `org-babel-execute-src-block'."
(when (file-exists-p out-file) (delete-file out-file))
(with-temp-file out-file
(insert body)))
- ((or (string-match "\\.pdf$" out-file) imagemagick)
- (with-temp-file tex-file
- (require 'ox-latex)
- (insert
- (org-latex-guess-inputenc
- (org-splice-latex-header
- org-format-latex-header
- (delq
- nil
- (mapcar
- (lambda (el)
- (unless (and (listp el) (string= "hyperref" (cadr el)))
- el))
- org-latex-default-packages-alist))
- org-latex-packages-alist
- nil))
- (if fit "\n\\usepackage[active, tightpage]{preview}\n" "")
- (if border (format "\\setlength{\\PreviewBorder}{%s}" border) "")
- (if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
- (if width (concat "\n" (format "\\pdfpagewidth %s" width)) "")
- (if headers
- (concat "\n"
- (if (listp headers)
- (mapconcat #'identity headers "\n")
- headers) "\n")
- "")
- (if fit
- (concat "\n\\begin{document}\n\\begin{preview}\n" body
- "\n\\end{preview}\n\\end{document}\n")
- (concat "\n\\begin{document}\n" body "\n\\end{document}\n"))))
- (when (file-exists-p out-file) (delete-file out-file))
- (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
- (cond
- ((string-match "\\.pdf$" out-file)
- (rename-file transient-pdf-file out-file))
- (imagemagick
- (org-babel-latex-convert-pdf
- transient-pdf-file out-file im-in-options im-out-options)
- (when (file-exists-p transient-pdf-file)
- (delete-file transient-pdf-file))))))
((and (or (string-match "\\.svg$" out-file)
(string-match "\\.html$" out-file))
(executable-find org-babel-latex-htlatex))
@@ -184,6 +144,46 @@ This function is called by `org-babel-execute-src-block'."
".html")
out-file)
(error "HTML file produced but SVG file requested")))))
+ ((or (string-match "\\.pdf$" out-file) imagemagick)
+ (with-temp-file tex-file
+ (require 'ox-latex)
+ (insert
+ (org-latex-guess-inputenc
+ (org-splice-latex-header
+ org-format-latex-header
+ (delq
+ nil
+ (mapcar
+ (lambda (el)
+ (unless (and (listp el) (string= "hyperref" (cadr el)))
+ el))
+ org-latex-default-packages-alist))
+ org-latex-packages-alist
+ nil))
+ (if fit "\n\\usepackage[active, tightpage]{preview}\n" "")
+ (if border (format "\\setlength{\\PreviewBorder}{%s}" border) "")
+ (if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
+ (if width (concat "\n" (format "\\pdfpagewidth %s" width)) "")
+ (if headers
+ (concat "\n"
+ (if (listp headers)
+ (mapconcat #'identity headers "\n")
+ headers) "\n")
+ "")
+ (if fit
+ (concat "\n\\begin{document}\n\\begin{preview}\n" body
+ "\n\\end{preview}\n\\end{document}\n")
+ (concat "\n\\begin{document}\n" body "\n\\end{document}\n"))))
+ (when (file-exists-p out-file) (delete-file out-file))
+ (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
+ (cond
+ ((string-match "\\.pdf$" out-file)
+ (rename-file transient-pdf-file out-file))
+ (imagemagick
+ (org-babel-latex-convert-pdf
+ transient-pdf-file out-file im-in-options im-out-options)
+ (when (file-exists-p transient-pdf-file)
+ (delete-file transient-pdf-file))))))
((string-match "\\.\\([^\\.]+\\)$" out-file)
(error "Can not create %s files, please specify a .png or .pdf file or try the :imagemagick header argument"
(match-string 1 out-file))))
--
2.1.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] ob-latex: htlatex and imagemagick
2015-03-21 22:22 [patch] ob-latex: htlatex and imagemagick Andreas Leha
@ 2015-03-23 23:43 ` Nicolas Goaziou
2015-03-23 23:54 ` Andreas Leha
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2015-03-23 23:43 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Hello,
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> please find attached a small patch that fixes a problem discussed
> in [1].
>
> In short, when executing a latex src block and htlatex is a valid
> option, it should be used even if imagemagick is part of the headers.
Applied. Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] ob-latex: htlatex and imagemagick
2015-03-23 23:43 ` Nicolas Goaziou
@ 2015-03-23 23:54 ` Andreas Leha
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Leha @ 2015-03-23 23:54 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Hello,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> please find attached a small patch that fixes a problem discussed
>> in [1].
>>
>> In short, when executing a latex src block and htlatex is a valid
>> option, it should be used even if imagemagick is part of the headers.
>
> Applied. Thank you.
>
Thanks,
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-23 23:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-21 22:22 [patch] ob-latex: htlatex and imagemagick Andreas Leha
2015-03-23 23:43 ` Nicolas Goaziou
2015-03-23 23:54 ` Andreas Leha
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.