Permalink
Browse files

Provide page range as an option, as requested in #32

  • Loading branch information...
1 parent ecccbc5 commit 87913ad7950ef5027e7d0f24cf39e29188ce5a59 @cboettig committed Mar 25, 2013
Showing with 21 additions and 4 deletions.
  1. +1 −1 DESCRIPTION
  2. +6 −0 NEWS
  3. +8 −2 R/citep.R
  4. +6 −1 man/citep.Rd
View
@@ -3,7 +3,7 @@ Type: Package
Title: Citations for knitr markdown files
Authors@R: person("Carl", "Boettiger", role=c("aut", "cre"),
email="cboettig@gmail.com")
-Version: 0.4-4
+Version: 0.4-5
Description: knitcitations provides the ability to create dynamic citations
in which the bibliographic information is pulled from the web rather
than having to be entered into a local database such as bibtex ahead of
View
6 NEWS
@@ -22,6 +22,12 @@ And constructed with the following guidelines:
For more information on SemVer, please visit http://semver.org/.
+v0.4-5
+------
+
+* Provide page range as option to `citep` (see issue [#32](https://github.com/cboettig/knitcitations/issues/32))
+
+
v0.4-4
------
View
@@ -4,6 +4,7 @@
#' @param inline_format a function for formating the inline citation, defaults to authoryear_t
#' @param format_inline_fn function to format a single inline citation
#' @param ... additional arguments passed to citet, see \code{\link{citet}} for details
+#' @param page optional page or page range that can be given as extra text. Page ranges should be separated by hyphen, giving "pp.", while single page returns as "p." followed by page number.
#' @return a parenthetical inline citation
#' @details Stores the full citation in a "works_cited" list,
#' which can be printed with \code{\link{bibliography}}
@@ -33,9 +34,14 @@
#'
citep <- function(x, ...,
format_inline_fn = format_authoryear_p,
- inline_format = authoryear_p){
+ inline_format = authoryear_p,
+ page = NULL){
text <- citet(x, ...,
format_inline_fn = format_inline_fn,
inline_format = inline_format)
- paste("(", text, ")", sep="", collapse=";")
+ if(!is.null(page)){
+ pgs <- ifelse(grepl("-", page), "pp.", "p.")
+ pgs <- paste(",", pgs, page)
+ }
+ paste("(", text, pgs, ")", sep="", collapse=";")
}
View
@@ -3,7 +3,7 @@
\title{Add a paranthetical citation}
\usage{
citep(x, ..., format_inline_fn = format_authoryear_p,
- inline_format = authoryear_p)
+ inline_format = authoryear_p, page = NULL)
}
\arguments{
\item{x}{a doi or list of dois, or a bibentry (or list of
@@ -17,6 +17,11 @@
\item{...}{additional arguments passed to citet, see
\code{\link{citet}} for details}
+
+ \item{page}{optional page or page range that can be given
+ as extra text. Page ranges should be separated by hyphen,
+ giving "pp.", while single page returns as "p." followed
+ by page number.}
}
\value{
a parenthetical inline citation

0 comments on commit 87913ad

Please sign in to comment.