Skip to content

Commit

Permalink
feat: add ps, encl, cc fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanouil committed Aug 21, 2022
1 parent d809545 commit e206832
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 39 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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 <https://mcanouil.github.io/quarto-letter/>.
10 changes: 6 additions & 4 deletions _extensions/letter/_extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 12 additions & 1 deletion _extensions/letter/partials/after-body.tex
Original file line number Diff line number Diff line change
@@ -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}
4 changes: 4 additions & 0 deletions _extensions/letter/partials/before-body.tex
Original file line number Diff line number Diff line change
@@ -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$
42 changes: 12 additions & 30 deletions template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit e206832

Please sign in to comment.