
Scan citations and write a bibliography file for a whole R project
Source:R/bbt_write_quarto_bib.R
bbt_write_quarto_bib.Rd
bbt_write_quarto_bib()
write a bibliography file scanning all citation
keys in a R project.
Different from bbt_write_bib()
, this function
scans all files in a project directory and subdirectories for citation
keys, ensuring that all citations are included in the bibliography file.
Usage
bbt_write_quarto_bib(
bib_file = here::here("references.json"),
dir = c("", "qmd", "tex"),
pattern = "\\.qmd$|\\.tex$",
ignore = NULL,
translator = rbbt::bbt_guess_translator(bib_file),
library_id = getOption("rbbt.default.library_id", 1),
overwrite = TRUE,
filter = identity,
wd = here::here()
)
Arguments
- bib_file
(Optional) A
character
string with the path to the bibliography file (Default:here::here("references.json")
).- dir
(Optional) A
character
vector indicating the directories to scan for citation keys (Default:c("", "qmd", "tex")
).- pattern
(Optional) A
character
string with a regular expression to match files to scan for citation keys (Default:"\.qmd$|\.tex$"
).- ignore
(Optional) A
character
string with a regular expression to match files to ignore when scanning for citation keys (Default:NULL
).- translator
(Optional) A
character
string with the name of the translator to use when writing the bibliography file. The available translators are:json
(CSL-JSON),biblatex
,bibtex
(BibLaTeX), andyaml
(CSL YAML). CSL-JSON is recommended if users are not specifically using a LaTeX citation processor. Seebbt_write_bib()
for more details (Default:rbbt::bbt_guess_translator(bib_file)
).- library_id
(Optional) A
numeric
integer with the Zotero library ID to use when writing the bibliography file. Seebbt_write_bib()
for more details (Default:getOption("rbbt.default.library_id", 1)
).- overwrite
(Optional) A
logical
flag indicating whether to overwrite the bibliography file if it already exists (Default:TRUE
).- filter
(Optional) A
function
to filter the bibliography entries before writing the bibliography file. Seebbt_write_bib()
for more details (Default:identity
).- wd
(Optional) A
character
string with the path to the working directory (Default:here::here()
).
Details
Better BibTeX
To use this function, you must have the BetterBibTeX (BBT) extension installed in your Zotero. Zotero must be open and running when you execute this function.
Note
(2025-03-10) Unfortunately, the author of the rbbt
package has not yet
merged a
crucial pull request into
the package repository. If you encounter problems with this function,
please try downloading and installing this rbbt
fork:
https://github.com/wmoldham/rbbt. You can install it using the following
code:
remotes::install_github("wmoldham/rbbt")