I'm following Gregor Gorjanc's tutorial on LyX & Sweave. Using Ubuntu 10.04 and LyX
version 1.6.5 with all of texlive-full
installed.
R
scraps which result in numerical output produce a valid PDF.
But, when I try to compile simple figures like
<<chunk, fig=T>>= [ctrl+enter]
hist(rnorm(100)) [ctrl+enter]
@
I get cryptic errors. Either that chunk.temp.Rnw
wasn't found, or that LaTeX
encountered an error and I should hit <enter>
to ignore.
If I change fig
to figure
and T
to TRUE
, then the LyX
document compiles but displays no graphics. With pgfsweave
I get this error, or sometimes this one.
Am I working with the wrong versions of these programs? Is there a way to elicit better error messages? Can I somehow dive into the LaTeX prompt and hit <enter>
myself?
update: I was using the wrong version of LaTeX
; Ubuntu's default is too old. Also I needed to update to LyX 2.0.1
and a newer version of pgf
and pgfSweave
(the programs are distinct).
The new (nondescript) error message is: An error occurred while running: Rscript '/home/mars/.lyx/scripts/lyx-sweave-exec.R' 'UTF-8' 'pgfSweave' "/home/mars/" "/tmp/lyx_tmpdir.T1663/lyx_tmpbuf2/" "test.sweave.lyx.Rnw" > "test.sweave.Rnw".log 2>&1
According to https://tex.stackexchange.com/questions/27993/can-i-download-ctan-packages-from-the-command-line-ubuntu/27994#27994 there is a perennial problem with TeX
in Ubuntu: their packages are way behind. Since many innovations with Sweave
have happened in 2010-2011, it seems one must download and install an .iso
from http://ftp.ctex.org/mirrors/CTAN/systems/texlive/Images/ rather than use Synaptic
. So much for package management!
I'll accept my own answer only if this actually works.
update: Make sure you disregard anything you read about Noweb.sty because in LyX 2.0.1
there is a "Sweave Module" meaning you should just use regular document classes (article
, book
, report
) -- the scraps
are replaced by chunks
and essentially Sweave
is handled natively. Also disregard Brett Collier's lucid explanation of how to install LyX
because it's now outdated, despite Gregor Gorjanc's highly-googleable blog post saying it works. That is also outdated, or maybe it only works in Ubuntu 9 and not Ubuntu 10.04.
So the steps to successfully getting Sweave
to work in LyX
for Ubuntu 10.04 as of August 2011 are:
texlive
from tug.org -- not the one from Synaptic. How to do that: https://tex.stackexchange.com/questions/27993/can-i-download-ctan-packages-from-the-command-line-ubuntu/27994pgf
and kTikz
as described here: http://justbloodywork.blogspot.com/2011/07/installing-latex-and-pgf.htmllyx-devel
from source, apply Yihue's patch, and configure some LyX preferences.Tools > Reconfigure
LyX
.LyX
and load Yihue's test file from (3). Hit Ctrl + R
, not Ctrl + D
to view.