From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthieu Lemerre Subject: Adding latex packages Date: Tue, 03 Apr 2007 18:00:25 +0200 Message-ID: <7fvegdv46e.fsf@orfaie.intra.cea.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HYlSS-000825-3i for emacs-orgmode@gnu.org; Tue, 03 Apr 2007 12:02:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HYlSP-0007xF-01 for emacs-orgmode@gnu.org; Tue, 03 Apr 2007 12:02:07 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HYlSN-0007wj-RW for emacs-orgmode@gnu.org; Tue, 03 Apr 2007 12:02:04 -0400 Received: from sainfoin.extra.cea.fr ([132.166.172.103]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HYlPD-0000af-9E for emacs-orgmode@gnu.org; Tue, 03 Apr 2007 11:58:47 -0400 Received: from nephilia.intra.cea.fr (nephilia.intra.cea.fr [132.166.88.33]) by sainfoin.extra.cea.fr (8.13.7/8.13.4/CEAnet-Internet.7.0) with ESMTP id l33FweKu016005 for ; Tue, 3 Apr 2007 17:58:40 +0200 (MEST) Received: from nenuphar.saclay.cea.fr (nenuphar.saclay.cea.fr [132.166.192.7]) by nephilia.intra.cea.fr (8.13.8/8.13.8) with ESMTP id l33Fwdwl007859 for ; Tue, 3 Apr 2007 17:58:39 +0200 (envelope-from matthieu.lemerre@cea.fr) Received: from orfaie.intra.cea.fr (is002221.intra.cea.fr [132.166.135.72]) by nenuphar.saclay.cea.fr (8.13.8/8.13.4/CEAnet-internes.7.0) with ESMTP id l33FwdaY017364 for ; Tue, 3 Apr 2007 17:58:39 +0200 (MEST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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