bibentry {utils}R Documentation

Bibliography Entries


Functionality for representing and manipulating bibliographic information in enhanced BibTeX style.


bibentry(bibtype, textVersion = NULL, header = NULL, footer = NULL,
         key = NULL, ..., other = list(),
         mheader = NULL, mfooter = NULL)

## S3 method for class 'bibentry'
print(x, style = "text", .bibstyle,
      bibtex = length(x) <= getOption("citation.bibtex.max", 1),

## S3 method for class 'bibentry'
format(x, style = "text", .bibstyle = NULL,
       bibtex = length(x) <= 1,
       citMsg = missing(bibtex),
       sort = FALSE, macros = NULL, ...)

## S3 method for class 'bibentry'
sort(x, decreasing = FALSE, .bibstyle = NULL, drop = FALSE, ...)

## S3 method for class 'citation'
 print(x, style = "citation", ...)
## S3 method for class 'citation'
format(x, style = "citation", ...)

## S3 method for class 'bibentry'
toBibtex(object, escape = FALSE, ...)



a character string with a BibTeX entry type. See Entry Types for details.


a character string with a text representation of the reference to optionally be employed for printing. It is recommended to leave this unspecified if format(x, style = "text") works correctly. Only if special LaTeX macros (e.g., math formatting) or special characters (e.g., with accents) are necessary, a textVersion should be provided.


a character string with optional header text.


a character string with optional footer text.


a character string giving the citation key for the entry.


for bibentry: arguments of the form tag=value giving the fields of the entry, with tag and value the name and value of the field, respectively. Arguments with empty values are dropped. Field names are case-insensitive. See Entry Fields for details.

For the print() method, extra arguments to pass to the renderer which typically includes the format() method.

For the citation class methods, arguments passed to the next method, i.e., the corresponding bibentry one.

For the toBibtex() method, currently not used.


a list of arguments as in ... (useful in particular for fields named the same as formals of bibentry).


a character string with optional “outer” header text.


a character string with optional “outer” footer text.


an object inheriting from class "bibentry".


an optional character string specifying the print style. If present, must be a unique abbreviation (with case ignored) of the available styles, see Details.


logical, passed to order indicating the sort direction.


a character string naming a bibliography style, see bibstyle.


logical indicating if BibTeX code should be given additionally; currently applies only to style = "citation". The default for the print() method depends on the number of (bib) entries and getOption("citation.bibtex.max") (which itself is 1 by default). For example, to see no BibTeX at all, you can change the default by options(citation.bibtex.max = 0).


logical indicating if a “message” should be added (to the footer) about how to get BibTeX code when bibtex is false and style = "citation".


logical indicating if bibentries should be sorted, using bibstyle(.bibstyle)$sortKeys(x).


a character string or an object with already loaded Rd macros, see Details.


logical used as x[ ..., drop=drop] inside the sort() method.


an object inheriting from class "bibentry".


a logical indicating whether non-ASCII characters should be translated to LaTeX escape sequences.


The bibentry objects created by bibentry can represent an arbitrary positive number of references. One can use c() to combine bibentry objects, and hence in particular build a multiple reference object from single reference ones. Alternatively, one can use bibentry to directly create a multiple reference object by specifying the arguments as lists of character strings.

The print method for bibentry objects is based on a corresponding format method and provides a choice between seven different styles: plain text (style "text"), BibTeX ("bibtex"), a mixture of plain text and BibTeX as traditionally used for citations ("citation"), HTML ("html"), LaTeX ("latex"), R code ("R"), and a simple copy of the textVersion elements (style "textVersion").

The "text", "html" and "latex" styles make use of the .bibstyle argument: a style defined by the bibstyle function for rendering the bibentry into (intermediate) Rd format. The Rd format uses markup commands documented in the ‘Rd format’ section of the ‘Writing R Extensions’ manual, e.g. ⁠\bold⁠. In addition, one can use the macros argument to provide additional (otherwise unknown, presumably LaTeX-style) Rd macros, either by giving the path to a file with Rd macros to be loaded via loadRdMacros, or an object with macros already loaded. Note that the "latex" result may contain commands from the LaTeX style file ‘Rd.sty’ shipped with R; put ⁠\usepackage{Rd}⁠ in the preamble of a LaTeX document to make these available when compiling, e.g. with texi2pdf.

When printing bibentry objects in citation style, a header/footer for each item can be displayed as well as a mheader/mfooter for the whole vector of references.

For formatting as R code, a choice between giving a character vector with one bibentry() call for each bibentry (as commonly used in ‘CITATION’ files), or a character string with one collapsed call, obtained by combining the individual calls with c() if there is more than one bibentry. This can be controlled by passing the argument collapse=FALSE (default) or TRUE, respectively, to the format() method. (Printing in R style always collapses to a single call.)

It is possible to subscript bibentry objects by their keys (which are used for character subscripts if the names are NULL).

There is also a toBibtex method for direct conversion to BibTeX.

As of R 4.3.0, there is also a transform method which allows to directly use the current fields, see the examples.


bibentry produces an object of class "bibentry".

Entry Types

bibentry creates "bibentry" objects, which are modeled after BibTeX entries. The entry should be a valid BibTeX entry type, e.g.,


An article from a journal or magazine.


A book with an explicit publisher.


A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.


A part of a book having its own title.


An article in a conference proceedings.


Technical documentation like a software manual.


A Master's thesis.


Use this type when nothing else fits.


A PhD thesis.


The proceedings of a conference.


A report published by a school or other institution, usually numbered within a series.


A document having an author and title, but not formally published.

Entry Fields

The ... argument of bibentry can be any number of BibTeX fields, including


The address of the publisher or other type of institution.


The name(s) of the author(s), either as a person object, or as a character string which as.person correctly coerces to such.


Title of a book, part of which is being cited.


A chapter (or section or whatever) number.


The DOI ( for the reference.


Name(s) of editor(s), same format as author.


The publishing institution of a technical report.


A journal name.


Any additional information that can help the reader. The first word should be capitalized.


The number of a journal, magazine, technical report, or of a work in a series.


One or more page numbers or range of numbers.


The publisher's name.


The name of the school where a thesis was written.


The name of a series or set of books.


The work's title.


A URL for the reference. (If the URL is an expanded DOI, we recommend to use the ‘⁠doi⁠’ field with the unexpanded DOI instead.)


The volume of a journal or multi-volume book.


The year of publication.

See Also



## R reference
rref <- 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 = 2014,
   url = "")

## Different printing styles
print(rref, style = "bibtex")
print(rref, style = "citation")
print(rref, style = "html")
print(rref, style = "latex")
print(rref, style = "R")

## References for boot package and associated book
bref <- c(
     bibtype = "Manual",
     title = "boot: Bootstrap R (S-PLUS) Functions",
     author = c(
       person("Angelo", "Canty", role = "aut",
         comment = "S original"),
       person(c("Brian", "D."), "Ripley", role = c("aut", "trl", "cre"),
         comment = "R port, author of parallel support",
         email = "")
     year = "2012",
     note = "R package version 1.3-4",
     url = "",
     key = "boot-package"

     bibtype = "Book",
     title = "Bootstrap Methods and Their Applications",
     author = as.person("Anthony C. Davison [aut], David V. Hinkley [aut]"),
     year = "1997",
     publisher = "Cambridge University Press",
     address = "Cambridge",
     isbn = "0-521-57391-2",
     url = "",
     key = "boot-book"

## Combining and subsetting
c(rref, bref)

## Extracting fields

## Field names are case-insensitive
rref$Year <- R.version$year
stopifnot(identical(rref$year, R.version$year))

## Convert to BibTeX

## Transform
transform(rref, address = paste0(address, ", Europe"))

## BibTeX reminder message (in case of >= 2 refs):
print(bref, style = "citation")

## Format in R style
## One bibentry() call for each bibentry:
writeLines(paste(format(bref, "R"), collapse = "\n\n"))
## One collapsed call:
writeLines(format(bref, "R", collapse = TRUE))

[Package utils version 4.4.1 Index]