From: Matthieu Lemerre <matthieu.lemerre@rez-gif.supelec.fr>
To: emacs-orgmode@gnu.org
Subject: Adding latex packages
Date: Tue, 03 Apr 2007 18:00:25 +0200 [thread overview]
Message-ID: <7fvegdv46e.fsf@orfaie.intra.cea.fr> (raw)
Hello,
I wondered if it was possible to include custom Latex packages when
processing embedded LaTeX fragments in org. This would require only a
simple change in org-create-formula-image:
(defun org-create-formula-image (string tofile options)
(let* ((tmpdir (if (featurep 'xemacs)
(temp-directory)
temporary-file-directory))
(texfilebase (make-temp-name
(expand-file-name "orgtex" tmpdir)))
;(texfilebase (make-temp-file "orgtex"))
; (dummy (delete-file texfilebase))
(texfile (concat texfilebase ".tex"))
(dvifile (concat texfilebase ".dvi"))
(pngfile (concat texfilebase ".png"))
(scale (number-to-string (* 1000 (or (plist-get options :scale) 1.0))))
(fg (or (plist-get options :foreground) "Black"))
(bg (or (plist-get options :background) "Transparent")))
(with-temp-file texfile
(insert "\\documentclass{article}
\\usepackage{fullpage}
\\usepackage{amssymb}
\\usepackage[usenames]{color}
\\usepackage{amsmath}
\\usepackage{latexsym}
\\usepackage[mathscr]{eucal}
XXX insert custom packages here
\\pagestyle{empty}
\\begin{document}\n" string "\n\\end{document}\n"))
(let ((dir default-directory))
(condition-case nil
(progn
(cd tmpdir)
(call-process "latex" nil nil nil texfile))
(error nil))
(cd dir))
(if (not (file-exists-p dvifile))
(progn (message "Failed to create dvi file from %s" texfile) nil)
(call-process "dvipng" nil nil nil
"-E" "-fg" fg "-bg" bg
"-x" scale "-y" scale "-T" "tight"
"-o" pngfile
dvifile)
(if (not (file-exists-p pngfile))
(progn (message "Failed to create png file from %s" texfile) nil)
;; Use the requested file name and clean up
(copy-file pngfile tofile 'replace)
(loop for e in '(".dvi" ".tex" ".aux" ".log" ".png") do
(delete-file (concat texfilebase e)))
pngfile))))
This should be global or per-file options. The point is that there are
plenty of good LaTeX environments that it would be useful to have in
org (for instance algorithm or tikz).
One of these environments is tikzpicture, and using tikzpicture in org
would allow to create high-quality graphics in org documents. There is
one remaining difficulty though; tikz pictures aren't extracted with
dvipng.
What do you think?
Thanks,
Matthieu Lemerre
next reply other threads:[~2007-04-03 16:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-03 16:00 Matthieu Lemerre [this message]
2007-04-13 8:41 ` Adding latex packages Carsten Dominik
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7fvegdv46e.fsf@orfaie.intra.cea.fr \
--to=matthieu.lemerre@rez-gif.supelec.fr \
--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 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.