Title: | Citations for 'Knitr' Markdown Files |
---|---|
Description: | 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 time. The package is primarily aimed at authoring in the R 'markdown' format, and can provide outputs for web-based authoring such as linked text for inline citations. Cite using a 'DOI', URL, or 'bibtex' file key. See the package URL for details. |
Authors: | Carl Boettiger [aut, cre] |
Maintainer: | Carl Boettiger <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.12 |
Built: | 2024-10-31 16:33:10 UTC |
Source: | https://github.com/cboettig/knitcitations |
get the full metadata for a citation / bibliographic object
bib_metadata(x, BibEntry = TRUE, ...)
bib_metadata(x, BibEntry = TRUE, ...)
x |
a query or citation identifer, as in citep/citet, except that it must be a single query, not a list of multiple queries. |
BibEntry |
logical. Coerce to RefManageR's BibEntry type? |
... |
additional arguments to query (see RCrossRef) |
This function is called internally by citet and citep, but is also made available in the namespace for a user wanting to return the full citation object directly.
a BibEntry (or bibentry, if requested) object with the required citation information.
Generate the bibliography
bibliography(style = "text", ...)
bibliography(style = "text", ...)
style |
see RefManageR::PrintBibliography |
... |
additional arguments passed to PrintBibliography, |
For non-trivial bibliographies, knitcitations recommends authors use pandoc format, and allow pandoc to generate the references list rather than rely on the bibliography() function. Pandoc has rich CSL support using any provided CSL file (see Pandoc documentation for details) and is integrated into recent version of RStudio.
a list of works cited
citet(citation("httr")) citet(citation("digest")) bibliography() bibliography(sorting = 'ynt') # sort by year, then name, title bibliography(sorting = 'ydnt') # sort by year, descending, then name, title cleanbib()
citet(citation("httr")) citet(citation("digest")) bibliography() bibliography(sorting = 'ynt') # sort by year, then name, title bibliography(sorting = 'ydnt') # sort by year, descending, then name, title cleanbib()
Toggles for various citation options
cite_options( citation_format = "compatibility", style = "text", hyperlink = FALSE, cite.style = "authoryear", super = FALSE, max.names = 4, longnamesfirst = FALSE, check.entries = FALSE, ... )
cite_options( citation_format = "compatibility", style = "text", hyperlink = FALSE, cite.style = "authoryear", super = FALSE, max.names = 4, longnamesfirst = FALSE, check.entries = FALSE, ... )
citation_format |
'pandoc', 'compatibility' (with version 0.5 or earlier), or 'text' |
style |
plain "text" style (default) inline citations, "markdown" style or or html style links to the hyperlink |
hyperlink |
Either logical (FALSE), or link "to.doc" (by DOI if available, otherwise to URL), or link "to.bib" section. |
cite.style |
Should inline textual citations use "authoryear", "numeric", or "authortitle" format? |
super |
logical, should numeric cite.style be a superscript? |
max.names |
numeric, maximum number of names to list before adding "et al.". |
longnamesfirst |
logical. Should all authors be listed the first time a citation is used (rather than obeying max.names?) |
check.entries |
logical. Should error if any 'required' bibtex field is missing? Default FALSE |
... |
additional arguments to BibOptions |
updates the option specified for the duration of the session.
Generate an inline parenthetical citation
citep(x, ...)
citep(x, ...)
x |
a citation query, or list of queries for multiple citations. See details and examples |
... |
additional arguments for the search or formatting. See details. |
the citation query can be any of: - A bibentry object, - An article or dataset DOI, - The URL to a website such as a scientific journal article page - A path to a PDF file (will attempt to extract citation info) - A search query string, such as part of the article title, year, or journal (Queries CrossRef) - The bibkey to anything that has already been cited. knitcitations will attempt to find the most complete citation information based on the information specified. In some cases that information may be incomplete. When using search queries rather than an exact reference (such as URL, DOI, pdf, or bibkey) the desired article may not be found or many not be uniquely determined by the string. The most relevant search result is returned, so consider refining search terms as necessary. See examples.
Format of the parenthetical citation will depend on configuration.
Unless citation_format = "pandoc", formatting is handled by
Citep
. See the arguments to Citep for details.
knitcitations will automatically track what has been cited during the
active R session until the citation log is reset.
Citep
for more details on the
parenthetical citation generation. citet
for generating
inline text citations.
# Cite an R package using the 'bibentry' object citep(citation("httr"))
# Cite an R package using the 'bibentry' object citep(citation("httr"))
Generate an inline text citation
citet(x, ...)
citet(x, ...)
x |
a citation query, or list of queries for multiple citations. See details and examples |
... |
additional arguments for the search or formatting. See details. |
the citation query can be any of: - A bibentry object, - An article or dataset DOI, - The URL to a website such as a scientific journal article page - A path to a PDF file (will attempt to extract citation info) - A search query string, such as part of the article title, year, or journal (Queries CrossRef) - The bibkey to anything that has already been cited. knitcitations will attempt to find the most complete citation information based on the information specified. In some cases that information may be incomplete. When using search queries rather than an exact reference (such as URL, DOI, pdf, or bibkey) the desired article may not be found or many not be uniquely determined by the string. The most relevant search result is returned, so consider refining search terms as necessary. See examples.
Format of the text citation will depend on configuration. Unless
citation_format = "pandoc", formatting is handled by
Citet
. See the arguments to Citet for details.
knitcitations will automatically track what has been cited during the
active R session until the citation log is reset.
Citep
for more details on the inline text
citation generation. citep
for generating parenthetical
citations.
# Cite an R package using the 'bibentry' object citet(citation("httr"))
# Cite an R package using the 'bibentry' object citet(citation("httr"))
Clean the log of works cited so far.
cleanbib()
cleanbib()
Removes log cache, returns invisible 'NULL'
Grab citation data using the greycite API
greycite(url, format = c("bib", "json"))
greycite(url, format = c("bib", "json"))
url |
the website URL |
format |
have greycite return data in bib (bibtex) or json format? |
a bibentry class object
read.bibtex
read.bibtex(file, .Encoding = "UTF-8", check = FALSE)
read.bibtex(file, .Encoding = "UTF-8", check = FALSE)
file |
string; bib file to parse. |
.Encoding |
encoding |
check |
error, warn, or logical FALSE. What action should be taken if an entry is missing required fields? FALSE means no checking is done, warn means entry is added with an error. error means the entry will not be added. See BibOptions. |
Returns the bib object
adds a BibEntry object to the works cited list even if not cited with a call to citep/citet
record_as_cited(entry)
record_as_cited(entry)
entry |
a BibEntry object (or something that can be coerced to one, like bibentry) |
Adds the object to the citation list, with a BibTex citation key that does not duplicate any that are already in the record. Invisibly returns the bibentry object.
write a bibtex file
write.bibtex(entry = NULL, file = "knitcitations.bib", append = FALSE, ...)
write.bibtex(entry = NULL, file = "knitcitations.bib", append = FALSE, ...)
entry |
a 'bibentry' object or list of bibentry objects. If NULL, writes all that have currently been cited. |
file |
output bibtex file. Will automatically append '.bib' if not added. if 'NULL' will use stdout. |
append |
a logical indicating that bibtex entries be added the the file. If FALSE (default), the file is overwritten. |
... |
additional arguments to WriteBib |
a list of citation information, invisibly
read.bib citep citet
tmp <- tempfile(fileext=".bib") write.bibtex(c(citation("knitr"), citation("knitcitations"), citation("httr")), file = tmp) bib <- read.bibtex(tmp)
tmp <- tempfile(fileext=".bib") write.bibtex(c(citation("knitr"), citation("knitcitations"), citation("httr")), file = tmp) bib <- read.bibtex(tmp)