bibstyle {tools} | R Documentation

## Select or define a bibliography style.

### Description

This function defines and registers styles for rendering `bibentry` objects into Rd format, for later conversion to text, HTML, etc.

### Usage

    bibstyle(style, envir, ..., .init = FALSE, .default = FALSE)

### Arguments

`style` | A character string naming the style.
`envir` | (optional) An environment holding the functions to implement the style.
`...` | Named arguments to add to the environment.
`.init` | Whether to initialize the environment from the default style `"JSS"`.
`.default` | Whether to set the specified style as the default style.

### Details

Rendering of `bibentry` objects may be done using routines modelled after those used by BibTeX. This function allows environments to be created and manipulated to contain those routines.

There are two ways to create a new style environment. The easiest is to set `.init = TRUE`, in which case the environment will be initialized with a copy of the default `"JSS"` environment. (This style is modelled after the ‘jss.bst’ style used by the Journal of Statistical Software.) Alternatively, the `envir` argument can be used to specify a completely new style environment.

To simply retrieve an existing style, specify `style` and no other arguments. To modify an existing style, specify `style` and some named entries via `...`. (Modifying the default `"JSS"` style is discouraged.) Setting `style` to `NULL` or leaving it missing will retrieve the default style, but modifications will not be allowed.

At a minimum, the environment should contain routines to render each of the 12 types of bibliographic entry supported by `bibentry` as well as a routine to produce a sort key to sort the entries. The former must be named `formatArticle`, `formatBook`, `formatInbook`, `formatIncollection`, `formatInProceedings`, `formatManual`, `formatMastersthesis`, `formatMisc`, `formatPhdthesis`, `formatProceedings`, `formatTechreport` and `formatUnpublished`. Each of these takes one argument, a single `unclass`'ed entry from the `bibentry` vector passed to the renderer, and should produce a single element character vector (possibly containing newlines). The sort keys are produced by a function named `sortKeys`. It is passed the original `bibentry` vector and should produce a sortable vector of the same length to define the sort order.

### Value

The environment which has been selected or created.

### Author(s)

Duncan Murdoch

### See Also

`bibentry`

### Examples

    refs <-
    c(bibentry(bibtype = "manual",
        title = "R: A Language and Environment for Statistical Computing",
        author = person("R Core Team"),
        organization = "R Foundation for Statistical Computing",
        address = "Vienna, Austria",
        year = 2010,
        isbn = "3-900051-07-0",
        url = "http://www.R-project.org"),
      bibentry(bibtype = "article",
        author = c(person(c("George", "E", "P"), "Box"),
                   person(c("David",  "R"),      "Cox")),
        year = 1964,
        title = "An Analysis of Transformations",
        journal = "Journal of the Royal Statistical Society, Series B",
        volume = 26,
        pages = "211-252"))
    bibstyle("unsorted", sortKeys = function(refs) seq_along(refs),
           .init = TRUE)
    print(refs, .bibstyle = "unsorted")

[Package tools version 2.15.1 Index]