# SweaveListingUtils-package

0th

Percentile

Package SweaveListingUtils provides utilities for defining R / Rd as TeX-package-listings "language" and including R / .Rd source file (sniplets) copied from an url, by default from svn server at R-forge in its most recent version, thereby avoiding inconsistencies between vignette and documented source code

Keywords
package, utilities
##### Details

 Package: SweaveListingUtils Version: 0.7.6 Date: 2017-04-22 Depends: R(>= 2.14.0), startupmsg Suggests: distr, MASS, survival, distrEx, Matrix, splines Imports: methods LazyLoad: yes License: LGPL-3 SVNRevision: 1132
TeX-package listings, confer http://www.ctan.org/tex-archive/macros/latex/contrib/listings/, http://www.ctan.org/tex-archive/macros/latex/contrib/listings/listings.pdf offers a very powerful setup for typesetting [program] code in TeX. For quite some time there has already been a corresponding language definition for R. We enhance this definition and also introduce a corresponding "language" definition file to typeset .Rd code (file Rdlistings.sty in the TeX subfolder of this package, which is according to Duncan Murdoch's Parsing Rd Files'' as of Jan. 1 2010.). In recent versions listings also cooperates with TeX package fancyvrb, so it can be configured to enhance Sweave typesetting. Just as a first simple example, comments are recognized automatically and hence typeset in particular format. For pretty printing, or moreover literate programming, with SweaveListingUtils, assignment operators <- and <<- get typeset by one symbol each. For a corresponding TeX preamble combining Sweave and listings, we provide command SweaveListingPreparations. As for the R language definition, we allow for different keywordstyles to typeset symbols from different packages. This is useful to distinguish mark-up for newly defined functions and alread existing ones. More specifically, whenever in some R code sniplet in some Sweave chunk, there is some library or require command, the corresponding symbols found by ls() afterwords in some search() entry position, are registered as <comma-separated keywordlist> (printed as 5 items per line) as a new "higher order" group of keywords by corresponding
 \lstdefinestyle{RstyleO<numi>}% RstyleO<numi> is the current order of Rstyle
{style = RstyleO<numi-1>,
morekeywords=[<order number>]{ <comma-separated keywordlist> },%
sensitive=true,%
keywordstyle=[<order number>]<keywordstyle as format string>,%
% [ possibly more
morekeywords=[<order number + 1>]{ <comma-separated keywordlist> },%
sensitive=true,%
keywordstyle=[<order number + 1>]<keywordstyle as format string>,%
% .... ]
}
\lstdefinestyle{Rstyle}{style = RstyleO<numi>}

TeX directives in the automatically generated .tex file where <order number> is incremented (resp. gets looked up from the global, non-exported variable .alreadyDefinedPkgs in the package name space) at each instance of a library or require command; an analogue incrementation present in <numi> is done for subsequent (incremental) redefinitions of style Rstyle, which is controlled by the again non-exported global variable .numberofRequires. <order number> and <numi> will in general differ, as in one call to require/library, several packages may be registered at once. To this end commands library and require are masked. See also lstsetLanguage, changeKeywordstyles, and setToBeDefinedPkgs As for the integration of code sniplets from an url (by default, we use the svn server at R-forge in its most recent version), this can be useful to stay consistent with the current version of the code without having to update vignettes all the time. To this end, besides referencing by line numbers, lstinputSourceFromRForge also offers referencing by matching regular expressions.

##### Note

This version already uses 'new-style' Rd-format version 1.1. For versions installable for $<$R-2.10.0, try and get a version 0.3.x of this package from a suitable repository.

##### Functions

lstset
lstsetR
lstsetRd
SweaveListingPreparations
copySourceFromRForge
lstinputSourceFromRForge
SweaveListingOptions
getSweaveListingOption
SweaveListingoptions
setToBeDefinedPkgs
lstsetLanguage
changeKeywordstyles
library
require


##### S3 classes and methods

taglist
print.taglist


##### Example - .Rnw vignette file

An example .Rnw file, ExampleSweaveListingUtils.Rnw, may be found in the doc folder of this package.

##### Aliases
• SweaveListingUtils-package
• SweaveListingUtils
Documentation reproduced from package SweaveListingUtils, version 0.7.7, License: LGPL-3

### Community examples

Looks like there are no examples yet.