gmail just sent me a message that this post was not sent through on
Wednesday because it could not contact lyx-users. So I'm trying again.
Sorry if it is a repost.

In Sweave, we process a noweb document first through R to generate the
tex file, and then the usual processing occurs.

Because not all LyX/LaTeX systems have the noweb setup, it is
necessary for me to develop my document with Sweave/Lyx, and then save
the generated files (in a folder "plots") and use them in the final
document without invoking Sweave.  I do this with LyX branches. I have
a branch for the Sweave commands that generates the files in "plots",
and then I have \includegraphics{} or \input{} as needed.

It mostly works fine, there is just a wrinkle that bothers me. So far,
I have just used brute force to copy the whole "plots" folder from the
working directory back to the document root with a command inside the
document itself.

<<copyover, fig=F, echo=T, include=T>>=
system("rsync -ra plots /home/pauljohn/ps/ps707/Workbook/Workbook-plot")
@

That is OK, except I have to "hardcode" the document directory.  And
no matter what I do, it seems like I have to process the document
through latex twice. The first time I run the process in LyX, it runs
the document through R Sweave and it makes the plots, but when the
pdflatex run happens,


LaTeX Error: Cannot determine size of grpahic in plots/plot-gss.pdf

After that, I check the plots folder in the document directory and the
files are copied over.  But they are not there "fast enough" to make
pdflatex happy? Really?

I was thinking there must be some work around in LyX config.  It the
LyX documents, I find info on converters and copiers and  $$p or  $$r.

The converter in .lyx/preferences, I have converters like so:

#
# CONVERTERS SECTION ##########################
#

\converter "literate" "latex" "R CMD Sweave $$i" ""
\converter "literate" "pdflatex" "R CMD Sweave $$i" ""
\converter "literate" "r" "R CMD Stangle $$i" ""
##

Put the copy on the end of the converter:

\converter "literate" "pdflatex" "R CMD Sweave $$i && cp -R plots $$r" ""

I believe it SHOULD work. The plot folder DOES get copied over.
However,  still not fast enough. I still see LaTeX errors:

LaTeX Error: Cannot determine size of graphic in plots/plot-gss.pdf

If I run everything through again, then the document goes get created.

But this is bad because the whole project has to be run through the R
Sweave process two times.

What do you think?

If you tell me how to fix this, I will feel happy.  In return, I will
show you the LyX file that uses Frank Harrell's Sweavel.sty (Sweave
using the listings class), which is nicer looking:

http://pj.freefaculty.org/latex/sweavel-01.pdf

-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

Reply via email to