From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: org-babel: Meta-LaTeX-Python-Environment Date: Tue, 27 Oct 2009 16:55:00 -0600 Message-ID: References: <200910261327.09576.torsten.wagner@googlemail.com> <878wexheeq.fsf@stats.ox.ac.uk> <4edb2bbc0910270757i3911f817jd99bc68eb4639e31@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2uwY-0001us-MF for emacs-orgmode@gnu.org; Tue, 27 Oct 2009 18:55:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2uwU-0001sI-7g for Emacs-orgmode@gnu.org; Tue, 27 Oct 2009 18:55:10 -0400 Received: from [199.232.76.173] (port=40939 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2uwU-0001sF-1Q for Emacs-orgmode@gnu.org; Tue, 27 Oct 2009 18:55:06 -0400 Received: from mail-pz0-f192.google.com ([209.85.222.192]:62314) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2uwT-0001bl-Hu for Emacs-orgmode@gnu.org; Tue, 27 Oct 2009 18:55:05 -0400 Received: by pzk30 with SMTP id 30so160320pzk.24 for ; Tue, 27 Oct 2009 15:55:04 -0700 (PDT) In-Reply-To: <4edb2bbc0910270757i3911f817jd99bc68eb4639e31@mail.gmail.com> (Torsten Wagner's message of "Tue, 27 Oct 2009 23:57:41 +0900") 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: Torsten Wagner Cc: Dan Davison , Emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Torsten Wagner writes: > Perhaps this will do what you want? =C2=A0When I run org-babel-tangle= on the following org file, and then > LaTeX the output, the resulting pdf file says:=C2=A0A bit of LATEX co= de, with the result: 6 > I just wonder if there is a more comfortable method rather then > creating a file. Although I still don't fully understand the need to embed latex *inside* of source-code blocks, perhaps the attached org-babel-latex.el file [1] will represent a simpler solution for embedding the results of source-code blocks in latex source-code blocks. It makes use of the :var org-babel header argument as shown in the attached example file [2]. To reproduce first load org-babel-latex.el and then evaluate the latex block (note the results are already in the file from my test evaluation). Hope this helps -- Eric Footnotes:=20 [1]=20=20 --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-babel-latex.el ;;; org-babel-latex.el --- org-babel functions for latex "evaluation" ;; Copyright (C) 2009 Eric Schulte ;; Author: Eric Schulte ;; Keywords: literate programming, reproducible research ;; Homepage: http://orgmode.org ;; Version: 0.01 ;;; License: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; Org-Babel support for evaluating LaTeX source code. ;; ;; Currently on evaluation this returns raw LaTeX code, however at ;; some point it *may* (it may not) make sense to have LaTeX blocks ;; compile small pdfs on evaluation. ;;; Code: (require 'org-babel) (org-babel-add-interpreter "latex") (add-to-list 'org-babel-tangle-langs '("latex" "tex")) (defvar org-babel-default-header-args:latex '((:results . "latex") (:exports . "results")) "Default arguments to use when evaluating a latex source block.") (defun org-babel-execute:latex (body params) "Execute a block of Latex code with org-babel. This function is called by `org-babel-execute-src-block'." (message "executing Latex source code block") (mapc (lambda (pair) ;; replace variables (setq body (replace-regexp-in-string (regexp-quote (format "%S" (car pair))) (if (stringp (cdr pair)) (cdr pair) (format "%S" (cdr pair))) body))) vars) body) (defun org-babel-prep-session:latex (session params) (error "Latex does not support sessions")) (provide 'org-babel-latex) ;;; org-babel-latex.el ends here --=-=-= [2] --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=latex.org #+TITLE: weird latex export #+OPTIONS: num:nil ^:nil #+LaTeX_CLASS: normal * Test org #+srcname: simple_six #+begin_src python :results silent 6 #+end_src #+begin_src latex :var python_result=simple_six \documentclass{article} \begin{document} A bit of \LaTeX code, with the result: python_result \end{document} #+end_src #+resname: #+BEGIN_LaTeX \documentclass{article} \begin{document} A bit of \LaTeX code, with the result: 6 \end{document} #+END_LaTeX --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--