From: Charles Berry <ccberry@ucsd.edu>
To: emacs-orgmode@gnu.org
Subject: Re: Is LaTeX pdf export that uses pgfSweave possible?
Date: Mon, 19 Sep 2011 04:12:55 +0000 (UTC) [thread overview]
Message-ID: <loom.20110919T060141-659@post.gmane.org> (raw)
In-Reply-To: 009d01cc73fc$3bd10a50$b3731ef0$@us
Mikhail Titov <mlt <at> 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 <dot>Rnw file instead of <dot>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]
prev parent reply other threads:[~2011-09-19 4:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-15 23:07 Is LaTeX pdf export that uses pgfSweave possible? Mikhail Titov
2011-09-19 4:12 ` Charles Berry [this message]
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=loom.20110919T060141-659@post.gmane.org \
--to=ccberry@ucsd.edu \
--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).