The package can be loaded in a code chunk within the Rmarkdown file:
library(namedropR)
As sample references we’ll use three fictional BibTeX entries stored in a file called ‘library.bib’.
@article{doe2024,
title = {When Inspiration Meets Passion: Translating Ideas into Practice},
author = {Doe, John and Sample, Anne},
year = {2024},
journal = {Journal of Unneccessary R Packages},
url = {https://nucleic-acid.github.io/namedropR/},
}
@article{active2021,
title = {Where Frustration Meets Essentiality: An Introduction to Unit Testing},
author = {Active, Alice and Boring, Bob},
year = {2021},
journal = {Journal of Unneccessary R Packages},
url = {https://nucleic-acid.github.io/namedropR/},
}
@article{fantastic1998,
title = {Why Writing Packages Matters: Sharing is Caring},
author = {Fantastic, Flora and Curious, Claire},
year = {1998},
journal = {Journal of Unneccessary R Packages},
url = {https://nucleic-acid.github.io/namedropR/},
}
The file can be read and converted to a tibble using the {bib2df} package like this:
# load required packages
library(bib2df)
library(dplyr)
# read the file
<- system.file("testdata", "library.bib", package = "namedropR")
bib_file <- bib2df::bib2df(bib_file) %>%
bib select(BIBTEXKEY, AUTHOR, YEAR, TITLE, JOURNAL, URL)
You can provide the following arguments to drop_name()
to specify custom style elements:
These options accept CSS values as strings, such as e.g.
#FF00AA
If you want to specify all options, you can do so (see final example below). To avoid long function calls, you can also chose one of the predefined styles and override the style of selected items to match your taste:
::drop_name(
namedropR
bib,cite_key = "fantastic1998",
export_as = "png",
style = "clean",
author_color = "FF00FF",
title_font = "Playfair Display"
)
Note: The fonts are not being loaded by the function call. {namedropR} assumes, you have the fonts installed. This requires you to install the desired font on your system before. If the renderer doesn’t find the font on your system, a default font is used.
Note: Similarly incorrect CSS options do not throw any errors, but may result in unexpected behavior / styling, mostly falling back to defaults. Please check, whether your custom options work on single bibliography items before bulk-styling many.
You can specify the QR code size (as integer, representing the width in pixels) and the foreground color as hex code.
::drop_name(
namedropR
bib,cite_key = "fantastic1998",
export_as = "png",
style = "modern",
qr_size = 150,
qr_color = "#AAAAAA"
)
An example using all possible custom styling options would be:
::drop_name(
namedropR
bib,cite_key = "fantastic1998",
export_as = "png",
author_color = "#FF0000",
author_weight = "normal",
author_size = "12pt",
author_font = "Roboto",
title_color = "#00FF00",
title_weight = "bold",
title_size = "2.5rem",
title_font = "Playfair Display",
journal_color = "#0000FF",
journal_weight = "bold",
journal_size = "8pt",
journal_font = "Fira Sans",
qr_size = 150,
qr_color = "#AAAAAA"
)