From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: Is LaTeX pdf export that uses pgfSweave possible? Date: Mon, 19 Sep 2011 04:12:55 +0000 (UTC) Message-ID: References: <009d01cc73fc$3bd10a50$b3731ef0$@us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:48107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5VG6-0006Qp-DY for emacs-orgmode@gnu.org; Mon, 19 Sep 2011 00:15:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R5VG5-0005Pi-2w for emacs-orgmode@gnu.org; Mon, 19 Sep 2011 00:15:06 -0400 Received: from lo.gmane.org ([80.91.229.12]:49750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5VG4-0005PH-Oz for emacs-orgmode@gnu.org; Mon, 19 Sep 2011 00:15:05 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R5VG3-0001Ap-D4 for emacs-orgmode@gnu.org; Mon, 19 Sep 2011 06:15:03 +0200 Received: from adsl-67-124-200-70.dsl.sndg02.pacbell.net ([67.124.200.70]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Sep 2011 06:15:03 +0200 Received: from ccberry by adsl-67-124-200-70.dsl.sndg02.pacbell.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Sep 2011 06:15:03 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Mikhail Titov gmx.us> writes: > > Hello! > > First of all I’m not good at lisp as of now. I’d like to have an extra > export option when I press C-c C-e that > would create Rnw file instead of tex, pass it through pgfSweave > in running R session. Mikhail, For vanilla Sweave, use the LaTeX style syntax (vs noweb style) to create an Rtex file. Typing 'C-c C-e l' causes the following *.org to produce *.Rtex which R CMD Sweave will turn to *.tex and R CMD pdflatex will turn into a *.pdf. Note this this will break ordinary R code export in latex, so be sure it is not invoked when you want to go from *.org to *.pdf via 'C-c C-e d' The trick is mainly to get the latex exporter to drop the verbatim wrapper. -------8<--------------------------------------------------------------->8---- * Retooling org-babel to accept Rtex Run this subtree once to start or put these blocks in your =~/.emacs= Either way, run the elisp in this subtree once to start a session ** Nullify =\begin{verbatim}= ... =\end{verbatim}= Under standard latex export, the code blocks get wrapped in verbatim environments. To Sweave the resulting code as =*.Rtex= it is necessary to unplug this behavior. 'Advising' =org-export-format-source-code-or-example= like this has the desired effect on =R= src blocks , but leaves others alone. #+begin_src emacs-lisp :exports code (defadvice org-export-format-source-code-or-example (around no-verbatim (lang code &optional opts indent caption)) "dont wrap R code in verbatim" ( let (( old-verb-wrap org-export-latex-verbatim-wrap)) (if (equal lang "R") (setq org-export-latex-verbatim-wrap nil)) ad-do-it (setq org-export-latex-verbatim-wrap old-verb-wrap))) (ad-activate 'org-export-format-source-code-or-example) #+end_src #+results: : org-export-format-source-code-or-example ** after processing convert =*.tex= to =*.Rtex= Adding the commands to run Sweave and pdflatex to this hook function is left as an exercise... #+begin_src emacs-lisp :results silent (add-hook 'org-export-latex-after-save-hook (lambda () (rename-file (buffer-file-name) (concat (file-name-sans-extension (buffer-file-name)) ".Rtex") t ) )) #+end_src * SRC BLOCKS Two simple examples ** R graphics A simple scatterplot. Here we want the verbatim omitted: \begin{Scode}{fig=T} #+begin_src R :eval never :exports code :results raw plot(rnorm(10)) #+end_src \end{Scode} ** shell script Here we want to execute the shell script and pass it to the =*.Rtex= file #+begin_src sh :eval t :results output verbatim :exports both ls | wc #+end_src -------8<--------------------------------------------------------------->8--- HTH, Chuck [rest deleted]