Skip to contents

A format for LaTeX letters via R Markdown using the KOMA-Script class 'scrlttr2'. It provides layouts for many different window envelope types (German, US, French, Japanese, ...) and lets you define customized layouts.

Usage

komaletter(..., keep_tex = FALSE)

Arguments

...

Additional arguments to rmarkdown::pdf_document()

keep_tex

A boolean toggle to select whether intermediate LaTeX files are to be kept, defaults to FALSE

Value

R Markdown output to pass to rmarkdown::render()

Letter features

Various aspects of the letter can be customized via the following variables in the R Markdown document metadata (aka YAML header).

Although it rarely makes sense to write a letter without sender and recipient, a komaletter can be constructed by merely specifying the output format. All other variables are optional.

Most commonly used variables:

VariableDescription
authorWriter of the letter.
return-addressAddress of the sender; takes a list for a multi-line address.
addressName and address of the recipient; takes a list.
dateCustom date; if not specified, current date will be inserted.
subjectSubject line.
openingText for the salutation.
closingText for the complementary close, like: Best regards.
signatureText (e.g. your name) or an image of your signature with "\\includegraphics{sig.png}".
signature-beforeAdjust vertical space between closing and signature by specifying a length such as 2mm or "0.5\\baselineskip".

All variables understood by rmarkdown's pdf_document format may be used in addition to the komaletter variables defined in the following table to further customize your letter. For modifications of the layout please refer to the vignette "Introduction to komaletter".

Further variables defined by komaletter:

VariableDescription
lcoLetter Class Option File. Either name of a standard KOMA-Script LCO (e.g. DIN, SN, ) or path to custom LCO. If not specified, the maintainersDelight.lco will be used.
langLanguage code according to BCP 47 (e.g. en or en-GB).
papersizeSize of paper eg. a4, letter.
return-phonePhone number of sender used in letter head.
return-emailEmail address of sender used in letter head.
return-urlWebsite of sender used in letter head.
return-shortShorter version of return address only used in window (see vignette letter_example4).
placeSender’s place used near date.
yourrefAddressee’s reference as part of reference line.
yourmailDate of addressee’s referenced mail as part of reference line.
myrefSender’s reference as part of reference line.
customerCustomer number as part of reference line.
invoiceInvoice number as part of reference line.
ccRecipients to be carbon-copied; can take a list.
enclList of enclosures.
psText to be added at the end of the letter as a postscript.
inline-linksIf true, do standard inline hyperlinks rather than footnotes (styling is author's job, cf. vignette letter_example2).
komaoptionSpecify further KOMA options; takes a list (see KOMA-Script documentation).
parskipDefines how to mark new paragraphs, e.g. full, half, off (see KOMA-Script documentation).

The source of the example letter vignettes show several of these options in use.

References

JJ Allaire, Yihui Xie, Jonathan McPherson et al. (2020). rmarkdown: Dynamic Documents for R. R package version 2.6. https://cran.r-project.org/package=rmarkdown

Aaron Wolen and Andrew Dunning (2017). pandoc-letter. GitHub Repository. https://github.com/aaronwolen/pandoc-letter

Markus Kohm (2020). KOMA-Script: A versatile LaTeX \(2_\epsilon\) bundle. https://komascript.de/~mkohm/scrguien.pdf

Examples

if (FALSE) {
rmarkdown::draft("my_letter.Rmd", template="pdf", package="komaletter")
rmarkdown::render("my_letter.Rmd")
}