-
Notifications
You must be signed in to change notification settings - Fork 26
/
README.Rmd
64 lines (44 loc) · 2.9 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
output: github_document
bibliography: README.bib
csl: CJFAS.csl
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rbbt
<!-- badges: start -->
[![R build status](https://github.com/paleolimbot/rbbt/workflows/R-CMD-check/badge.svg)](https://github.com/paleolimbot/rbbt/actions)
<!-- badges: end -->
The goal of rbbt is to connect R to the [Better Bibtex for Zotero connector](https://retorque.re/zotero-better-bibtex/). This allows the insertion of in-text citations (pandoc or LaTex style) and BibLaTex bibliography items directly into the RStudio editor using the RStudio addin, or to the console otherwise.
## Installation
You can install rbbt from GitHub with:
``` r
remotes::install_github("paleolimbot/rbbt")
```
```{r}
library(rbbt)
```
You will also need [Zotero](https://www.zotero.org/) installed and running, and the [Better BibTeX for Zotero](https://retorque.re/zotero-better-bibtex/installation/) add-on installed.
## RStudio Addin
This package is most useful for the RStudio addins that insert citations and references into the editor. The "Insert Zotero Citation" will pop up a zotero search where you can search for a reference to add to your writing (Markdown, RMarkdown, or LaTeX). The "Insert Zotero Bibliography" addin inserts the bibliographical information corresponding to the selected item in the Zotero window. Finally, "Update bibliography for current document" runs `bbt_update_bib()` to update the bibliography based on the .Rmd file currently in the editor window. You can bind either of these to keyboard shortcuts in RStudio. The addins may behave differently depending on which file you have open (e.g., if you have a .bib file open, it will use the biblatex translator)...if you need more fine-grained control, try one of the console functions (like `bbt_bib()`!).
## knitr + rmarkdown integration
To make this work seamlessly with [knitr](https://yihui.org/knitr/) and [rmarkdown](https://rmarkdown.rstudio.com/), use the "Update bibliography for current document" addin to write your bibliography file based on the citations in the currently selected document. You can use `bbt_update_bib("some_file.Rmd")` to detect citations and write your bibliography file from the console.
## Programmatically fetch bibliography info
Fetch bibliography text using a list of Better BibTex citation keys:
```{r, comment=""}
# uses the citation keys you've defined with Better BibTeX
rbbt::bbt_bib("dunnington_etal18", translator = "biblatex", .action = bbt_print)
```
Fetch bibliography text from selected items in Zotero:
```{r, comment=""}
# uses whatever is currently selected in the zotero window
rbbt::bbt_bib_selected(translator = "biblatex", .action = bbt_print)
```
<!-- lazy way to test the bbt_update_bib() addon: @dunnington_etal18 -->