[R] Sweave and \input or \include LaTeX commands

Friedrich.Leisch@tuwien.ac.at Friedrich.Leisch at tuwien.ac.at
Tue Mar 1 09:09:39 CET 2005


>>>>> On Tue, 01 Mar 2005 07:53:47 +0100,
>>>>> Gregor GORJANC (GG) wrote:

  > Hi!
  > What is wrong if there would be the same command?

2  reasons:

1) I try to keep the Sweave and LaTeX namespaces disjunct, i.e., I
   currently do not overload regular LaTeX commands with a different
   meaning, and I want to keep it that way.

2) If it is "the same" command, then I you can already take bets on
   the date of the first "bug report" claiming that Sweave's \input{}
   command behaves differently that LaTeX's, e.g., by not searching
   .Rnw files along the TEXINPUTS path, etc.

I currently also plan only a \SweaveInput{}, but no \SweaveInclude{}
(the former is much easier to implement, because I don't have to
switch output files in the middle of operation).


  > Recall my example from 
  > previous posts and at the end of this mail. If I have a file a.Rnw and this
  > one inputs file a1.Rnw. My idea was that Sweave would check \input{a1} or 
  > \include{a1} statements. If file a1 would have extension .Rnw it would
  > parse it otherwise (i.e. having .tex) it would skip it. Sweave would just 
  > parse .Rnw files, while latex would put all of them in one file during 
  > typesetting.

  > Example:
  > - we have files
  >    a.Rnw, which has \input{a1} or \include{a1}
  >    a1.Rnw

Note that theese are *not* the same under LaTeX

  > - run Sweave(a.Rnw) and you get
  >    a.tex
  >    a1.tex

Nope, for \input{a1} you would get only a.tex. From the LaTeX
documentation:

**********************************************************
   `\input{file}'

   The `\input' command causes the indicated `file' to be read and
processed, exactly as if its contents had been inserted in the current
file at that point.  The file name may be a complete file name with
extension or just a first name, in which case the file `file.tex' is
used.
**********************************************************


That is easy to implement, because I read the .Rnw file, replace
(recursively) all \SweaveInput{} statements with their contents until
no more \SweaveInput{} statements are found (here the unique name
comes in handy ;-) and then process as usual.

If you want a fancier system with include statements I am happily
waiting for your code implementing it.

Best,
Fritz

-- 
-------------------------------------------------------------------
                        Friedrich Leisch 
Institut für Statistik                     Tel: (+43 1) 58801 10715
Technische Universität Wien                Fax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071
A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch




More information about the R-help mailing list