Format citations across academic styles (APA 7, Chicago, Vancouver, IEEE) using CSL processors and R tooling. Convert between citation styles, generate in-text citations and reference lists, and validate formatting against style guides using citeproc, knitcitations, and Quarto's built-in citation engine. Use when rendering a Quarto or R Markdown document with formatted citations, converting a bibliography between citation styles, generating a standalone reference list, or setting up citation infrastructure for a multi-document project.
Instrucciones de origen · Vista previa de solo lectura
name
format-citations
locale
wenyan-ultra
source_locale
en
source_commit
82c77053
translator
Julius Brussee homage — caveman
translation_date
2026-04-24
description
Format citations across academic styles (APA 7, Chicago, Vancouver, IEEE) using CSL processors and R tooling. Convert between citation styles, generate in-text citations and reference lists, and validate formatting against style guides using citeproc, knitcitations, and Quarto's built-in citation engine. Use when rendering a Quarto or R Markdown document with formatted citations, converting a bibliography between citation styles, generating a standalone reference list, or setting up citation infrastructure for a multi-document project.
# Common CSL styles and their repository names
csl_styles <-list(
apa ="apa.csl",
chicago ="chicago-author-date.csl",
vancouver ="vancouver.csl",
ieee ="ieee.csl",
nature ="nature.csl",
harvard ="harvard-cite-them-right.csl",
mla ="modern-language-association.csl")
download_csl <-function(style, dest_dir ="."){
base_url <-"https://raw.githubusercontent.com/citation-style-language/styles/master"
filename <- csl_styles[[style]]if(is.null(filename)) stop(sprintf("Unknown style: %s", style))
dest <- file.path(dest_dir, filename)
utils::download.file(
url = sprintf("%s/%s", base_url, filename),
destfile = dest, quiet =TRUE)
message(sprintf("Downloaded %s to %s", filename, dest))
dest
}# Download APA 7 style
download_csl("apa")
得:CSL 文已下至項目錄。
敗:察網連。CSL GitHub 庫含 10,000+ 式。離線用→項中捆所需 CSL 文。
四:書文中引
於文體用 Pandoc 引語:
<!-- Single citation -->
According to @Smith2020, the method improves accuracy.
<!-- Parenthetical citation -->
The method improves accuracy [@Smith2020].
<!-- Multiple citations -->
Several studies confirm this [@Smith2020; @Jones2021; @Lee2022].
<!-- Citation with page number -->
As noted by @Smith2020 [p. 42], the results are significant.
<!-- Suppress author name -->
The results are significant [-@Smith2020].
<!-- Citation with prefix -->
[see @Smith2020, pp. 42-45; also @Jones2021, ch. 3]
得:Pandoc/Quarto 渲為標式之正擬引(如 APA 之 (Smith, 2020),Chicago 之 (Smith 2020))。
五:以 R 生獨參列
# Using RefManageR to print formatted references
library(RefManageR)
BibOptions(style ="text", bib.style ="authoryear", sorting ="nyt")
bib <- ReadBib("references.bib", check =FALSE)# Print all entries in text format
print(bib)# Format specific entries
print(bib[author ="Smith"])# Generate markdown reference list programmatically
format_reference_list <-function(bib, style ="apa"){
BibOptions(style ="text", bib.style ="authoryear")
entries <- capture.output(print(bib))
entries <- entries[nzchar(trimws(entries))]
paste(sprintf("- %s", entries), collapse ="\n")}
cat(format_reference_list(bib))
得:擬參列印於控或捕為字向為後處。
六:引式間轉
# Render the same document in different styles
styles <-c("apa","chicago","ieee")for(style in styles){
csl_file <- download_csl(style)
output_file <- sprintf("output_%s.html", style)
rmarkdown::render(
input ="document.Rmd",
output_file = output_file,
params =list(csl = csl_file),
quiet =TRUE)
message(sprintf("Rendered %s with %s style", output_file, style))}
Quarto:
quarto render document.qmd --metadata csl:apa.csl -o output_apa.html
quarto render document.qmd --metadata csl:ieee.csl -o output_ieee.html