R/bibtools.R

###
###
###
###   Purpose:   Tools for bibliographies
###   started:   2018-01-18 (pvr)
###
### ############################################## ###


#' @title Write bibentries to a bib file
#'
#' @description
#' One way of specifying records of a bibliography is to define
#' a vector of bibentries at the end of a document. This vector
#' must then be written to a .bib file which can later be used
#' by the latex-system to generate the bibliography. This function
#' is used to write the vector of bibentries to a file.
#'
#' @param pvec_bref vector of bibentries
#' @param ps_bibfile bibfile where bibentries should be written to
#' @export write_bib
write_bib <- function(pvec_bref, ps_bibfile = "skeleton.bib"){
  cat("%%% Bibfile automatically generated by rmddochelper::write_bib\n", file = ps_bibfile)
  if (!is.null(pvec_bref))
    cat(paste0(utils::toBibtex(pvec_bref), collapse = "\n"), file = ps_bibfile, append = TRUE)
  return(invisible(TRUE))
}
charlotte-ngs/rmddochelper documentation built on June 27, 2019, 1:22 a.m.