From e2068328c42ce80c7bac351fc2717ecf212202df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 21 Aug 2022 21:24:50 +0200 Subject: [PATCH] feat: add ps, encl, cc fields --- README.md | 6 +-- _extensions/letter/_extension.yml | 10 +++-- _extensions/letter/partials/after-body.tex | 13 ++++++- _extensions/letter/partials/before-body.tex | 4 ++ template.qmd | 42 ++++++--------------- 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index d528ae0..90e5b81 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Letter Format Template -This is a **WIP** Quarto template that assists you in creating a manuscript using the letter format. +This is a Quarto template that assists you in creating a manuscript using the letter format. ## Creating a New Letter @@ -34,9 +34,7 @@ quarto render template.qmd --to letter-pdf or in your document yaml ```yaml -format: - letter-pdf: - keep-tex: true +format: letter-pdf ``` You can view a preview of the rendered template at . diff --git a/_extensions/letter/_extension.yml b/_extensions/letter/_extension.yml index 12d41bc..c7c1f17 100644 --- a/_extensions/letter/_extension.yml +++ b/_extensions/letter/_extension.yml @@ -3,14 +3,16 @@ author: Mickaƫl Canouil version: 0.1.0 contributes: formats: + common: + date: today + date-format: long pdf: - recipient: "recipient" documentclass: letter geometry: - - "top=1in" + - "margin=1in" - "bottom=1in" - - "left=2in" - - "right=2in" + - "left=1in" + - "right=1in" colorlinks: true template-partials: - "partials/before-body.tex" diff --git a/_extensions/letter/partials/after-body.tex b/_extensions/letter/partials/after-body.tex index 84733a6..cd3ba26 100644 --- a/_extensions/letter/partials/after-body.tex +++ b/_extensions/letter/partials/after-body.tex @@ -1,3 +1,14 @@ +$if(closing)$ \closing{$closing$} - +$endif$ +\vfill +$if(encl)$ +\encl{$for(encl)$$encl$$sep$\\$endfor$} +$endif$ +$if(cc)$ +\cc{$for(cc)$$cc$$sep$\\$endfor$} +$endif$ +$if(ps)$ +\ps{$ps$} +$endif$ \end{letter} diff --git a/_extensions/letter/partials/before-body.tex b/_extensions/letter/partials/before-body.tex index 6565476..8cf3b19 100644 --- a/_extensions/letter/partials/before-body.tex +++ b/_extensions/letter/partials/before-body.tex @@ -1,4 +1,8 @@ +$if(author)$ \signature{$author$} \address{${ by-author:_authors.tex() }} +$endif$ \begin{letter}{$for(address)$$address$$sep$\\$endfor$$if(subject)$\\ ~ \\Subject: $subject$$endif$} +$if(opening)$ \opening{$opening$} +$endif$ diff --git a/template.qmd b/template.qmd index df75da6..f6bc245 100644 --- a/template.qmd +++ b/template.qmd @@ -16,37 +16,19 @@ address: subject: collaboration opening: "Dear Sir or Madam," closing: "Yours Faithfully," -format: - letter-pdf: - keep-tex: true +cc: + - Recipient 1 + - Recipient 2 +encl: + - Enclosure 1 + - Enclosure 2 +ps: | + PS: Lorem ipsum dolor sit amet, *consectetur* adipiscing elit. +format: letter-pdf --- -I am writing to you about a project I am doing. I hope you like this table: +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin mollis dolor vitae tristique eleifend. Quisque non ipsum sit amet velit malesuada consectetur. Praesent vel facilisis leo. Sed facilisis varius orci, ut aliquam lorem malesuada in. Morbi nec purus at nisi fringilla varius non ut dui. Pellentesque bibendum sapien velit. Nulla purus justo, congue eget enim a, elementum sollicitudin eros. Cras porta augue ligula, vel adipiscing odio ullamcorper eu. In tincidunt nisi sit amet tincidunt tincidunt. Maecenas elementum neque eget dolor [egestas fringilla](http://example.com): -```{r} -#| echo: false -knitr::kable(mtcars[1:2,]) -``` +> Nullam eget dapibus quam, sit amet sagittis magna. Nam tincidunt, orci ac imperdiet ultricies, neque metus ultrices quam, id gravida augue lacus ac leo. -The figure is also informative. - -```{r} -#| echo: false -#| warning: false -#| fig-height: 2 -library(ggplot2) -df <- data.frame( - gp = factor(rep(letters[1:3], each = 10)), - y = rnorm(30) -) -ds <- do.call(rbind, lapply(split(df, df$gp), function(d) { - data.frame(mean = mean(d$y), sd = sd(d$y), gp = d$gp) -})) -ggplot(df, aes(gp, y)) + - geom_point() + - geom_point(data = ds, aes(y = mean), colour = 'red', size = 3) -``` - -Thank you for your time and consideration. - -I look forward to your reply. +Vestibulum id sodales lectus, sed scelerisque quam. Nullam auctor mi et feugiat commodo. Duis interdum imperdiet nulla, vitae bibendum eros placerat non. Cras ornare, risus in faucibus malesuada, libero sem fringilla quam, ut luctus enim sapien eget dolor.