Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
juliantao committed Oct 2, 2022
0 parents commit d18e709
Show file tree
Hide file tree
Showing 14 changed files with 261 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
3 changes: 3 additions & 0 deletions .quartoignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add files / folder that are useful to your repo
# but should not be in the downloaded bundle after `quarto use template`
style-guide
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 quarto-journals

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Opinioned Quarto letter template for the ASU BiG research group

This is a Quarto template that assists you in writing a letter.

The template is based on the LaTex `letter` class, with a customized layout including a logo at the upper left, a name block on the upper right, and an address block at the bottom left of the first page.

This template is the quarto version of the [original `rmd` letter template](https://github.com/juliantao/bigrmd/tree/master/inst/rmarkdown/templates/Letter) for the same research group. Original inspirations were drawn from [Rob Hyndman's MonashEBSTemplates](https://github.com/robjhyndman/MonashEBSTemplates/tree/master/inst/rmarkdown/templates/Letter). I also burrowed some ideas from the [quarto-letter extension](https://github.com/mcanouil/quarto-letter).


## Creating a New Letter

You can use this as a template to create a letter with the ASU default. To do this, use the following command:

```bash
quarto use template juliantao/qletter
```

This will install the extension and create an example qmd file. You'll need to modify the various fields in the YAML header and replace the placeholder logo with your own logo.

After rendering, the pdf file will be saved to the `_output` folder.

An

## Usage

To use the format, you can use the format names `qletter-pdf`. For example:

```bash
quarto render letter.qmd --to qletter-pdf
```

or in your document yaml

```yaml
format: qletter-pdf
```
You can view a preview of the rendered template at <https://github.com/juliantao/quarto-asce/blob/main/style-guide/asce-template.pdf>.
## YAML header and logo file
```yaml
---
fromname: Sender name
fromqualifications: PhD
fromtitle: Professor
fromWWW: sender.com
fromemail: [email protected]
fromphone: (000) 000 000
fromdepartment: Sender Department
frominstitute: Sender Institution
fromaddress: Sender Address in one line
fromsignature: signature
fromlogo: logo
toname: Recipient
toaddress: |
| Recipient address line 1
| Recipient address line 2
subject: Subject Line
opening: Dear Recipient,
closing: Best regards,
cc:
- CC 1
- CC 2
encl:
- Enclosure 1
- Enclosure 2
ps: |
p.s.: something else
spacing: 1.2
format: qletter-pdf
---

```

1. Sender fields starts with `from`
2. Recipient fields starts with `to`
3. You can also set a different `fontfamily`, `fontsize`, and `spacing`. The default fontfamily is `Roboto` and the size is `12pt`
4. The `fromWWW` field is your website **without the starting string of `https://`**
5. Save a copy of your logo and signature files in the directory, **please use a pdf format**
6. The recipient's address can have more than two lines in the `toaddress` field, just add more lines with the syntax `- address`
7. `cc`, `encl`, and `ps` fields are optional.
21 changes: 21 additions & 0 deletions _extensions/qletter/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Mickaël Canouil

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
30 changes: 30 additions & 0 deletions _extensions/qletter/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
title: Personal Letter Format Template
author: Julian Tao
version: 0.1.0
contributes:
formats:
common:
date-format: long
pdf:
documentclass: letter
fontfamily: roboto
fontsize: 12pt
geometry:
- "margin=1in"
colorlinks: true
header-includes: |
\usepackage{fontawesome, setspace}
\usepackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\renewcommand{\familydefault}{\sfdefault}
template-partials:
- "partials/before-body.tex"
- "partials/after-body.tex"
latex-output-dir: _output
format-resources:
- "assets/logo.pdf"
- "assets/signature.pdf"
execute:
echo: false
warning: false
Binary file added _extensions/qletter/assets/logo.pdf
Binary file not shown.
Binary file added _extensions/qletter/assets/signature.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions _extensions/qletter/partials/after-body.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\vspace{4\parskip}%
\closing{$closing$\\[1em]\includegraphics[height=3ex]{$fromsignature$}}
$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}
59 changes: 59 additions & 0 deletions _extensions/qletter/partials/before-body.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
%% Define boxes for letter heads

\newsavebox{\lethdone} %logo
\newsavebox{\lethdtwo} %address
\newsavebox{\headname} %name

% define new page style, including the locations of the letter head boxes
\makeatletter
\def\ps@quartoletter{\begin{textblock}{8}(2,1.5)
\usebox{\lethdone}
\end{textblock}
\begin{textblock}{6}(15,1.5)
\usebox{\headname}
\end{textblock}
\begin{textblock}{10}(2,25.5)\usebox{\lethdtwo}\end{textblock}\def\thepage{}}

\@ifundefined{opening}{}{%
\renewcommand*{\opening}[1]{\thispagestyle{quartoletter}%
{\@date\par}%
\vspace{2\parskip}%
{\raggedright \toname \\ \toaddress \par}%
\vspace{2\parskip}%
#1\par\nobreak}}
\makeatother

% define letterhead logo
\sbox{\lethdone}{\hbox{
\includegraphics[height=1in]{$if(fromlogo)$$fromlogo$$endif$}
}
}

% define letterhead name
\sbox{\headname}{\parbox{4in}{\fontsize{10}{12}\sffamily\color[gray]{0.4}
{\large\textbf{$fromname$}}, $fromqualifications$\\
$fromtitle$\\[1ex]
\begin{tabular}{@{}ll@{}}
\faicon{home} & \href{https://$fromWWW$}{$fromWWW$} \\
\faicon{envelope} & \href{mailto:$fromemail$}{$fromemail$} \\
\faicon{phone} & $fromphone$
\end{tabular}}}

% define letterhead address
\sbox{\lethdtwo}{\hbox{\fontsize{9}{11}\sffamily\color[gray]{0.4}\begin{tabular}{@{}ll@{}}
\multicolumn{2}{@{}l}{$if(fromdepartment)$$fromdepartment$$endif$} \\
\multicolumn{2}{@{}l}{$if(frominstitute)$$frominstitute$$endif$} \\
\multicolumn{2}{@{}l}{$if(fromaddress)$$fromaddress$$endif$} \\[0.2cm]
\end{tabular}}}

$if(date)$
\date{$date$}
$else$
\date{\today}
$endif$

\begin{letter}{$toname$\\$toaddress$$if(subject)$\\ ~ \\Subject: $subject$$endif$}
\setstretch{1}
\vspace*{2ex}
\opening{$opening$}
\setstretch{$spacing$}
Binary file added _output/qletter.pdf
Binary file not shown.
Binary file added logo.pdf
Binary file not shown.
32 changes: 32 additions & 0 deletions qletter.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
fromname: Sender name
fromqualifications: PhD
fromtitle: Professor
fromWWW: sender.com
fromemail: [email protected]
fromphone: (000) 000 000
fromdepartment: Sender Department
frominstitute: Sender Institution
fromaddress: Sender Address in one line
fromsignature: signature
fromlogo: logo
toname: Recipient
toaddress: |
| Recipient address line 1
| Recipient address line 2
subject: Subject Line
opening: Dear Recipient,
closing: Best regards,
cc:
- CC 1
- CC 2
encl:
- Enclosure 1
- Enclosure 2
ps: |
p.s.: something else
spacing: 1.2
format: qletter-pdf
---

Enjoy!
Binary file added signature.pdf
Binary file not shown.

0 comments on commit d18e709

Please sign in to comment.