# changeKeywordstyles: changeKeywordstyles In SweaveListingUtils: Utilities for Sweave Together with TeX 'listings' Package

## Description

sets up / updates a table of keywordstyles to different packages

## Usage

 `1` ```changeKeywordstyles(pkgs, keywordstyles) ```

## Arguments

 `pkgs` character; the packages for which keywordstyle information is to be changed `keywordstyles` character or missing; the corresponding keywordstyle format strings; if missing the corresponding option `Keywordstyle` is read off by using `getSweaveListingOption("Keywordstyle")`. Internally, it is being cast to the same length as `pkgs` by `rep(keywordstyles, length.out = length(pkgs))`.

## Details

Before changing the keywordstyles, we first check whether the corresponding package is registered at all —by looking up the (non-exported) vector object `.alreadyDefinedPkgs`, which is hidden in the namespace of this package.

For changing the keywordstyle, we write out a

 ```1 2 3``` ``` \lstdefinelanguage{R}% {keywordstyle=[],% } ```

directive to standard out, where `<keywordstyle as format string>` is a string containing any sequence of TeX formatting commands like `"\\bfseries\\footnotesize"`. Note that backslashes have to be escaped. and `<order number>` is just `num+2` where `num` is the index of the package in the `.alreadyDefinedPkgs` vector.

For use in an `.Rnw` file, the call to `lstsetlanguage` should be wrapped into a corresponding Sweave chunk in the form

 ```1 2 3``` ```<< /chunkname/, results=tex, echo=FALSE>>= changeKeywordstyles( ..... ) @ ```

for example

 ```1 2 3 4``` ```<>= changeKeywordstyles(pkgs = "distr", keywordstyles = "\\bfseries\\color{blue}") @ ```

## Value

`invisible()`

## Author(s)

Peter Ruckdeschel [email protected]

`lstsetLanguage`

## Examples

 ```1 2 3 4 5 6 7 8``` ```require(MASS) lstsetLanguage(pkgs = c("MASS","stats"), keywordstyles = paste("\\bfseries\\color{",c("blue","red"),"}", sep="", collapse="")) changeKeywordstyles(pkgs = c("distr","distrEx"), keywordstyles = paste("\\bfseries\\color{",c("green","blue"),"}", collapse="", sep = "")) ```

SweaveListingUtils documentation built on May 30, 2017, 6:29 a.m.