I'm trying to automate some of the processing of org-mode files through knitr and finally to a pdf. To do this I am using ox-ravel.el from https://github.com/chasberry/orgmode-accessories . Basically I want another entry in the org-mode export that allows me to C-c C-e l q that runs org-ravel-latex-noweb-pdf-dispatch:
(org-export-define-derived-backend 'latex-noweb 'latex
:translate-alist '((src-block . org-ravel-src-block)
(inline-src-block . org-ravel-inline-src-block))
:menu-entry
'(?l 1
((?q "As KnitR PDF" org-ravel-latex-noweb-pdf-dispatch))))
This seems to remove the current entry for a similar derived backend in ox-ravel:
(org-export-define-derived-backend 'latex-noweb 'latex
:translate-alist '((src-block . org-ravel-src-block)
(inline-src-block . org-ravel-inline-src-block))
:menu-entry
'(?l 1
((?r "As Rnw File" org-ravel-latex-noweb-dispatch))))
Any tips to make both entries appear are appreciated. Now for the trickier part. I want org-ravel-latex-noweb-pdf-dispatch to first export to an Rnw file as is done by:
(defun org-ravel-latex-noweb-dispatch
(&optional async subtreep visible-only body-only ext-plist)
"Execute menu selection. See org-export.el for meaning of ASYNC,
SUBTREEP, VISIBLE-ONLY and BODY-ONLY."
(interactive)
(if async
(message "No async allowed.")
(let
((outfile (org-export-output-file-name ".Rnw" subtreep)))
(org-export-to-file 'latex-noweb
outfile async subtreep visible-only
body-only ext-plist))))
After the .Rnw file is export I need to run ess-swv-weave to export a .tex file. Then I want to run org-latex-compile to obtain a final pdf. Below is a portion of org-latex-export-to-pdf which may be relevant:
(defun org-latex-export-to-pdf
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to LaTeX then process through to PDF."
(interactive)
(let ((outfile (org-export-output-file-name ".tex" subtreep)))
(org-export-to-file 'latex outfile
async subtreep visible-only body-only ext-plist
(lambda (file) (org-latex-compile file)))))
Any help in combining the above ideas to make C-c C-e l q produce the desired pdf would be greatly appreciated!