Skip to content

Commit

Permalink
Add subsetting arguments to PrintBibliography
Browse files Browse the repository at this point in the history
The additional arguments, `start`, `stop`, and `decreasing`, make it possible to subset the output of `PrintBibliography` so that subsections of the references can be printed to separate slides in Rmarkdown HTML slides.
  • Loading branch information
jvcasillas authored Mar 7, 2018
1 parent f838f35 commit 060a5e0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/rmdCite.R
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,10 @@ AddCitationPunct <- function(result, bibpunct, before, after, textual,
#' \code{\link[utils]{citeNatbib}}, the package vignettes
#' bib <-
#' @rdname Cite
PrintBibliography <- function(bib, .opts = list()){
PrintBibliography <- function(bib, .opts = list(), start = 1, stop = NULL, decreasing = FALSE){

bib <- sort(bib, decreasing = FALSE)

if (!length(bib))
return(bib)
if (identical(class(bib), "bibentry"))
Expand Down Expand Up @@ -368,6 +371,11 @@ PrintBibliography <- function(bib, .opts = list()){
sQuote(paste0(paste0("@", names(.cites$indices)), collapse = ", ")))
cat("\n... \n\n")
}

if (is.null(stop)) {
stop <- length(bib)
}
bib <- bib[start:stop]
print(bib)
}

Expand Down

0 comments on commit 060a5e0

Please sign in to comment.