Trying to write my second latex file
\documentclass{article} \title{simple Sweave script} \usepackage{/Users/Brenden/Documents/R/R-2.15.1/share/texmf/tex/latex/Sweave} \begin{document} \maketitle This is a simple script to demonstrate Sweave. Let's begin by generating some results <<>>= x=rnorm(30) y=rnorm(30) mean(x) cor(x,y) @ and follow that up with some random text \end{document}
File saved with .Rnw as an extension. Then I could use Sweave under R to convert the file to tex. Then I run pdflatex under cmd to get the .pdf file. R is stored in the / Users / Brenden / Documents section. MiKTex is stored in the / Users / Brenden / Desktop section.
They say that usually the line "usepackage" is not needed, because when I run Sweave under R, the line "usepackage {Sweave}" will be added to the tex file, which is stored in the / Users / Brenden / Documents section. However, if I do not put the userpackage line when I run pdflatex under cmd (either under / Documents or / Desktop), I get a message that says: "Sweave.sty not found". So I overcame this problem by always adding a usepackage line with a detailed path to help get around the problem. Although the "Sweave.sty not found" problem is bypassed, I notice that when I run pdflatex under cmd, I got an answer
LaTeX Warning: You have requested package '/Users/Brenden/Documents/R/R- 2.15.1/share/texmf/tex/latex/Sweave', but the package provides "Sweave'.
Then it runs through several .sty files under MiKTex
(C:\Users\Brenden\Desktop\MiKTex\tex\latex\base\ifthen.sty) (C:\Users\Brenden\Desktop\MiKTex\tex\latex\graphics\graphicx.sty) (C:\Users\Brenden\Desktop\MiKTex\tex\latex\graphics\keyval.sty) (C:\Users\Brenden\Desktop\MiKTex\tex\latex\graphics\graphics.sty) (C:\Users\Brenden\Desktop\MiKTex\tex\latex\graphics\trig.sty) ...
to end up creating .pdf
From another post in Stackoverflow it says: "This path is set automatically when LaTeX is installed, this is your personal texmf tree, and you can put any style or class files that you want LaTeX to find. It doesn't matter, it recursively searches them for Sweave.sty" . However, for me, obviously, my MiKTex could not find Sweave.sty unless I showed the way. And even with a path, LaTex still gives me a warning. Can someone explain to me where I screwed up (during the installation of MiKTex, maybe?), So that I can help MiKtex find its way to Sweave without specifying a path?
Thanks.