tags:

views:

108

answers:

2

Dear SOers,

I am writing my thesis in LaTeX and because things got a bit long for my taste, I had split it into several files. Let's call them thesis.tex, intro.tex, mat_n_met.tex, rslts.tex and discsn.tex. I have linked intro.tex, mat_n_met.tex, rslts.tex and discsn.tex through thesis.tex with \include{intro} (and so on...). I have also created a separate file called r_crunching.Rnw (that I run through Sweave) that holds a chunk that runs the R script with data analysis and chunks that produce pdf outputs of graphs that I embed via \includegraphics (in e.g., rslts.tex). Still following?

If I run a Rnw (i.e. I renamed rslts.tex to rslts.Rnw) without "a link" to the chunk with the R script, you will get a Sweave() error saying the reference in \Sexpr{} doesn't exist. Is there a way, without merging all the files into a single .Rnw, to call \Sexpr{} in say rslts.Rnw?

Other methods how to accomplish this are welcome.

+2  A: 

Forget for a second that you are dealing with Sweave and just think of the latex problem -- for which \include and \includeonly offer solutions. Try that with a few simple test files.

Once you have that figured out, fold Sweave back into the mix and it just work as Sweave is after 'merely' a pre-processing step, albeit a very clever one.

Dirk Eddelbuettel
See also SweaveInput.
jverzani
A: 

one fairly obvious answer is to use a makefile, possibly using package cachesweave, to process the relevant files in the right order.

mjm