* Is LaTeX pdf export that uses pgfSweave possible?
@ 2011-09-15 23:07 Mikhail Titov
2011-09-19 4:12 ` Charles Berry
0 siblings, 1 reply; 2+ messages in thread
From: Mikhail Titov @ 2011-09-15 23:07 UTC (permalink / raw)
To: emacs-orgmode
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.
I have the following to use pgfSweave in R session:
-------8<--------------------------------------------------------------->8-------
(defun ess-swv-pgfweave ()
"Run pgfSweave on the current .Rnw file."
(interactive)
(ess-execute "library(pgfSweave)")
(ess-swv-run-in-R "pgfSweave"))
(define-key noweb-minor-mode-map "\M-ns" 'ess-swv-pgfweave)
(easy-menu-add-item noweb-minor-mode-menu '("Sweaving, Tangling, ...") ["pgfSweave" ess-swv-pgfweave t])
-------8<--------------------------------------------------------------->8-------
So I thought I'd somehow hook up altogether as I like an idea of folding things while make Beamer slides, but same time I like neatness of pgfSweave...
I don't know if there might be problems passing through constructs like
<<stuff>>=
stuff
@
untouched into <dot>Rnw file.
I'm aware of babel for R but I can't use LaTeX in plots with it :(
Mikhail
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Is LaTeX pdf export that uses pgfSweave possible?
2011-09-15 23:07 Is LaTeX pdf export that uses pgfSweave possible? Mikhail Titov
@ 2011-09-19 4:12 ` Charles Berry
0 siblings, 0 replies; 2+ messages in thread
From: Charles Berry @ 2011-09-19 4:12 UTC (permalink / raw)
To: emacs-orgmode
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]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-19 4:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 23:07 Is LaTeX pdf export that uses pgfSweave possible? Mikhail Titov
2011-09-19 4:12 ` Charles Berry
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).