Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
Thanks,
Mic
Sweave, Texshop, and sync with included Rnw file
13 messages · Duncan Mackay, michele caseposta, huang min +2 more
I believe RStudio has done a fairly good job in terms of the synchronization. If you have to stick to TeXShop, I do not have any ideas on how to make it work with Sweave child documents. Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA
On Wed, Jan 9, 2013 at 2:25 PM, michele caseposta <mic.cipi at gmail.com> wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
Thanks,
Mic
Hi Yihui, yes, RStudio works flawlessly with synchronization, but working with it I will lose all the features of a full-fledged tex editor, first of all BibDesk integration. Texworks can also do two-way sync in Rnw, and I tried to switch configurations but with no luck. In texworks I am using RScript with the options recommended in this document: http://www.math.montana.edu/~jimrc/classes/Rseminar/TexWorks.pdf The problem with texworks is the same: no integration with bibdesk
On Jan 9, 2013, at 4:06 PM, Yihui Xie wrote:
I believe RStudio has done a fairly good job in terms of the synchronization. If you have to stick to TeXShop, I do not have any ideas on how to make it work with Sweave child documents. Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Wed, Jan 9, 2013 at 2:25 PM, michele caseposta <mic.cipi at gmail.com> wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
Thanks,
Mic
Hi
Perhaps you need to make a master file and call the chapter files from it
eg (just copying the relevant section from my master GClimate12.Rnw file)
latex preliminaries + R options + begin
% plots
\SweaveInput{GClimate12RX.Rnw}
% Soil 300 % 15
\SweaveInput{GClimate12SP.Rnw}
% proportions % 16
\SweaveInput{GClimate12RS.Rnw}
% cumsum days % 17
\SweaveInput{GClimate12RC.Rnw}
closing commands etc
end document
This means that you require 1 setup page rather than individual ones
and the benefits attached for TOC etc
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
At 06:25 10/01/2013, you wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the
pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every
chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing
synchronization between the pdf and the source Rnw. If part of text
is in book.Rnw I can synchronize, but if the text is in one of the
included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
Thanks,
Mic
______________________________________________ R-help at 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.
On 13-01-09 3:25 PM, michele caseposta wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
This is a problem addressed by my patchDVI package, available on R-forge. You have a main file (which can be .tex or .Rnw), and put code at the start of each .Rnw file to indicate where to find it. Then you just run Sweave on one of the chapters, and it automatically produces the full document. The sample document here: http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/ includes an appendix describing how to set this up with TeXShop. Duncan Murdoch
On 13-01-09 9:09 PM, Duncan Murdoch wrote:
On 13-01-09 3:25 PM, michele caseposta wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
This is a problem addressed by my patchDVI package, available on R-forge. You have a main file (which can be .tex or .Rnw), and put code at the start of each .Rnw file to indicate where to find it. Then you just run Sweave on one of the chapters, and it automatically produces the full document. The sample document here: http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/ includes an appendix describing how to set this up with TeXShop.
I just committed an update to the vignette in patchDVI giving a quick version of the instructions for basic use. Version 1.8.1585 has the new vignette. I should get around to pushing it to CRAN one of these days... Duncan Murdoch
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130110/64f6144a/attachment-0001.pl>
On 13-01-10 4:54 PM, michele caseposta wrote:
Hi everybody, thanks for the replies. I might have not explained the problem completely. Duncan Mackay: Yes, I am already having a master file and separate Rnw files. Duncan Murdock: I am using patchDVI in the TexShop Sweave engine. Sync works flawlessly between the master file and the pdf produced by pdflatex. My problem is that I don't seem to be able to obtain sync between the *included* Rnws and the pdf, either way.
I think you said before that you were using \SweaveInput to include the
files. I thought this had been handled, but perhaps not, or perhaps
there's a bug. What I'd recommend is that you don't use \SweaveInput.
Set up your main file main.Rnw like this:
... usual header stuff ...
<<echo=FALSE>>=
.SweaveFiles <- c("chap1.Rnw", "chap2.Rnw")
@
\input{chap1}
\input{chap2}
Set up the chapters like this. They aren't standalone files, so they
don't need the usual LaTeX header lines, but they'll need some Sweave stuff:
% Put a commented usepackage so Sweave doesn't insert one
%\usepackage{Sweave}
% Make sure to set a unique prefix in each chapter
% so that figures and concordances don't clash
\SweaveOpts{concordance=TRUE,prefix=chap1}
% Tell SweaveAll about the other files
<<echo=FALSE>>=
.SweaveFiles <- "main.Rnw"
.TexRoot <- "main.tex"
@
Then patchDVI::SweaveAll (or SweavePDF, etc.) on any chapter or on the
main.Rnw file will run Sweave on all the chapters (in a slightly
unpredictable order, so don't count on it). You should get the
concordances working for each file.
I'll take a look at what is happening with SweaveInput, but not tonight.
(Besides working, the setup described above has the advantage of
making things go faster: you won't need to run Sweave on unmodified
chapters. Only modified ones get run each time. You can also use
\include in place of \input, and then LaTeX will run faster with
\includeonly to select particular chapters.
Duncan Murdoch
The sweave engine is as follows:
#!/bin/bash
R CMD Sweave "$1"
latexmk -pdf -silent -pdflatex=?pdflatex ?shell-escape ?synctex=1?"${1%.*}"
Rscript -e "library(?patchDVI?);patchSynctex(?${1%.*}.synctex.gz?)"
Funny thing is that the sync works in texworks, using the following Rscript line
patchDVI::SweavePDF('$fullname',stylepath=FALSE)
I tried to mix and match configurations between texshop and texworks but I had no luck
On Jan 10, 2013, at 11:23 AM, Duncan Murdoch wrote:
On 13-01-09 9:09 PM, Duncan Murdoch wrote:
On 13-01-09 3:25 PM, michele caseposta wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
This is a problem addressed by my patchDVI package, available on R-forge. You have a main file (which can be .tex or .Rnw), and put code at the start of each .Rnw file to indicate where to find it. Then you just run Sweave on one of the chapters, and it automatically produces the full document. The sample document here: http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/ includes an appendix describing how to set this up with TeXShop.
I just committed an update to the vignette in patchDVI giving a quick version of the instructions for basic use. Version 1.8.1585 has the new vignette. I should get around to pushing it to CRAN one of these days... Duncan Murdoch
On 13-01-10 4:54 PM, michele caseposta wrote:
Hi everybody,
thanks for the replies.
I might have not explained the problem completely.
Duncan Mackay:
Yes, I am already having a master file and separate Rnw files.
Duncan Murdock:
I am using patchDVI in the TexShop Sweave engine.
Sync works flawlessly between the master file and the pdf produced by pdflatex.
My problem is that I don't seem to be able to obtain sync between the *included* Rnws and the pdf, either way.
The sweave engine is as follows:
#!/bin/bash
R CMD Sweave "$1"
latexmk -pdf -silent -pdflatex=?pdflatex ?shell-escape ?synctex=1?"${1%.*}"
Rscript -e "library(?patchDVI?);patchSynctex(?${1%.*}.synctex.gz?)"
Funny thing is that the sync works in texworks, using the following Rscript line
patchDVI::SweavePDF('$fullname',stylepath=FALSE)
I tried to mix and match configurations between texshop and texworks but I had no luck
I just tried a simple example in TeXShop and it worked for me. My Sweave engine is #!/bin/tcsh # set path= ($path /usr/local/bin) Rscript -e "patchDVI::SweavePDF( '$1' )" So it seems to be work listing versions: On the Mac, I'm using R 2.15.0 patched, rev 59478, with patchDVI version 1.8.1584 (I just uploaded 1.9 to CRAN, by the way), TeXShop version 2.43. It also works on Windows, where I have current releases of R and patchDVI installed. If you've got current versions of everything installed and it's still not working, could you try putting together a small reproducible example? Duncan Murdoch
On Jan 10, 2013, at 11:23 AM, Duncan Murdoch wrote:
On 13-01-09 9:09 PM, Duncan Murdoch wrote:
On 13-01-09 3:25 PM, michele caseposta wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
This is a problem addressed by my patchDVI package, available on R-forge. You have a main file (which can be .tex or .Rnw), and put code at the start of each .Rnw file to indicate where to find it. Then you just run Sweave on one of the chapters, and it automatically produces the full document. The sample document here: http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/ includes an appendix describing how to set this up with TeXShop.
I just committed an update to the vignette in patchDVI giving a quick version of the instructions for basic use. Version 1.8.1585 has the new vignette. I should get around to pushing it to CRAN one of these days... Duncan Murdoch
6 days later
Hi,
I just updated R and patchDVI (from CRAN).
Now I can reverse search from the pdf to the included.Rnw.
However, I cannot forward search from the included to the pdf. Is this how it is expected to work?
Forward and inverse search work between main Rnw and pdf.
I am pasting below the code in the two files.
%%%%%%%%% Sweavetest.Rnw %%%%%%%%%%%%
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
\title{an Sweave inclusion test}
\author{Michele}
\maketitle
This is an example for the inclusion of RNW files and forward-inverse search.
following is a chunk of sweave code:
<<>>=
n <- 5
for(i in 1:n){
print(i)
}
@
\section{text from an included file}
\SweaveInput{included.Rnw}
\end{document}
%%%%%%%%% Included.Rnw %%%%%%%%%%%%
% !Rnw root = Sweavetest.Rnw
this is some text included in an Rnw file
<<>>=
for(i in 1:3){
print('included')
}
@
On Jan 11, 2013, at 5:38 AM, Duncan Murdoch wrote:
On 13-01-10 4:54 PM, michele caseposta wrote:
Hi everybody,
thanks for the replies.
I might have not explained the problem completely.
Duncan Mackay:
Yes, I am already having a master file and separate Rnw files.
Duncan Murdock:
I am using patchDVI in the TexShop Sweave engine.
Sync works flawlessly between the master file and the pdf produced by pdflatex.
My problem is that I don't seem to be able to obtain sync between the *included* Rnws and the pdf, either way.
The sweave engine is as follows:
#!/bin/bash
R CMD Sweave "$1"
latexmk -pdf -silent -pdflatex=?pdflatex ?shell-escape ?synctex=1?"${1%.*}"
Rscript -e "library(?patchDVI?);patchSynctex(?${1%.*}.synctex.gz?)"
Funny thing is that the sync works in texworks, using the following Rscript line
patchDVI::SweavePDF('$fullname',stylepath=FALSE)
I tried to mix and match configurations between texshop and texworks but I had no luck
I just tried a simple example in TeXShop and it worked for me. My Sweave engine is #!/bin/tcsh # set path= ($path /usr/local/bin) Rscript -e "patchDVI::SweavePDF( '$1' )" So it seems to be work listing versions: On the Mac, I'm using R 2.15.0 patched, rev 59478, with patchDVI version 1.8.1584 (I just uploaded 1.9 to CRAN, by the way), TeXShop version 2.43. It also works on Windows, where I have current releases of R and patchDVI installed. If you've got current versions of everything installed and it's still not working, could you try putting together a small reproducible example? Duncan Murdoch
On Jan 10, 2013, at 11:23 AM, Duncan Murdoch wrote:
On 13-01-09 9:09 PM, Duncan Murdoch wrote:
On 13-01-09 3:25 PM, michele caseposta wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
This is a problem addressed by my patchDVI package, available on R-forge. You have a main file (which can be .tex or .Rnw), and put code at the start of each .Rnw file to indicate where to find it. Then you just run Sweave on one of the chapters, and it automatically produces the full document. The sample document here: http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/ includes an appendix describing how to set this up with TeXShop.
I just committed an update to the vignette in patchDVI giving a quick version of the instructions for basic use. Version 1.8.1585 has the new vignette. I should get around to pushing it to CRAN one of these days... Duncan Murdoch
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130118/1bc13bf4/attachment.pl>
Sweave produces foo-concordance.tex from foo.Rnw, and writes
\input{foo-concordance.tex} in the LaTeX output. You can turn on the
concordance option in knitr as well. Since you do not use RStudio, you
have a couple of more steps to go:
1. borrow \Sconcordance from Sweave.sty;
2. manually \input{foo-concordance.tex};
3. set the option concordance=TRUE in opts_knit;
The rest of steps are the same as Sweave -- you compile the output by
`pdflatex --synctex=1 foo.tex`, and run patchDVI on the results. I do
not use TeXShop, so I'm not sure if it really works.
\documentclass{article}
% from Sweave.sty in R
\newcommand{\Sconcordance}[1]{%
\ifx\pdfoutput\undefined%
\csname newcount\endcsname\pdfoutput\fi%
\ifcase\pdfoutput\special{#1}%
\else%
\begingroup%
\pdfcompresslevel=0%
\immediate\pdfobj stream{#1}%
\pdfcatalog{/SweaveConcordance \the\pdflastobj\space 0 R}%
\endgroup%
\fi}
\input{foo-concordance.tex}
<<setup, include=FALSE>>=
opts_knit$set(concordance=TRUE)
@
\begin{document}
<<>>=
for (i in 1:5) {
print(i)
}
@
\end{document}
Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Thu, Jan 17, 2013 at 7:45 PM, huang min <minhuangr at gmail.com> wrote:
Anybody know if it is possible to use texshop and knitr with the sync working? I add a knitr engine but cannot sync. PS, I am comfortable with texshop but not RStudio. Huang On Fri, Jan 18, 2013 at 7:33 AM, michele caseposta <mic.cipi at gmail.com>wrote:
Hi,
I just updated R and patchDVI (from CRAN).
Now I can reverse search from the pdf to the included.Rnw.
However, I cannot forward search from the included to the pdf. Is this how
it is expected to work?
Forward and inverse search work between main Rnw and pdf.
I am pasting below the code in the two files.
%%%%%%%%% Sweavetest.Rnw %%%%%%%%%%%%
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
\title{an Sweave inclusion test}
\author{Michele}
\maketitle
This is an example for the inclusion of RNW files and forward-inverse
search.
following is a chunk of sweave code:
<<>>=
n <- 5
for(i in 1:n){
print(i)
}
@
\section{text from an included file}
\SweaveInput{included.Rnw}
\end{document}
%%%%%%%%% Included.Rnw %%%%%%%%%%%%
% !Rnw root = Sweavetest.Rnw
this is some text included in an Rnw file
<<>>=
for(i in 1:3){
print('included')
}
@
On Jan 11, 2013, at 5:38 AM, Duncan Murdoch wrote:
On 13-01-10 4:54 PM, michele caseposta wrote:
Hi everybody, thanks for the replies. I might have not explained the problem completely. Duncan Mackay: Yes, I am already having a master file and separate Rnw files. Duncan Murdock: I am using patchDVI in the TexShop Sweave engine. Sync works flawlessly between the master file and the pdf produced by
pdflatex.
My problem is that I don't seem to be able to obtain sync between the
*included* Rnws and the pdf, either way.
The sweave engine is as follows: #!/bin/bash R CMD Sweave "$1" latexmk -pdf -silent -pdflatex=?pdflatex ?shell-escape
?synctex=1?"${1%.*}"
Rscript -e "library(?patchDVI?);patchSynctex(?${1%.*}.synctex.gz?)"
Funny thing is that the sync works in texworks, using the following
Rscript line
patchDVI::SweavePDF('$fullname',stylepath=FALSE)
I tried to mix and match configurations between texshop and texworks
but I had no luck
I just tried a simple example in TeXShop and it worked for me. My
Sweave engine is
#!/bin/tcsh # set path= ($path /usr/local/bin) Rscript -e "patchDVI::SweavePDF( '$1' )" So it seems to be work listing versions: On the Mac, I'm using R 2.15.0
patched, rev 59478, with patchDVI version 1.8.1584 (I just uploaded 1.9 to CRAN, by the way), TeXShop version 2.43.
It also works on Windows, where I have current releases of R and
patchDVI installed.
If you've got current versions of everything installed and it's still
not working, could you try putting together a small reproducible example?
Duncan Murdoch
On Jan 10, 2013, at 11:23 AM, Duncan Murdoch wrote:
On 13-01-09 9:09 PM, Duncan Murdoch wrote:
On 13-01-09 3:25 PM, michele caseposta wrote:
Hello everyone. I am in the process of writing a book in Latex with Texshop, on Mac. This book contains a lot of R code, hence the need to use Sweave. I was able to compile Rnw files, and to sync back and forth from the
pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every
chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing
synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
Has anybody succeeded in synchronizing with included Rnw files?
This is a problem addressed by my patchDVI package, available on R-forge. You have a main file (which can be .tex or .Rnw), and put
code
at the start of each .Rnw file to indicate where to find it. Then you just run Sweave on one of the chapters, and it automatically produces the full document. The sample document here:
includes an appendix describing how to set this up with TeXShop.
I just committed an update to the vignette in patchDVI giving a quick
version of the instructions for basic use. Version 1.8.1585 has the new vignette.
I should get around to pushing it to CRAN one of these days... Duncan Murdoch
On 13-01-17 6:33 PM, michele caseposta wrote:
Hi, I just updated R and patchDVI (from CRAN). Now I can reverse search from the pdf to the included.Rnw. However, I cannot forward search from the included to the pdf. Is this how it is expected to work?
I think it works if you use first line % !TEX root = Sweavetest.Rnw in the included file, rather than % !Rnw root = Sweavetest.Rnw If not, I think you'll have to ask the TeXShop people. Duncan Murdoch
Forward and inverse search work between main Rnw and pdf.
I am pasting below the code in the two files.
%%%%%%%%% Sweavetest.Rnw %%%%%%%%%%%%
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
\title{an Sweave inclusion test}
\author{Michele}
\maketitle
This is an example for the inclusion of RNW files and forward-inverse search.
following is a chunk of sweave code:
<<>>=
n <- 5
for(i in 1:n){
print(i)
}
@
\section{text from an included file}
\SweaveInput{included.Rnw}
\end{document}
%%%%%%%%% Included.Rnw %%%%%%%%%%%%
% !Rnw root = Sweavetest.Rnw
this is some text included in an Rnw file
<<>>=
for(i in 1:3){
print('included')
}
@
On Jan 11, 2013, at 5:38 AM, Duncan Murdoch wrote:
On 13-01-10 4:54 PM, michele caseposta wrote:
Hi everybody,
thanks for the replies.
I might have not explained the problem completely.
Duncan Mackay:
Yes, I am already having a master file and separate Rnw files.
Duncan Murdock:
I am using patchDVI in the TexShop Sweave engine.
Sync works flawlessly between the master file and the pdf produced by pdflatex.
My problem is that I don't seem to be able to obtain sync between the *included* Rnws and the pdf, either way.
The sweave engine is as follows:
#!/bin/bash
R CMD Sweave "$1"
latexmk -pdf -silent -pdflatex=?pdflatex ?shell-escape ?synctex=1?"${1%.*}"
Rscript -e "library(?patchDVI?);patchSynctex(?${1%.*}.synctex.gz?)"
Funny thing is that the sync works in texworks, using the following Rscript line
patchDVI::SweavePDF('$fullname',stylepath=FALSE)
I tried to mix and match configurations between texshop and texworks but I had no luck
I just tried a simple example in TeXShop and it worked for me. My Sweave engine is #!/bin/tcsh # set path= ($path /usr/local/bin) Rscript -e "patchDVI::SweavePDF( '$1' )" So it seems to be work listing versions: On the Mac, I'm using R 2.15.0 patched, rev 59478, with patchDVI version 1.8.1584 (I just uploaded 1.9 to CRAN, by the way), TeXShop version 2.43. It also works on Windows, where I have current releases of R and patchDVI installed. If you've got current versions of everything installed and it's still not working, could you try putting together a small reproducible example? Duncan Murdoch
On Jan 10, 2013, at 11:23 AM, Duncan Murdoch wrote:
On 13-01-09 9:09 PM, Duncan Murdoch wrote:
On 13-01-09 3:25 PM, michele caseposta wrote:
Hello everyone.
I am in the process of writing a book in Latex with Texshop, on Mac.
This book contains a lot of R code, hence the need to use Sweave.
I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
I can compile them from the main one (book.Rnw) using the directive
\SweaveInput{chapter1.Rnw}
The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
I am using the sweave engine found in the following webpage:
http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
Has anybody succeeded in synchronizing with included Rnw files?
This is a problem addressed by my patchDVI package, available on R-forge. You have a main file (which can be .tex or .Rnw), and put code at the start of each .Rnw file to indicate where to find it. Then you just run Sweave on one of the chapters, and it automatically produces the full document. The sample document here: http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/ includes an appendix describing how to set this up with TeXShop.
I just committed an update to the vignette in patchDVI giving a quick version of the instructions for basic use. Version 1.8.1585 has the new vignette. I should get around to pushing it to CRAN one of these days... Duncan Murdoch