From: Andreas Leha <andreas.leha@med.uni-goettingen.de>
To: emacs-orgmode@gnu.org
Subject: [patch] ob-latex: htlatex and imagemagick
Date: Sat, 21 Mar 2015 22:22:17 +0000 [thread overview]
Message-ID: <olupp82yorq.fsf@med.uni-goettingen.de> (raw)
[-- 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
next reply other threads:[~2015-03-21 22:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-21 22:22 Andreas Leha [this message]
2015-03-23 23:43 ` [patch] ob-latex: htlatex and imagemagick Nicolas Goaziou
2015-03-23 23:54 ` Andreas Leha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=olupp82yorq.fsf@med.uni-goettingen.de \
--to=andreas.leha@med.uni-goettingen.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).