9
votes

I am writing my CV using markdown and want to have multiple bibliography sections (one for journal articles, another for book chapters etc). I'm using the RefManagerR package to do this and it works nicely.

library("RefManageR")
BIB <- structure(list(structure(list(title = "Quantitative palaeotemperature records inferred from fossil pollen and chironomid assemblages from Lake Gilltjarnen, northern central Sweden", author = structure(list(structure(list(given = "K", family = "Antonsson", role = NULL, email = NULL, comment = NULL), .Names = c("given", "family", "role", "email", "comment")), structure(list(given = "SJ", family = "Brooks", role = NULL, email = NULL, comment = NULL), .Names = c("given", "family", "role", "email", "comment")), structure(list(given = "H", family = "Seppa", role = NULL, email = NULL, comment = NULL), .Names = c("given", "family", "role", "email", "comment"))), class = "person"), journal = "Journal of Quaternary Science", year = "2006", number = "8", pages = "831-841", volume = "21"), .Names = c("title", "author", "journal", "year", "number", "pages", "volume"), bibtype = "Article", key = "RID:0428130725771-5", dateobj = structure(1136070000, class = c("POSIXct", "POSIXt"), tzone = "", day.mon = 0L))), strings = structure(character(0), .Names = character(0)), class = c("BibEntry", "bibentry"))

NoCite(BIB)
PrintBibliography(BIB, .opts = list(style = "latex", bib.style = "authoryear", 
                                    sorting = "ydnt"))

Which is rendered in the pdf as

Antonsson, K, S. Brooks and H. Seppa (2006). “Quantitative palaeotemperature records inferred from fossil pollen and chironomid assemblages from Lake Gilltjarnen, northern central Sweden”. In: Journal of Quaternary Science 21.8, pp. 831-841.

I want to change the style of the reference. Basically, I want to remove the quote marks and the In:, and put initials after the name. I understand that the style is set using tools::bibstyle and that I need to make a routine called formatArticle but the example for tools::bibstyle only shows how to change the sort order and I cannot work out how to see the default JSS style.

Please can someone show me how to use bibstyle.

Alternatively, please can someone show me how to make multiple bibliography sections in a single document using the bibliography generator built into rmarkdown, so I can use a csl file.

1
As far as I can see there is no option yet when working with RefManageR. Raising the flexibility of using bibstyles is in the pipeline though.Martin Schmelzer
Do you intend to use output formats other than pdf? If not, you can use latex directly to achieve what you want, though you'll need to Tame the BeaST and from personal experience, it isn't much fun.Kevin Arseneau

1 Answers

1
votes

Answering only the part about bibliography in multiple sections: If you want to do it "using the bibliography generator built into rmarkdown", you will need to change the the latex template used for generating the pdf from the Rmarkdown file. Set the template at the YAML section with something like:

output:
  pdf_document:
    template: mytemplate.tex    

There are references on how to work with templates.

An easier approach would be to add the multiple sections in the RMarkdown file itself, and print out the bibs. Example of an .Rmd file:

---
title: "2 bibs"
output: pdf_document
---

```{r init, echo=FALSE}
library("RefManageR")

## loading some bib entries from example file
file <- system.file("Bib", "biblatexExamples.bib", package = "RefManageR")
BibOptions(check.entries = FALSE)
bib <- ReadBib(file)

## Gerating the entries for the 2 sections
bib1 = bib[[5:6]]
bib2 = bib[[7:8]]
```

Intro text.

# Bib 1

```{r, results='asis', echo=FALSE}
NoCite(bib1)
PrintBibliography(bib1, .opts = list(style = "markdown", bib.style = "authoryear", sorting = "ydnt"))
```

# Bib 2

```{r, results='asis', echo=FALSE}
NoCite(bib2)
PrintBibliography(bib2, .opts = list(style = "markdown", bib.style = "authoryear", sorting = "ydnt"))
```