SweaveListingPreparations(
withOwnFileSection = FALSE,
withVerbatim = FALSE,
withSchunkDef = TRUE,
gin = TRUE,
ae = TRUE,
LineLength = getOption("width"),
Rset = getSweaveListingOption("Rset"),
Rdset = getSweaveListingOption("Rdset"),
Rin = getSweaveListingOption("Rin"),
Rout = getSweaveListingOption("Rout"),
Rcode = getSweaveListingOption("Rcode"),
Rcolor = getSweaveListingOption("Rcolor"),
RRecomdcolor = getSweaveListingOption("RRecomdcolor"),
Rbcolor = getSweaveListingOption("Rbcolor"),
Routcolor = getSweaveListingOption("Routcolor"),
Rcommentcolor = getSweaveListingOption("Rcommentcolor"),
pkg = getSweaveListingOption("pkg"),
pkv = getSweaveListingOption("pkv"),
fileCommand = getSweaveListingOption("fileCommand"),
pkgCommand = getSweaveListingOption("pkgCommand"),
lib.loc = NULL)
Sinput
, Soutput
,
Scode
environments; if TRUE
you should write some
\include directive to include your own
definitions / or write them in your .Rnw
file.
Sinput
environment
based on 'listings' command 'lstnewenvironment';
this option is due to a suggestion by
Andrew Ellis (thank you!).Schunk
be defined?gin
ae
"Rset"
"Rdset"
"Rin"
"Rout"
"Rcode"
"Rcolor"
;
rgb coordinates of the color in which to print R-code"RRecomdcolor"
;
rgb coordinates of the color in which to print R-code"Rbcolor"
;
rgb coordinates of the color in which to print R keywords
induced by intermediate packages."Rout"
;
rgb coordinates of the color in which to print R output"Rcomment"
;
rgb coordinates of the color in which to print comments
in R-code"pkg"
"pkv"
\file
\pkg
invisible()
SweaveListingPreparations
writes a corresponding preamble to the .Rnw
-file for the simultaneous use
of Sweave and package listings; note that so far, even if you do not want to
use the default style file Sweave.sty
, the lines
%\usepackage{Sweave} \SweaveOpts{keep.source=TRUE}still have to appear in the
.Rnw
file --- before the corresponding
SweaveListingPreparations
-chunk.
The TeX code inserted by SweaveListingPreparations
sets colors,
requires TeX-package listings
,
defines listings-settings for .R
- and .Rd
-code.
For .Rd
files it uses a new 'listings'-language definition file,
Rdlisting.sty
to be found in subfolder TeX
in the
SweaveListingUtils package folder.
SweaveListingPreparations
is to be called in an .Rnw
file and
[re-]defines Sinput
,
Soutput
, Scode
environments for use with TeX-package listings
,
defines commands \code
, \file
, \pkg
and sets
the corresponding package version.
The default values are taken from
SweaveListingOptions.
The output to stdout can be captured in an .Rnw
file as
<< lstPreamble, results=tex, echo=FALSE>>= require(SweaveListingUtils) SweaveListingPreparations() @to insert the corresponding preamble parts to the produced TeX file. If you one want to use destinct keywordstyles for packages loaded by
require
or library
without adding extra arguments
to these commands (and hence displaying the actual R code),
you have to set up a global formatting matrix
.tobeDefinedPkgs
by setToBeDefinedPkgs
.SweaveListingPreparations()
SweaveListingPreparations(pkv="2.1")
Run the code above in your browser using DataLab