Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package citations and references #19

Open
friendly opened this issue Oct 24, 2024 · 0 comments
Open

Package citations and references #19

friendly opened this issue Oct 24, 2024 · 0 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@friendly
Copy link
Owner

friendly commented Oct 24, 2024

In the book I refer to the first use of a package in the text with the package name in bold and
citation: **lattice** package [@R-lattice]; thereafter, I just use lattice.
All packages used in the book have their BibTeX references in bib/packages.bib, and the keys are all of the form R-pkgname.

I would prefer to have the package name appear in (a) a distinctive font, (b) in color if possible,
(c) be able to generate the citations as needed, (d) and automatically generate index entries.

I describe this in `test/package-citations.html, also rendered in PDF.

I have a first go at a function pkg() which I intend to use inline as, r pkg(package), and to generate the citations
using r pkg(package, cite=TRUE), which should also generate index entries in LaTeX. (This function, and one to colorize() text are defined in R/common.R, which is source()d in every chapter file.)

My attempts to change the font or color of the package name now fail. How can I fix this?

pkg <- function(package, cite=FALSE, color="brown") {
  pkgname <- if(is.null(color)) package else colorize(package, color)
  ref <- paste0("`", pkgname, "`")
  if (cite) ref <- paste0(ref, " [@R-", package, "]")
  if (knitr::is_latex_output()) {
    ref <- paste0(ref, "\\index{`",package, "`}\\index{package!`", package, "`}")
      }

  ref
}
@friendly friendly added the help wanted Extra attention is needed label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants