Description Usage Arguments Details Value Acknowledgement Author(s) Examples
View source: R/SweaveListingUtils.R
helping tool for writing the corresponding TeX preamble commands to integrate Sweave and package listings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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)
|
withOwnFileSection |
logical: Does one want to use an own definition file/
section to define |
withVerbatim |
logical of length 3 (filled by recycling if of shorter length)
either named ("Sinput", "Soutput", "Scode") or taken in
order (Sinput, Soutput, Scode):
Should we use Verbatim from TeX package 'fancyvrb'
(i.e. the original
"\DefineVerbatimEnvironment{Sinput}{Verbatim}" by
Fritz Leisch) or just TeX package 'listings'
(i.e. we define our own |
withSchunkDef |
logical: shall environment |
gin |
logical: shall we use |
ae |
logical: shall we use |
LineLength |
numeric; defaults to 80 |
Rset |
list or taglist; defaults to global option |
Rdset |
list or taglist; defaults to global option |
Rin |
list or taglist; format string for R input code; defaults to global option |
Rout |
list or taglist; format string for R output code; defaults to global option |
Rcode |
list or taglist; format string for R code; defaults to global option |
Rcolor |
numeric of length 3; [color for R-input-code] defaults to global option |
RRecomdcolor |
numeric of length 3; [color for R-symbols from recommended packages]
defaults to global option |
Rbcolor |
numeric of length 3; [color for R-symbols from intermediate packages] defaults to global option |
Routcolor |
numeric of length 3; [color for R-output-code] defaults to global option |
Rcommentcolor |
numeric of length 3; [color for R-comments] defaults to global option |
pkg |
character; name of the packageto be described (e.g. in a vignette);
defaults to global option |
pkv |
character; package version to be described (e.g. in a vignette);
defaults to global option |
fileCommand |
character; the TeX code to define TeX command |
pkgCommand |
character; the TeX code to define TeX command |
lib.loc |
location of a local library in which the described package resides |
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
1 2 |
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
1 2 3 4 | << 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
.
invisible()
The author wants to thank Frank E. Harrel and Andrew Ellis for very valuable suggestions to enhance this package.
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de
1 2 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.