Skip to contents

Format and print reference entries from the milestones database as text, HTML, or BibTeX.

Usage

print_reference(
  ref,
  result = c("text", "html", "md", "markdown", "bibtex"),
  bibtex = FALSE
)

Arguments

ref

A data frame from the reference() table (one or more rows), or a numeric vector of reference IDs (rid) to look up

result

Output format: "text" for plain text citation (default), "html" for HTML formatted citation, "md" or "markdown" for markdown format, or "bibtex" for BibTeX entry

bibtex

Logical; if TRUE, output as BibTeX entry (overrides result). Default is FALSE.

Value

A character vector with the formatted references (invisibly). The formatted references are also printed to the console.

Details

The function formats references according to the reference type (article, book, incollection, inproceedings). When bibtex = TRUE, it generates a proper BibTeX entry using the bibtexkey field.

If multiple references are provided (either as multiple rows or multiple IDs), each reference is printed on a separate line with a blank line between them.

Examples

if (FALSE) { # \dontrun{
# Get references and print the first one
refs <- reference()
print_reference(refs[1, ])

# Print multiple references
print_reference(refs[1:3, ])

# Print as HTML
print_reference(refs[1, ], result = "html")

# Print as markdown
print_reference(refs[1, ], result = "md")

# Print as BibTeX
print_reference(refs[1, ], bibtex = TRUE)

# Look up by reference ID
print_reference(261)

# Look up multiple IDs
print_reference(c(261, 262, 263))
} # }