Re: [R] Understanding the workflow between sweave, R and Latex
On Fri, Sep 30, 2011 at 2:41 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: As an aside, I don't recommend the workflow you describe: it's very slow and cumbersome. It's much better to tell your text editor how to run both Sweave and Latex in one command. In the upcoming release of R 2.14.0, this Another approach is to use LyX. The latest stable release comes with an Sweave module that provides out-of-the box support for Sweave documents. Once everything is configured, and on a Mac it should be fairly straightforward in this case, then compiling documents is usually a matter of pressing a button or activating a key combination. LyX takes care of a lot of automation for you, including BibTeX et al. Regards Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Understanding the workflow between sweave, R and Latex
On 9/30/2011 9:08 AM, syrvn wrote: Hi Duncan, I use Eclipse and StatET plus TexClipse and Sweave which comes with the StatET package. So fore me it is basically one click as well to produce the pdf from the .Rnw file. I installed the MacTex live 2011 version on my computer and thought it might actually be easy to find out how and where latex searches for packages. But I did not find the place where all this is coded... First, since this is Mac-related, you would probably get better answers on the R-sig-mac list. Second, most latex distributions support both a system 'texmf' tree and one or more local/user texmf trees, that you can configure with something like Preferences somewhere in MacTex. On my linux system, I use ~/texmf/ and simply copied Sweave.sty to ~/texmf/tex/latex/misc/Sweave.sty (if my path-memory serves) No more worries (unless Sweave.sty is changed in a new R distro) Finally, it does help to RTFM, where you can find other options under ?RweaveLatex in the Details section. The LaTeX file generated needs to contain the line \usepackage{Sweave}, and if this is not present in the Sweave source file (possibly in a comment), it is inserted by the RweaveLatex driver. If stylepath = TRUE, a hard-coded path to the file ‘Sweave.sty’ in the R installation is set in place of Sweave. The hard-coded path makes the LaTeX file less portable, but avoids the problem of installing the current version of ‘Sweave.sty’ to some place in your TeX input path. However, TeX may not be able to process the hard-coded path if it contains spaces (as it often will under Windows) or TeX special characters. The default for stylepath is now taken from the environment variable SWEAVE_STYLEPATH_DEFAULT, or is FALSE it that is unset or empty. If set, it should be exactly TRUE or FALSE: any other values are taken as FALSE. As from R 2.12.0, the simplest way for frequent Sweave users to ensure that ‘Sweave.sty’ is in the TeX input path is to add ‘R_HOME/share/texmf’ as a ‘texmf tree’ (‘root directory’ in the parlance of the ‘MiKTeX settings’ utility). By default, ‘Sweave.sty’ sets the width of all included graphics to: \setkeys{Gin}{width=0.8\textwidth}. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Understanding the workflow between sweave, R and Latex
On 30/09/2011 8:03 AM, syrvn wrote: Let's say I have written the following tiny .Rnw file: _ \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{Sweave} \usepackage{tikz} \usepackage{pgf} \begin{document} = sessionInfo() @ \end{document} _ I then can go to R and use sweave to translate the .Rnw file into a .tex file Once this is done the latex interpreter can be called and because I used \usepackage{Sweave} Latex knows how to handle the sweave specific code tags. When I first did this procedure I got the commong error that the Sweave.sty file could not be found. I googled and could solve the problem by typing the following command into the Mac OS Terminal: _ mkdir -p ~/Library/texmf/tex/latex cd ~/Library/texmf/tex/latex ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave _ What I don't understand now is how does the latex package \usepackage{Sweave} know that it has to look at ~/Library/texmf/tex/latex to find the symbolic link to the Sweave.sty file? What happens if I change the following line: ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave to ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave_Link In the .Rnw file do I have to use then \usepackage{Sweave_Link}? No. You need to read up on LaTeX documentation, and particularly on the documentation for your particular implementation, to find out how it searches for packages, but in general it is looking for the file named Sweave.sty, and the directory containing it could be named anything. As an aside, I don't recommend the workflow you describe: it's very slow and cumbersome. It's much better to tell your text editor how to run both Sweave and Latex in one command. In the upcoming release of R 2.14.0, this is a single command: R CMD Sweave --pdf. In earlier releases, it's only slightly more complicated: you need to process the Rnw to tex, then the tex to pdf using pdflatex or similar. (You can do more elaborate conversions using my patchDVI package; it's on R-forge, here: https://r-forge.r-project.org/R/?group_id=233). Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Understanding the workflow between sweave, R and Latex
Hi Duncan, I use Eclipse and StatET plus TexClipse and Sweave which comes with the StatET package. So fore me it is basically one click as well to produce the pdf from the .Rnw file. I installed the MacTex live 2011 version on my computer and thought it might actually be easy to find out how and where latex searches for packages. But I did not find the place where all this is coded... Best -- View this message in context: http://r.789695.n4.nabble.com/Understanding-the-workflow-between-sweave-R-and-Latex-tp3859612p3859762.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.