88
99This package focuses solely on “extra” functions related to citeing
1010bibliography items such as processing .bib files to get citation keys,
11- processing BiBtex keys to get inline citations, etc. This work was
12- inspired by the need to find a way to process citation keys to inline
13- citation text in DT tables as rendering in rmarkdown does not produce
14- the results we desire so we need to do it with manual calls to ` pandoc ` .
11+ processing BiBtex keys to get inline citations, etc. We are calling it
12+ “extra” because we rely heavily on
13+ [ ` rbbt ` ] ( https://github.com/paleolimbot/rbbt ) and standard
14+ ` rmarkdown::render ` magic to almost everything we need to do. Some
15+ functions for rendering citation keys as inline references wrap calls to
16+ ` pandoc ` so that needs to be installed. If you have Rstudion you likely
17+ have it already.
18+
19+ This package deals with a few problems as follows:
20+
21+ - Identify all citation keys in documents and confirm their presence in
22+ a specified .bib file.
23+ - Highlight citation keys that do not match and suggest the closest
24+ matching keys from the .bib file.
25+ - Provide workarounds for citation handling in interactive tables
26+ [ (DT)] ( https://github.com/rstudio/DT ) and other HTML outputs where
27+ standard citation rendering in R Markdown and Quarto may fail.
1528
1629## Installation
1730
@@ -25,18 +38,20 @@ pak::pkg_install("NewGraphEnvironment/xciter")
2538
2639## Example
2740
28- This is a basic example which shows you how to solve a common problem:
41+ This is a basic example of subbing citation keys for inline references
42+ within a table so that it can be rendered as is after the changes are
43+ made:
2944
3045``` r
3146library(xciter )
3247# # basic example code
3348
34- path_bib <- system.file(" extdata" , " references .bib" , package = " xciter" )
49+ path_bib <- system.file(" extdata" , " NewGraphEnvironment .bib" , package = " xciter" )
3550dat <- data.frame (
3651 id = 1 : 3 ,
3752 bib_keys = c(
3853 " Outside block quotes @busch_etal2011LandscapeLevelModela and in [@woll_etal2017SalmonEcological]" ,
39- " This is many [@busch_etal2011LandscapeLevelModela; @woll_etal2017SalmonEcological; @kirsch_etal2014Fishinventory ]" ,
54+ " This is many [@busch_etal2011LandscapeLevelModela; @woll_etal2017SalmonEcological; @kirsch_etal2014Fishinventorya ]" ,
4055 " this is a failed key @key3"
4156 )
4257)
@@ -51,3 +66,23 @@ print(result)
5166# > 2 This is many (Busch et al. 2011; Woll, Albert, and Whited 2017; Kirsch, Buckwalter, and Reed 2014)
5267# > 3 this is a failed key (key3?)
5368```
69+
70+ This is a basic example of checking if the citation keys within a
71+ bookdown document are found within a specified ` .bib ` file.
72+
73+ ``` r
74+ key_missing <- xct_bib_keys_missing(path_bib , " kirsch_etal2014Fishinventory" )
75+ # > ! The following citations were not found in the BibTeX file:
76+ # > [1] "kirsch_etal2014Fishinventory"
77+ ```
78+
79+ <br >
80+
81+ This is an example of how to search for the closest match for an
82+ unmatched key.
83+
84+ ``` r
85+ xct_keys_guess_match(key_missing , keys_bib = xct_bib_keys_extract(path_bib ))
86+ # > key_missing key_missing_guess_match
87+ # > 1 kirsch_etal2014Fishinventory kirsch_etal2014Fishinventorya
88+ ```
0 commit comments