Skip to content

Commit

Permalink
Template now based on the official LaTeX template of pandoc
Browse files Browse the repository at this point in the history
  • Loading branch information
benedictdudel committed Dec 26, 2022
1 parent 78cb692 commit f1a9c37
Show file tree
Hide file tree
Showing 11 changed files with 724 additions and 132 deletions.
107 changes: 86 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# Pandoc Letter Template (DIN 5008)
# Pandoc Letter Template (Default: DIN 5008)

[Pandoc](https://pandoc.org/) template for writing letters in Markdown and converting them into PDFs
that follow the German national standard DIN 5008 for letter formatting. By using this
template, you can more efficiently create professional-looking letters in a
clean and organized manner. The template is customizable, so you can tailor it
to your specific needs.
Effortlessly write professional letters with the Pandoc Letter Template. Simply create and customize your letters in Markdown and convert them to stunning PDFs with one command. Based on the official [Pandoc LaTeX template](https://github.com/jgm/pandoc/blob/master/data/templates/default.latex) and [`scrlttr2`](https://ftp.rrzn.uni-hannover.de/pub/mirror/tex-archive/macros/latex/contrib/koma-script/doc/scrguide-en.pdf#chapter.4) document class, you can use all the variables supported by the official template, plus additional variables. The template defaults to the German [DIN 5008](https://de.wikipedia.org/wiki/DIN_5008) standard for added convenience. No more tedious design or typesetting work - just easy, beautiful letters for any occasion.

## Preview
## Previews

<p align="center">
<img src="https://github.com/benedu/pandoc-letter/raw/master/example/letter.png" alt="Letter Preview"/>
</p>

## Requirements

- [Pandoc](http://pandoc.org/installing.html)
- [LaTeX](https://latex-project.org/ftp.html)
- [csquotes](https://ctan.org/pkg/csquotes)
|[Minimal](/examples/minimal)|[Invoice](/examples/invoice)|
|:--------------------------:|:--------------------------:|
|<img src="/examples/minimal/letter.png" alt="Minimal Letter Preview"/>|<img src="/examples/invoice/letter.png" alt="Invoice Letter Preview"/>|

## Usage

Expand All @@ -26,23 +16,98 @@ Clone this repository or download the template with the following command:
curl https://raw.githubusercontent.com/benedictdudel/pandoc-letter-din5008/master/letter.latex --create-dirs -o ~/.pandoc/templates/letter.latex
```

Write your letter in markdown, using the provided [`example/letter.md`](https://raw.githubusercontent.com/benedictdudel/pandoc-letter-din5008/master/example/letter.md) file as a
Write your letter in markdown, using one of the provided examples [`examples/minimal/letter.md`](https://raw.githubusercontent.com/benedictdudel/pandoc-letter-din5008/master/examples/minimal/letter.md) file as a
guide. You can download the example `letter.md` file with the following command:

```bash
curl https://raw.githubusercontent.com/benedictdudel/pandoc-letter-din5008/master/example/letter.md -o letter.md
curl https://raw.githubusercontent.com/benedictdudel/pandoc-letter-din5008/master/examples/minimal/letter.md -o letter.md
```

To convert the markdown file to a PDF run:

```bash
pandoc letter.md -s -o letter.pdf --template="letter"
pandoc letter.md -o letter.pdf --template="letter"
```

## Customization

You can customize the look and feel of the generated PDF by modifying the
variables. See [`example/letter.md`](https://raw.githubusercontent.com/benedictdudel/pandoc-letter-din5008/master/example/letter.md) for a full list of available variables.
There are two ways to customize the letter. You can use the exported KOMA-variables via yaml or use a custom `lco` (letter class options) file which you can reference in your yaml metadata.

### 1. Letter Class Options (`.lco`)

Create a new file `defaults.lco` with the following content:
```latex
\ProvidesFile{defaults.lco}
\setkomavar{opening}{Dear Sir or Madam,}
\setkomavar{closing}{Sincerely,}
```

Reference the `defaults.lco` file within you yaml metadata:
```yaml
---
letteroption:
- defaults
---
```

### 2. Variables

The template supports all variables from the official LaTeX template plus additional variables from `scrlttr2`. Those variables are:

|name |description |
|--------------------|-------------------------------------------------------|
|addresseeimage|commands used to print the postpaid postmark for the addrfield backgroundimage option or the postpaid address for the addrfield=image option|
|backaddress|return address for window envelopes|
|backaddressseparator|separator within the return address|
|closing|concluding text|
|ccseparator|separator between title of additional addresses (cc list) and additional addresses|
|cc|distribution list|
|customer|customer number|
|customername|name of customer number|
|date|date|
|datename|name of date|
|emailseparator|separator between email name and email address|
|enclseparator|separator between title of enclosure and enclosures|
|faxseparator|separator between title of fax and fax number|
|firstfooter|footer of the letterhead page|
|firsthead|header of the letterhead page|
|fromaddress|sender’s address without sender name|
|fromalign|where the sender information should be placed on the first page|
|frombank|sender’s bank details|
|fromemail|sender’s e-mail|
|fromfax|sender’s fax number|
|fromlogo|commands for inserting the sender’s logo|
|frommobilephone|sender’s mobile telephone number|
|fromname|complete name of sender|
|fromphone|sender’s telephone number|
|fromurl|URL of the sender, e. g. of the sender’s homepage|
|fromzipcode|ZIP code (postal code) of the sender for the postpaid postmark of the addrfield=PP option|
|invoice|invoice number|
|invoicename|name of invoice number|
|letteroption|to load lco files|
|location|extra details of the sender|
|myref|sender’s reference|
|nextfoot|footer using page style headings or myheadings|
|nexthead|header using page style headings or myheadings|
|opening|salutation|
|phoneseparator|separator between title of telephone and telephone number|
|place|sender’s location; used next to date|
|placeseparator|separator between location and date|
|PPdatamatrix|command to print the data array for the addrfield=PP option|
|PPcode|commands for the sender’s identification code for the addrfield=PP option|
|signature|signature annotation beneath the closing text of the letter|
|specialmail|delivery method|
|subject|letter’s subject|
|subjectseparator|separator between subject title and subject|
|title|letter title|
|toaddress|address of recipient without recipient name|
|toname|complete name of recipient|
|yourmail|date of recipient’s referenced mail|
|yourmailname|name of date of recipient’s referenced mail|
|yourref|recipient’s reference|
|yourrefname|name of the recipient’s reference|
|zipcodeseparator|separator between the title of ZIP code (postal code) and the code itself|

## Contact

Expand Down
39 changes: 0 additions & 39 deletions example/letter.md

This file was deleted.

Binary file removed example/letter.pdf
Binary file not shown.
Binary file removed example/letter.png
Binary file not shown.
30 changes: 30 additions & 0 deletions examples/invoice/letter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
lang: de
backaddress: Erika Musterfrau, Musterstraße 1, 12345 Musterstadt
fromname: Erika Musterfrau
fromaddress: |
Musterstraße 1
12345 Musterstadt
place: Musterstadt
to: |
Musterfirma GmbH
Max Mustermann
Musterstraße 2
12345 Musterstadt
date: 01.01.2023
subject: Musterbrief
signature: Erika Musterfrau
invoice: 123456789
...

vielen Dank für Ihren Auftrag. Bitte überweisen Sie den im Folgenden aufgeführten Rechnungsbetrag innerhalb von 14 Tagen auf das angegebene Konto.

| **Beschreibung** | **Menge** | **Preis St.** | **Preis Gesamt** |
| --------------------- | --------- | ------------- | ---------------- |
| Software-Entwicklung | 4 | € 100 | € 400 |
| Software-Installation | 1 | € 50 | € 50 |
| --------------------- | ----- | --------- | ------------ |
| Zwischensumme | | | € 450 |
| _MwSt. 19%_ | | | _€ 85,5_ |
| --------------------- | ----- | --------- | ------------ |
| **Gesamt** | | | **€ 535,5** |
Binary file added examples/invoice/letter.pdf
Binary file not shown.
Binary file added examples/invoice/letter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions examples/minimal/letter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
backaddress: Erika Musterfrau, Musterstraße 1, 12345 Musterstadt
fromname: Erika Musterfrau
fromaddress: |
Musterstraße 1
12345 Musterstadt
place: Musterstadt
to: |
Musterfirma GmbH
Max Mustermann
Musterstraße 2
12345 Musterstadt
date: 01.01.2023
subject: Musterbrief
signature: Erika Musterfrau
...
Nostrud ullamco do elit ullamco. Tempor culpa id minim eiusmod labore in fugiat anim anim cupidatat est. Ipsum culpa in labore ea minim nisi amet. Fugiat aute duis non ut aliqua ex. Irure id nulla amet do nostrud commodo ea aliqua non eu.

Do duis voluptate occaecat mollit laborum ad id proident culpa sit. Fugiat labore qui magna occaecat ex amet nisi ipsum eiusmod commodo minim. Ea culpa voluptate est laborum in culpa.

Esse incididunt consequat Lorem nostrud ea enim cupidatat occaecat. Commodo ut fugiat magna nulla. Id consectetur minim laborum id laboris quis amet. Veniam ipsum id culpa eiusmod id deserunt laboris cupidatat quis duis dolor sit. Do culpa veniam laboris aute ipsum in.
Binary file added examples/minimal/letter.pdf
Binary file not shown.
Binary file added examples/minimal/letter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f1a9c37

Please sign in to comment.