On Tue, Apr 21, 2009 at 11:06 PM, Paul Johnson <pauljoh...@gmail.com> wrote:
> Can I please have an example of how to use the ifelse package for
> LaTeX with LyX?  I want to manage a NoWeb/Literate programming
> document so that some commands are included in the document only
> sometimes.  (I'm sending LyX documents to R through Sweave:
> http://wiki.lyx.org/LyX/LyxWithRThroughSweave.
>
> This ERT makes sure that R- Sweave drops the images in a folder "foo"
> and prefixes all with "bar".
>
> \SweaveOpts{prefix.string=foo/bar}
>
> This is a NoWeb "code chunk" that will create an image in foo called
> bar-testfn.eps.
>
> <<testfn, fig=true, include=false>>=
> curve(sin, from = 1, to = 5)
> @
>
>
> Then the image can be used later with some LaTeX:
>
> \includegraphics{foo/bar-testfn}
>
> I would like to conditionalize the figure creation, so that only when
> I really want new figures will the code chunk be executed.
>
> In the r-help list I asked about ways to avoid re-doing calculations,
> but the answers were focused on ways in which R calculations can be
> cached, rather than avoiding asking R for calculations in the first
> place. Since I am doing this work within LyX, and LyX has its own way
> of handling the temporary LaTeX files, it is not immediately apparent
> that the caching strategies proposed from within R are going to help
> (the LyX "current working directory" is an unpredictable directory
> inside /tmp while the R working directory is inside there, and the R
> stuff disappears once LyX exits.
>
> I'm sorry, this is hard to explain.  If you can just give me a
> concrete ifthen example in ERT, I think I can make it work.  I just
> don't understand the ifelse package instructions because they assume a
> person is fluent in LaTeX.

Perhaps you should take a look at the Branch feature: section 6.8 of
the User's Guide.

Clearly this feature should be better publicized....

Bennett

Reply via email to