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 the possibility to define your own.
komaletter(..., keep_tex = FALSE)
Additional arguments to pdf_document
A boolean toggle to select whether intermediate
LaTeX files are to be kept, defaults to FALSE
R Markdown output format to pass to
render
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:
Variable | Description |
author | Writer of the letter. |
return-address | Address of the sender; takes a YAML sequence for a multi-line address. |
address | Name and address of the recipient; takes a YAML sequence. |
date | Custom date; if not specified, current date will be inserted. |
subject | Subject line. |
opening | Text for the salutation. |
closing | Text for the complementary close. |
signature | Typed signature or image placed below closing. |
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:
Variable | Description |
lco | Letter 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. |
lang | Language code according to BCP 47 (e.g. en or en-GB ). |
papersize | Size of paper eg. `a4`, `letter`. |
return-phone | Phone number of sender used in letter head. |
return-email | Email address of sender used in letter head. |
return-url | Website of sender used in letter head. |
place | Sender<U+2019>s place used near date. |
yourref | Addressee<U+2019>s reference as part of reference line. |
yourmail | Date of addressee<U+2019>s referenced mail as part of reference line. |
myref | Sender<U+2019>s reference as part of reference line. |
customer | Customer number as part of reference line. |
invoice | Invoice number as part of reference line. |
cc | Recipients to be carbon-copied; can take a list for multiple recipients. |
encl | List of enclosures. |
ps | Text to be added at the end of the letter as a postscript. |
komaoption | Specify further KOMA options; takes a list (see KOMA-Script documentation). |
The source of the example letter vignettes show several of these options in use.
JJ Allaire, R Foundation, Hadley Wickham, Journal of Statistical Software, Yihui Xie, Ramnath Vaidyanathan, Association for Computing Machinery, Carl Boettiger, Elsevier, Karl Broman, Kirill Mueller, Bastiaan Quast, Randall Pruim, Ben Marwick, Charlotte Wickham, Oliver Keyes and Miao Yu (2017). rticles: Article Formats for R Markdown. R package version 0.4.1. https://cran.r-project.org/package=rticles
JJ Allaire, Joe Cheng, Yihui Xie, Jonathan McPherson, Winston Chang, Jeff Allen, Hadley Wickham, Aron Atkins, Rob Hyndman and Ruben Arslan (2017). rmarkdown: Dynamic Documents for R. R package version 1.6. https://cran.r-project.org/package=rmarkdown
Yihui Xie (2017). knitr: A General-Purpose Package for Dynamic Report Generation in R. R package version 1.17.
Aaron Wolen (2017). pandoc-letter. GitHub Repository. https://github.com/aaronwolen/pandoc-letter.
Dirk Eddelbuettel and Aaron Wolen (2017). linl: 'linl' is not 'Letter'. R package version 0.0.2. https://cran.r-project.org/package=linl
# NOT RUN {
rmarkdown::draft("MyLetter.Rmd", template="pdf", package="komaletter")
rmarkdown::render("MyLetter.Rmd")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab