>>Le 12 juil. 09 à 17:30, Gorjanc Gregor a écrit :
>> I agree with shorter names.
>
> And also with changing some custom insets to plain layouts? My problem
> is that I would normally have to implement lyx2lyx upgrade of documents if I
> change the layout
> name. Would it be OK to change the names without any upgrade path?
I forgot what is the difference between the insets and plain layouts? Aha, the
insets
are inserted via Insert menu, while layouts are dealt with via the handy
toolbar menu
(Standard, LyX-Code, ...). Right? For me both approaches are OK, though it
would be
more uniform to have current "insets" as insets - how can, say, \Sexpr{} be
defined
as a layout?
>> I also like the log trick, since up to now I was only able to see
>> the log if I started LyX from the terminal (works on Linux and MS Windows).
> We should normally be able to use the literate support and convert the
> log format so that it can use the Document>Log functionality.
What do you mean by "literate support" here?
>> This is especially usefull in case of errors - I never figured out
>> how listerrors python script could be used instead. However, there must be
>> some
>> way to use other place for Sweave log, since different users can overwrite
>> the file. How about generating a log in the current "private" temporary
>> folder
>> that is being used by LyX anyway?
> Yes, this is probably what we shall do.
OK. Then we need to accept the redirect trick Phillipe showed for Sweave
converter.
>> I am a bit out of date regarding the lyx-devel. What is the current
>> status with "automatic" Sweave support in LyX? Jean-Marc did you used any of
>> my
>> ideas regarding the working.directory, i.e., for reading the datafiles
>> from the "original" place?
> This is not yet done. The real solution would be to ask R developers
> to implement a R_DATA_PATH environment variable to search files.
> Since this is just a dream right now, an easy workaround would be an
> InsetInfo that returns the path of the current document. This would
> allow to have an absolute path to data in the Rnw file.
> Philippe, would you have ideas? The problem is to be able to read data
> file, since Sweave is run from a temporary directory.
Philippe what do you think about this? I still think that my proposal is a good
one - I attached the e-mail sent in April to Jean-Marc - I forgot to CC to
lyx-devel list at that time.
>> Regarding the docs. I think we first need to polish the Sweave
>> support. Then
>> we can use my paper as an initial version for documentation. Perhaps
>> we could
>> better first describe the enhanced implementation in the R Journal
>> (new R News)
>> and then use that (or extended version) as a documentation in LyX.
------------------------------------------------------------------------------------------------------
Email from GG to JM on 2009-04-26
>> Btw. Did you read my suggestion about how to solve the problem with
>> accessing the data files when moving the LyX file to the "compilation"
>> directory? I posted it to the thread where you announced the modules.
> Yes, I did, but I am still unsatisfied. I did not answer at the time
> because I wanted to find something else, and when I did not find it, I
> forgot to answer!
OK.
> Do you think it would be difficult to obtain modifications in R (for
> example have a search path for files)? I do not know the R community at
> all, actually.
I have now re-read again your e-mail[see 1] describing how is this done with
standard LyX file and I did some testing as described in detail bellow (I am
attaching the files if you want to look for yourself). From what I have seen
I think that adding the following code to the very top of a file is a good
solution.
<<>>=
setwd(dir=Sys.getenv(LYX_...))
@
This action in esence puts R back to the origdir, but the Rnw file is in
tempdir.
However, figures will be saved in origdir - this might be a feature! If we want
to save figures in tempdir to keep the origdir clean, we need to use
\SweaveOpts{prefix.string=some/path}, but I encountered some problems
with LyX/LaTeX compilation - the temdir path on MS Windows is a "mess" - see
bellow.
Another issue is when a user uses \SweaveOpts{prefix.string=some/other/path}
(say
to save figures in a specific folder). For this to work, the folder needs to
exist in
advance and this can of course work only if we use the above setwd proposal -
it can
not work in the tempdir - LyX would also have to copy also the folder.
Additionally, in such cases LyX will not be able to copy the figures to
tempdir, since the
figures are created after the Rnw files is copied to tempdir. If
some/other/path is
relative to origdir, then the figures can be saved there
(origdir/some/other/path) and the
use of \def\in...@path{} solves the problem of locating the figures. However,
if the
some/other/parth is not relative, then there is not problem at all - absolute
paths work
in any case!
Here is a summary of my tests:
-----------------------------------------------------------------------------------
LyX
I created a simple LyX file (test_paths.lyx) with two included static figures -
one
from "./" (current folder) and one from "fig/" (subfolder). When I created the
PDF I
browsed to the temporary directory and inspected the files. I also exported the
LyX
file to LaTeX file to inspect its contents.
---
Preview PDF action
Tempdir files:
- test_paths.pdf
- test_paths.tex
- 0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf
(static figure)
-
1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf
(static figure)
- other temporary files
The produced LaTeX file had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
I also did a test with a BibTeX file and noticed that BibTeX file was also
copied. Is there actually
a need for \def\in...@path directive since it seems that all needed files are
copied to the tempdir?
---
Export to LaTeX action
The resulting LaTeX file has:
- no \def\in...@path{}
- \includegraphics{test_paths_fig}
- \includegraphics{fig/test_paths_fig2}
-----------------------------------------------------------------------------------
LyX + Sweave
A test with use of Sweave in LyX file (my old approach via
literate-article.layout). I included
one static figure and created another one via R code.
This scenario causes problems with reading in the data as you are already aware
of it!
---
Preview PDF action
Tempdir files:
- test_paths_Sweave_classic.pdf
- test_paths_Sweave_classic.Rnw
- test_paths_Sweave_classic.tex
- 0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf
(static figure)
-
1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf
(static figure)
- test_paths_Sweave_classic-mySecondChunkInLyX.pdf (figure created via Sweave)
- other temporary files
The produced Sweave file (test_paths_Sweave_classic.Rnw - created from
test_paths_Sweave_classic.lyx) had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
The produced LaTeX file (test_paths_Sweave_classic.tex - created from
test_paths_Sweave_classic.Rnw) had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
- \includegraphics{test_paths_Sweave_classic-mySecondChunkInLyX}
---
Export to LaTeX action
The resulting LaTeX file had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.eps}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.eps}
- \includegraphics{test_paths_Sweave_classic-mySecondChunkInLyX}
Note that we have a potential file naming problem here. If I export to a LaTeX
file, the paths
for static figures are changed, but should not be! The resulting LaTeX file is
not operative
since it tries to include a nonexisting figure - the filename is wrong.
-----------------------------------------------------------------------------------
LyX + Sweave + setwd(dir=Sys.getenv(LYX_...))
I added the following code to the LyX file - the path corresponds to the
origdir:
<<setwd>>=
setwd(dir="C:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths")
@
This scenario avoids problems with reading in the data!
---
Preview PDF action
Tempdir files:
- test_paths_Sweave_setwd.pdf
- test_paths_Sweave_setwd.Rnw
- test_paths_Sweave_setwd.tex
- 0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf
(static figure)
-
1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf
(static figure)
- other temporary files
The produced Sweave file (test_paths_Sweave_setwd.Rnw - created from
test_paths_Sweave_setwd.lyx) had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
The produced LaTeX file (test_paths_Sweave_setwd.tex - created from
test_paths_Sweave_setwd.Rnw) had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
- \includegraphics{test_paths_Sweave_setwd-mySecondChunkInLyX}
Note that although the created figure
(test_paths_Sweave_setwd-mySecondChunkInLyX.pdf) did not
had the exact path and that is was created in the origdir, the resulting PDF
had this figure
due to \def\in...@path{} directive. This shows that my warning about figures
[see 2] does not
apply. That surely is nice! We can use setwd(dir=Sys.getenv(LYX_...)) without
problems. Figures
will be saved in origdir!
---
Export to LaTeX action
The resulting LaTeX file had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.eps}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.eps}
- \includegraphics{test_paths_Sweave_setwd-mySecondChunkInLyX}
Here we have the same file naming problem as before with classic implementation
of Sweave.
-----------------------------------------------------------------------------------
LyX + Sweave + setwd(dir=Sys.getenv(LYX_...)) + SweaveOpts{prefix.string=}
I added the following code to the LyX file - the first path corresponds to the
origdir,
while the second path corresponds to the tempdir:
<<setwd>>=
setwd(dir="C:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths")
@
\SweaveOpts{prefix.string="C:/Documents and Settings/GGorjan/Local
Settings/Temp/lyx_tmpdir.Hp5532/lyx_tmpbuf1/foo"}
This scenario avoids problems with reading in the data!
---
Preview PDF action
Tempdir files:
- test_paths_Sweave_setwd_prefix.pdf
- test_paths_Sweave_setwd_prefix.Rnw
- test_paths_Sweave_setwd_prefix.tex
- 0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf
(static figure)
-
1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf
(static figure)
- foo-mySecondChunkInLyX.pdf (figure created via Sweave)
- other temporary files
The produced Sweave file (test_paths_Sweave_setwd_prefix.Rnw - created from
test_paths_Sweave_setwd_prefix.lyx) had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
The produced LaTeX file (test_paths_Sweave_setwd_prefix.tex - created from
test_paths_Sweave_setwd_prefix.Rnw) had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
- \includegraphics{C:/Documents and Settings/GGorjan/Local
Settings/Temp/lyx_tmpdir.Hp5828/lyx_tmpbuf4/foo-mySecondChunkInLyX}
However I encountered problems in LyX when compiling the file - I got the
"Missing $ inserted ..." message.
---
Export to LaTeX action
The resulting LaTeX file had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.eps}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.eps}
- \includegraphics{C:/Documents and Settings/GGorjan/Local
Settings/Temp/lyx_tmpdir.Hp5828/lyx_tmpbuf4/foo-mySecondChunkInLyX}
Here we have the same file naming problem as before with classic implementation
of Sweave.
-----------------------------------------------------------------------------------
LyX + Sweave + setwd(dir=Sys.getenv(LYX_...)) + SweaveOpts{prefix.string=} +
user SweaveOpts{prefix.string=}
I added the following code to the LyX file - the first path corresponds to the
origdir,
while the second path corresponds to the tempdir:
<<setwd>>=
setwd(dir="C:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths")
@
\SweaveOpts{prefix.string="C:/Documents and Settings/GGorjan/Local
Settings/Temp/lyx_tmpdir.Hp5532/lyx_tmpbuf1/foo"}
But somewhere bellow there is also
\SweaveOpts{prefix.string=fig/plot}
This scenario avoids problems with reading in the data!
---
Preview PDF action
Tempdir files:
- test_paths_Sweave_setwd_prefix_user_prefix_relative.pdf
- test_paths_Sweave_setwd_prefix_user_prefix_relative.Rnw
- test_paths_Sweave_setwd_prefix_user_prefix_relative.tex
- 0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf
(static figure)
-
1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf
(static figure)
- foo-mySecondChunkInLyX.pdf (figure created via Sweave)
- other temporary files
The produced Sweave file
(test_paths_Sweave_setwd_prefix_user_prefix_relative.Rnw - created from
test_paths_Sweave_setwd_prefix_user_prefix_relative.lyx) had the following key
lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
The produced LaTeX file
(test_paths_Sweave_setwd_prefix_user_prefix_relative.tex - created from
test_paths_Sweave_setwd_prefix_user_prefix_relative.Rnw) had the following key
lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.pdf}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.pdf}
- \includegraphics{fig/plot-mySecondChunkInLyX}
No problems here.
---
Export to LaTeX action
The resulting LaTeX file had the following key lines:
- \def\in...@path{{c:/ggorjan/devel/r-ggorjan/trunk/LyX-Sweave/test_paths//}}
-
\includegraphics{0C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_test_paths_fig.eps}
-
\includegraphics{1C__ggorjan_devel_r-ggorjan_trunk_LyX-Sweave_test_paths_fig_test_paths_fig2.eps}
- \includegraphics{fig/plot-mySecondChunkInLyX}
Here we have the same file naming problem as before with classic implementation
of Sweave.
gg
[1]http://article.gmane.org/gmane.editors.lyx.devel/115399
[2]http://article.gmane.org/gmane.editors.lyx.devel/115401