auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] Auctex and Sweave -- can't compile .*Rnw files directly


From: Leo Alekseyev
Subject: Re: [AUCTeX] Auctex and Sweave -- can't compile .*Rnw files directly
Date: Sat, 9 May 2009 14:14:37 -0400

Andreas,

thank you for your help!

The line
(setq TeX-file-extensions
     '("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
is indeed what was necessary to get things working.  You might want to
add that to the snippet of code on the web.

On my system, the \\input{%s} line still doesn't work (I am guessing
it has something to do with the fact that I am on windows, and the
command getting passed to pdflatex is "input{file}", not
"\input{file}", even though the backslash is escaped...  If someone
has more insight on this, feel free to comment...)

*however* if you just use %s instead of \\input{%s} everything appears to work.

The %s expansion that you mentioned only strips extensions if it
recognizes them as valid TeX extensions, that's why that line is
necessary.  (Incidentally, to see what the %s expands to, evaluate the
following (via M-S-:) (TeX-master-file nil t).  You will see that for
non-tex files, the extension is there while for tex files the
extension is stripped).

--Leo

On Fri, May 8, 2009 at 2:42 AM, Andreas Kiermeier
<address@hidden> wrote:
> Hi Leo,
>
> I use these functions extensively with out problem (I guess that's why
> I've put them on the web). But I'm a neophyte with respect to Lisp
> programming, but a little bit of knowledge is a dangerous thing. :)
>
> Invoking Sweave on the file habraken.Rnw gives for me:
>
> Running `Sweave' on `habraken' with ``R CMD Sweave "habraken"''
>
> And when following up with LatexSweave I get the following (I have PDF
> mode by default).
>
> Running `LatexSweave' on `habraken' with ``pdflatex
> -interaction=nonstopmode \input{"habraken"}''
>
> The only other thing I can see in my .emacs file that may be related
> is the following:
>
> (setq TeX-file-extensions
>      '("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
>
> I recall that when I was trying to get this working, I was stuffing
> around with the TeX-expand-list, but I don't believe that I actually
> ended up having to change anything. But just in case, the entry for %s
> in TeX-expand-list is
>
>  ("%s" file nil t)
>
> If anyone has got a clue with respect to what's happening then I'd be
> vary grateful and I'll update any comments on the web.
>
> Cheers,
>
> Andreas Kiermeier
>
> On Thu, May 7, 2009 at 7:32 PM, Leo <address@hidden> wrote:
>>
>> Hi all,
>> Searching the web/this list I have found the following snippet from .emacs
>> that should enable direct compilation of Sweave files in Auctex:
>>
>> (add-hook 'Rnw-mode-hook
>> (lambda ()
>> (add-to-list 'TeX-command-list
>> '("Sweave" "R CMD Sweave %s"
>> TeX-run-command nil (latex-mode) :help "Run Sweave") t)
>> (add-to-list 'TeX-command-list
>> '("LatexSweave" "%l %(mode) \\input{%s}"
>> TeX-run-TeX nil (latex-mode) :help "Run Latex after Sweave") t)
>> (setq TeX-command-default "Sweave")))
>>
>> Indeed, Sweave command now works for me and produces the formatted tex files
>> and figures, however, LatexSweave fails like so:
>> ERROR: I can't find file `input{test.Rnw}'.
>>
>> texput.log contains:
>> This is pdfTeX, Version 3.141592-1.40.4 (MiKTeX 2.7) (preloaded format=latex
>> 2008.4.1)  7 MAY 2009 08:10
>> entering extended mode
>> **input{test.Rnw}
>>
>> ! Emergency stop.
>> <*> input{test.Rnw}
>>
>> *** (job aborted, file error in nonstop mode)
>>
>>
>> Now, I work with files test.Rnw and test.tex.  If I change the
>> line '("LatexSweave" "%l %(mode) \\input{%s}" to read
>> '("LatexSweave" "%l %(mode) test", the LatexSweave command produces the
>> desired output.
>>
>> Finally, I can copy the Sweave.sty file into the working directory, run 
>> Sweave
>> command, and compile the test.tex file just like I would any other tex file.
>>
>> From this it seems that the line '("LatexSweave" "%l %(mode) \\input{%s}"
>> needs to be modified in order to pass the correct arguments to lates/pdftex.
>> Unfortunately, I am rather new to elisp and Auctex, so I can't figre out how
>> to do so.  I would much appreciate any help to this end!
>>
>>
>>
>>
>> _______________________________________________
>> auctex mailing list
>> address@hidden
>> http://lists.gnu.org/mailman/listinfo/auctex
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]