cover_letter: Render a cover letter

View source: R/render.R

cover_letterR Documentation

Render a cover letter

Description

Render a two-column cover letter to self-contained HTML or PDF. The narrow left column holds the sender's details, while the letter remains the visual foreground in the wider right column.

Usage

cover_letter(
  input,
  output = NULL,
  author = NULL,
  address = NULL,
  phone = NULL,
  email = NULL,
  website = NULL,
  date = NULL,
  greeting = NULL,
  font_family = NULL,
  google_font = NULL,
  font_files = NULL,
  font_size = NULL,
  font_scale = NULL,
  ligatures = NULL,
  line_height = NULL,
  paragraph_spacing = NULL,
  section_spacing = NULL,
  margins = NULL,
  paper = NULL,
  link_color = NULL,
  paged = NULL,
  keep_html = FALSE,
  browser = NULL,
  envir = parent.frame()
)

Arguments

input

Path to a .Rmd or .md source document.

output

Output path ending in .html or .pdf. If NULL, an HTML file is created beside input.

author, address, phone, email, website

Contact metadata. NULL uses the corresponding value in the source document's YAML header.

date, greeting

Letter date and salutation. NULL uses YAML metadata.

font_family

A CSS font-family value. For example, "Charter, Georgia, serif".

google_font

A Google Fonts family name or a full Google Fonts CSS URL. This is an explicit online resource and is never used by default. A family name loads its default face; pass a full URL plus the matching font_family when specific axes or weights are required.

font_files

A named character vector or list of local font files. Names may be regular, italic, bold, and bold_italic. Relative paths are resolved from the source document. Fonts are embedded in the HTML.

font_size

A CSS length such as "11pt".

font_scale

A positive number used to scale font_size. This is useful when replacing a font with different metrics.

ligatures

Whether to enable common and discretionary ligatures. Defaults to FALSE for more predictable text extraction from PDFs.

line_height

A positive unitless CSS line height or CSS length.

paragraph_spacing, section_spacing

CSS lengths controlling vertical rhythm.

margins

Page margins. Supply one to four CSS lengths using standard CSS shorthand order, or numeric values interpreted as inches.

paper

A paper name ("letter", "a4", or "legal") or a two-element vector containing width and height as CSS lengths.

link_color

Any valid CSS color.

paged

Whether the HTML preview should open in a paginated layout. Printing always invokes the packaged pages.js pagination.

keep_html

For PDF output, whether to retain the intermediate HTML beside the PDF.

browser

Path to Chromium, Google Chrome, or Microsoft Edge. NULL lets xfun::browser_print() discover it.

envir

Environment in which R code in input is evaluated.

Value

The normalized output path, invisibly.

Examples

source <- use_cover_letter(tempfile(fileext = ".Rmd"))
cover_letter(source, tempfile(fileext = ".html"))

## Not run: 
# PDF output requires a local Chromium-based browser
cover_letter(source, "cover-letter.pdf")

## End(Not run)

liteformats documentation built on Aug. 5, 2026, 9:08 a.m.