Permalink
Browse files

updates to formating order, also now documented in readme

  • Loading branch information...
1 parent acc5e1e commit 51b15a9e63994d0bd6de0176cb1f36bb8826ff25 @cboettig committed Feb 25, 2013
Showing with 84 additions and 13 deletions.
  1. +1 −1 DESCRIPTION
  2. +8 −0 NEWS
  3. +14 −1 R/bib_format.R
  4. +1 −1 R/bibliography.R
  5. +1 −1 R/print_markdown.R
  6. +21 −2 README.md
  7. +8 −3 inst/examples/README.Rmd
  8. +27 −1 man/bib_format.Rd
  9. +3 −3 man/bibliography.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-1
+Version: 0.4-2
Date: 2012-03-24
Description: knitcitations provides the ability to create dynamic citations
in which the bibliographic information is pulled from the web rather
View
8 NEWS
@@ -21,7 +21,15 @@ And constructed with the following guidelines:
For more information on SemVer, please visit http://semver.org/.
+
+
+v0.4-2
+------
+* Testing out `bib_format` method to change order of citation elements in reference list
+
+
v0.4-1
+------
* Fixes Issue [#27](https://github.com/cboettig/knitcitations/issues/27) in rdfa printing
* Nicer markdown printing
View
@@ -3,9 +3,22 @@
#' An internal function used by methods such as print_rdfa
#' and print_markdown to specify a custom odering of the elements.
#'
+#' @param ordering a character string giving the ordering of elements
+#' @param authors the author element
+#' @param year the year element
+#' @param title element
+#' @param journal journal element
+#' @param volume volume element
+#' @param number isue number element
+#' @param pages the pages element
+#' @param doi the doi element
+#' @param uri the URL element
+#' @param collapse the collapse value passed to paste (e.g. separate with spaces only)
#' @details currently not possible to specify custom markup
#' (quotations, bold, italics, etc) though this could be added
-#' more or less without changing the API.
+#' more or less without changing the API.
+#' @keywords internal
+#'
bib_format <- function(ordering =
c("authors", "year", "title", "journal",
"volume", "number", "pages", "doi", "url"),
View
@@ -22,7 +22,7 @@
#' bibliography()
#'
#' @export
-bibliography <- function(style="textVersion", .bibstyle = "JSS",
+bibliography <- function(style="markdown", .bibstyle = "JSS",
ordering = c("authors", "year", "title",
"journal", "volume", "number",
"pages", "doi", "url"),
View
@@ -18,7 +18,7 @@ print_markdown <- function(bib, ordering =
paste(" (", r$year, ")", sep="")
journal <- if(!is.null(r$journal))
- paste(" *", r$journal, "*,", sep="")
+ paste(" *", r$journal, "*", sep="")
volume <- if(!is.null(r$volume))
paste(' **', r$volume, '**', sep="")
number <- if(!is.null(r$number))
View
@@ -27,9 +27,9 @@ Or install the current release from your CRAN mirror with `install.packages("kni
Quick start
-----------
+It is usually good to clear the bibliographic environment after loading the library, in case any citations are already stored there.
-It is usually good to clear the bibliographic environment after loading the library, in case any citations are already stored there.
@@ -117,8 +117,27 @@ bibliography()
```
-Other formats can be given as options to `bibliography`, as described in the help documentation, `?bibliography`.
+- Peter A. Abrams, Lasse Ruokolainen, Brian J. Shuter, Kevin S. McCann, (2012) Harvesting Creates Ecological Traps: Consequences of Invisible Mortality Risks in Predator–Prey Metacommunities. *Ecology* **93** [10.1890/11-0011.1](http://dx.doi.org/10.1890/11-0011.1)
+- Carl Boettiger, (2012) knitcitations: Citations for knitr markdown files. [https://github.com/cboettig/knitcitations](https://github.com/cboettig/knitcitations)
+- Yihui Xie, (2013) knitr: A general-purpose package for dynamic report generation in R. [http://yihui.name/knitr/](http://yihui.name/knitr/)
+- Phillip Lord, (2012) Greycite. *Knowledge Blog* [http://knowledgeblog.org/greycite](http://knowledgeblog.org/greycite)
+
+
+Other formats can be given as options to `bibliography`, as described in the help documentation, `?bibliography`. For instance, we can specify the format as "markdown". The custom formats "markdown" and "rdfa" take an additional argument, "ordering", which can specify what elements we want to print and what order they should be given in. For instance, we can omit everything but the authors, year, and journal, given in that order:
+
+
+```r
+bibliography("markdown", ordering = c("authors", "year", "journal"))
+```
+
+
+- Peter A. Abrams, Lasse Ruokolainen, Brian J. Shuter, Kevin S. McCann, (2012) *Ecology*
+- Carl Boettiger, (2012)
+- Yihui Xie, (2013)
+- Phillip Lord, (2012) *Knowledge Blog*
+
+(Note that since version 0.5, "markdown" is the default and can be omitted)
### Links and tooltips
View
@@ -27,8 +27,6 @@ Or install the current release from your CRAN mirror with `install.packages("kni
Quick start
-----------
-`r cite_options(linked=FALSE)`
-
It is usually good to clear the bibliographic environment after loading the library, in case any citations are already stored there.
@@ -37,6 +35,8 @@ library(knitcitations)
newbib()
```
+`r cite_options(linked=FALSE)`
+
### Cite by DOI
Cite an article by DOI and the full citation information is gathered automatically.
@@ -93,8 +93,13 @@ At the end of our document we can generate the traditional "References" or "Work
bibliography()
```
-Other formats can be given as options to `bibliography`, as described in the help documentation, `?bibliography`.
+Other formats can be given as options to `bibliography`, as described in the help documentation, `?bibliography`. For instance, we can specify the format as "markdown". The custom formats "markdown" and "rdfa" take an additional argument, "ordering", which can specify what elements we want to print and what order they should be given in. For instance, we can omit everything but the authors, year, and journal, given in that order:
+
+```{r results="asis"}
+bibliography("markdown", ordering=c("authors", "year", "journal"))
+```
+(Note that since version 0.5, "markdown" is the default and can be omitted)
### Links and tooltips
View
@@ -2,10 +2,35 @@
\alias{bib_format}
\title{Specify the order in which citation elements should be returned}
\usage{
- bib_format(ordering = c("authors", "year", "title", "journal", "volume", "number", "pages", "doi", "uri"),
+ bib_format(ordering = c("authors", "year", "title", "journal", "volume", "number", "pages", "doi", "url"),
authors, year, title, journal, volume, number, pages,
doi, uri, collapse = " ")
}
+\arguments{
+ \item{ordering}{a character string giving the ordering of
+ elements}
+
+ \item{authors}{the author element}
+
+ \item{year}{the year element}
+
+ \item{title}{element}
+
+ \item{journal}{journal element}
+
+ \item{volume}{volume element}
+
+ \item{number}{isue number element}
+
+ \item{pages}{the pages element}
+
+ \item{doi}{the doi element}
+
+ \item{uri}{the URL element}
+
+ \item{collapse}{the collapse value passed to paste (e.g.
+ separate with spaces only)}
+}
\description{
An internal function used by methods such as print_rdfa
and print_markdown to specify a custom odering of the
@@ -16,4 +41,5 @@
(quotations, bold, italics, etc) though this could be
added more or less without changing the API.
}
+\keyword{internal}
View
@@ -2,8 +2,8 @@
\alias{bibliography}
\title{Generate the bibliography}
\usage{
- bibliography(style = "textVersion", .bibstyle = "JSS",
- ordering = c("authors", "year", "title", "journal", "volume", "number", "pages", "doi", "uri"),
+ bibliography(style = "markdown", .bibstyle = "JSS",
+ ordering = c("authors", "year", "title", "journal", "volume", "number", "pages", "doi", "url"),
sort = FALSE,
bibtex = get("bibtex_data", envir = knitcitations_options),
...)
@@ -54,7 +54,7 @@
citet(citation("knitr"))
bibliography()
## use markdown formatting, show only author, year, and url
-bibliography("markdown", ordering = c("author", "year", "url"))
+bibliography("markdown", ordering = c("authors", "year", "url"))
## Repeat citations do not create duplicates:
bib <- c(citation("knitr"), citation("knitr"), citation("bibtex"), citation("bibtex"), citation("knitr"), citation("knitcitations"), citation("bibtex"))

0 comments on commit 51b15a9

Please sign in to comment.