Package {bibtex}


Version: 0.5.3
Title: Bibtex Parser
Description: Utility to parse a bibtex file.
BugReports: https://github.com/ropensci/bibtex/issues
URL: https://github.com/ropensci/bibtex, https://docs.ropensci.org/bibtex/
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Depends: R (≥ 3.6.0)
Imports: utils
Suggests: testthat (≥ 3.0.3)
LazyLoad: yes
Encoding: UTF-8
Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-09-22 17:18:09 UTC; ronin
Author: Romain Francois ORCID iD [aut, cph] (principal developer of bibtex R package), Diego Hernangómez ORCID iD [aut], James Joseph Balamuta ORCID iD [aut, cre], Scott Chamberlain ORCID iD [ctb], Kurt Hornik ORCID iD [ctb], Brian Ripley [ctb] (compilation fixes), Michael Koohafkan [ctb], Mathew W. McLean ORCID iD [ctb]
Maintainer: James Joseph Balamuta <balamut2@illinois.edu>
Repository: CRAN
Date/Publication: 2026-09-22 18:10:02 UTC

bibtex: Bibtex Parser

Description

Utility to parse a bibtex file.

Author(s)

Maintainer: James Joseph Balamuta balamut2@illinois.edu (ORCID)

Authors:

Other contributors:

See Also

Useful links:


Read the raw entries of a bib file

Description

Parses a bib file into its entries without building bibentry objects. This is the parser used by read.bib, exported for packages that process the entries differently.

Usage

do_read_bib(file, encoding = "unknown", srcfile)

Arguments

file

file name

encoding

encoding

srcfile

Deprecated

Details

The parser is greatly inspired from the ‘⁠bibparse⁠’ library.

Value

A list with one element per entry, leaving out @string, @preamble and @comment blocks. Each element is a character vector of field values, named by field as written, with the outer braces or quotes removed and the file's @string macros expanded. Its attributes are entry (the entry type as written), key (the citation key) and srcref (the line numbers from the start of the entry up to the next entry or the end of the file). An empty file, or one holding only comments, gives an empty list.

See Also

bibentry

Examples

entries <- do_read_bib(system.file("bib", "xampl_single.bib",
  package = "bibtex"
))
attr(entries[[1]], "key")
entries[[1]][["title"]]

bibtex parser

Description

Parser for bibliography databases written in the bib format.

Usage

read.bib(
  file = findBibFile(package),
  package = "bibtex",
  encoding = "unknown",
  header,
  footer
)

Arguments

file

bib file to parse. By default, the file ‘REFERENCES.bib’ in the root directory of the package given by the package argument is used.

package

package from which we want to read the bibliography. Only used if file is unspecified. Core R packages (base, datasets, graphics, grDevices, methods, stats, stats4, tools and utils) are treated specially: this package contains bibtex entries for these packages.

encoding

encoding

header

DEPRECATED.

footer

DEPRECATED

Value

An object of class "bibentry", similar to those obtained by the bibentry function.

References

Nelson H. F. Beebe. bibparse 1.04. 1999. https://www.math.utah.edu/~beebe/

Examples

## this package has a REFERENCES.bib file
bib <- read.bib(package = "bibtex")

## bibtex collects bibtex entries for R base packages
base.bib <- read.bib(package = "base")

Generate a Bibtex File from Package Citations

Description

Generates a Bibtex file from a bibentry object or a list of packages. It is useful for adding relevant citations in Sweave documents.

Usage

write.bib(entry, file = "Rpackages.bib", append = FALSE, verbose = TRUE)

Arguments

entry

a bibentry object or a character vector of package names.

file

output Bibtex file.

append

logical. If TRUE content is appended to the file.

verbose

a logical to toggle verbosity.

Value

the list of Bibtex objects – invisibly.

Author(s)

Renaud Gaujoux, based on the function Rpackages.bib from Achim Zeileis (see References).

References

[R] Creating bibtex file of all installed packages? Achim Zeileis. R-help mailing list.

Examples

tmp <- tempfile(fileext = ".bib")
write.bib(c("bibtex", "utils", "tools"), file = tmp)
bibs <- read.bib(tmp)

tmp2 <- tempfile(fileext = ".bib")
write.bib(bibs, tmp2)
unname(tools::md5sum(tmp) == tools::md5sum(tmp2))

unlink(c(tmp, tmp2))

mirror server hosted at Truenetwork, Russian Federation.