From edeb428e827b46bd2a6f913847bbc1000fd9a4f5 Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Sun, 4 Feb 2018 21:34:49 +0100 Subject: [PATCH 1/7] allow more control over localizaton from template --- template.tex | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/template.tex b/template.tex index b43fb24..5d1136a 100644 --- a/template.tex +++ b/template.tex @@ -61,12 +61,32 @@ \setlist[itemize]{leftmargin=0.5cm} % Reduce list left indent \setlength{\tabcolsep}{9pt} % Larger gutter between columns +% MACROS +\newcommand{\total}{\STtag{totalsum}} +% MACROS:Locale +$if(locale.commasep)$\STsetdecimalsep{,}$endif$ % Use comma as decimal separator +\newcommand{\localInvoice} +{$if(locale.invoice)$$locale.invoice$$else$Invoice$endif$} +\newcommand{\localDescription} +{$if(locale.description)$$locale.description$$else$Description$endif$} +\newcommand{\localItemPos} +{$if(locale.itemPos)$$locale.itemPos$$else$Pos.$endif$} +\newcommand{\localPriceIn} +{$if(locale.price)$$locale.price$$else$Price in$endif$} +\newcommand{\localSubtotal} +{$if(locale.subtotal)$$locale.subtotal$$else$Subtotal$endif$} +\newcommand{\localTotal} +{$if(locale.total)$$locale.total$$else$Total$endif$} +\newcommand{\localVAT} +{$if(locale.VAT)$$locale.VAT$$else$VAT$endif$} + % LANGUAGE %-------------------------------- -$if(lang)$ \usepackage{polyglossia} -\setmainlanguage{$lang$} +$if(language)$ +\usepackage[$language$]{isodate} +\setmainlanguage{$language$} $endif$ % PDF SETUP @@ -109,33 +129,31 @@ \begin{flushright} \small - $city$, \today + $city$, $if(date)$$date$$else$\numdate\today$endif$ \end{flushright} \vspace{1em} -\section*{\textsc{Invoice} \textsc{\#$invoice-nr$}} +\section*{\textsc{\localInvoice} \textsc{$invoice-nr$}} \footnotesize \newcounter{pos} \setcounter{pos}{0} \STautoround*{2} % Get spreadtab to always display the decimal part -$if(commasep)$\STsetdecimalsep{,}$endif$ % Use comma as decimal separator - \begin{spreadtab}{{tabular}[t t t]{lp{8.2cm}r}} \hdashline[1pt/1pt] - @ \noalign{\vskip 2mm} \textbf{Pos.} & @ \textbf{Description} & @ \textbf{Prices in $currency$} \\ \hline - $for(service)$ @ \noalign{\vskip 2mm} \refstepcounter{pos} \thepos - & @ $service.description$ - $if(service.details)$\newline \begin{itemize} - $for(service.details)$\scriptsize \item $service.details$ + @ \noalign{\vskip 2mm} \textbf{\localItemPos} & @ \textbf{\localDescription} & @ \textbf{\localPriceIn~$currency$} \\ \hline + $for(service)$ @ \noalign{\vskip 2mm} \refstepcounter{pos} \thepos + & @ $service.description$ + $if(service.details)$\newline \begin{itemize} + $for(service.details)$\scriptsize \item $service.details$ $endfor$ \end{itemize} $endif$ & $service.price$\\$endfor$ \noalign{\vskip 2mm} \hline $if(VAT)$ - @ & @ \multicolumn{1}{r}{Subtotal:} & :={sum(c1:[0,-1])} \\ \hhline{~~-} - @ & @ \multicolumn{1}{r}{VAT $VAT$\%:} & $VAT$/100*[0,-1] \\ \hhline{~~-} + @ & @ \multicolumn{1}{r}{\localSubtotal:} & :={sum(c1:[0,-1])} \\ \hhline{~~-} + @ & @ \multicolumn{1}{r}{\localVAT $VAT$\%:} & $VAT$/100*[0,-1] \\ \hhline{~~-} $endif$ - @ & @ \multicolumn{1}{r}{\textbf{Total:}} & \textbf{:={$if(VAT)$[0,-1]+[0,-2]$else$sum(c1:[0,-1])$endif$}} \\ \hhline{~~-} + @ & @ \multicolumn{1}{r}{\textbf{\localTotal:}} & \textbf{:={$if(VAT)$[0,-1]+[0,-2]tag(totalsum)$else$sum(c1:[0,-1])tag(totalsum)$endif$}} \\ \hhline{~~-} \end{spreadtab} @@ -149,4 +167,8 @@ \section*{\textsc{Invoice} \textsc{\#$invoice-nr$}} $author$ +$for(signature)$ + \includegraphics[width=3cm]{$signature$} +$endfor$ + \end{document} From b9d4ee31b4f3640d8031ef4024affcc7bbdc463d Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Sun, 4 Feb 2018 21:35:07 +0100 Subject: [PATCH 2/7] add examples for locale settings --- details.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/details.yml b/details.yml index 485be6f..b129cc2 100644 --- a/details.yml +++ b/details.yml @@ -2,6 +2,7 @@ invoice-nr: 2015-11-04 author: Max Mustermann city: Musterstadt +date: \today # set custom date here from: - Musterstraße 37 - 12345 Musterstadt @@ -24,22 +25,34 @@ service: - description: The last service provided price: 65.00 -closingnote: | +closingnote: | # use \total to refer to the calculated sum Please transfer the due amount to the following bank account within the next 14 days: - - Mustermann GmbH - Kreditinstitut: Deutsche Postbank AG - IBAN: DE18 3601 0043 9999 9999 99 - BIC: PBNKDEFF + + Mustermann GmbH + Kreditinstitut: Deutsche Postbank AG + IBAN: DE18 3601 0043 9999 9999 99 + BIC: PBNKDEFF We really appreciate your business and look forward to future projects together. Best regards, +signature: +# put path to an image of your signature here + # Invoice settings currency: EUR -# commasep: true -lang: english + +# Locale settings +language: english +locale: + commasep: true + VAT: MwSt. + price: Preis in + description: Beschreibung + itemPos: Nr. + subtotal: Netto + total: Brutto # Typography and layout seriffont: Hoefler Text From 4345a14752c5bcdd59e860052a974f431bca42b0 Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Sun, 4 Feb 2018 21:43:14 +0100 Subject: [PATCH 3/7] allow including of signatures --- template.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/template.tex b/template.tex index 5d1136a..979b54e 100644 --- a/template.tex +++ b/template.tex @@ -61,6 +61,9 @@ \setlist[itemize]{leftmargin=0.5cm} % Reduce list left indent \setlength{\tabcolsep}{9pt} % Larger gutter between columns +% allow including of signatures +\usepackage{graphicx} + % MACROS \newcommand{\total}{\STtag{totalsum}} % MACROS:Locale From f563c966e14528abc84c89d8a4791acace01c78c Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Sun, 4 Feb 2018 21:58:07 +0100 Subject: [PATCH 4/7] fix readme --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d147ff..62c1739 100644 --- a/README.md +++ b/README.md @@ -66,21 +66,35 @@ Although I didn't test it, you can probably use this on Windows, too. Both [Pand ## Available settings +- **`date`**: set a specific - **`VAT`**: Your VAT rate. - **`currency`**: Your currency code (USD, EUR...) -- **`commasep`**: Set to `true` to use a comma as decimal separator. This is for display purposes only—remember to always use a dot to set the prices in your YAML file. -- **`lang`**: Sets the main language through the `polyglossia` package. This is important for proper hyphenation and date format. +- **`language`**: Sets the main language through the `polyglossia` package. This is important for proper hyphenation and date format. - **`seriffont`**: Used for the heading and the sender address. Hoefler Text is the default, but every font installed on your system should work out of the box (thanks, XeTeX!) - **`sansfont`**: Used to render the recipient address, the table and the closing note. Defaults to Helvetica Neue. - **`fontsize`**: Possible values here are 10pt, 11pt and 12pt. - **`geometry`**: A string that sets the margins through `geometry`. Read [this](https://www.sharelatex.com/learn/Page_size_and_margins) to learn how this package works. - **`closingnote`**: This gets printed after the table as a closing note. Use it to provide your bank details and a thank you message. - **`letterhead`**: include custom letterhead in the PDF (see below). +- **`locale`**: configure strings and other locale related options. All strings default to their english variant + - **`commasep`**: Set to `true` to use a comma as decimal separator. This is for display purposes only—remember to always use a dot to set the prices in your YAML file. + - **`VAT`**: Set your local word for VAT here, e.g. MwSt. in geman + - **`price`**: Your local phrase for "price in" + - **`description`**: you get the idea ain't you? ;) + - **`subtotal`**: Netto + - **`total`**: Brutto + - **`itemPos`**: You can use `\phantom` to make shure the string is not displayed and not substituted by the english default value ## Custom letterhead If you have already designed your own letterhead and want to use it with this template, including it should be easy enough. Set the `letterhead` option to `true` to activate the `wallpaper` package in the template. `wallpaper` will look for a file named `letterhead.pdf` in the project root folder and print it on the PDF before compiling the document. Change the fonts to match the ones in your letterhead, adjust the margins with `geometry` and you should be all set. + + + + + + ## Recommended readings - [Typesetting Automation](http://mrzool.cc/writing/typesetting-automation/), my article about this project with in-depth instructions and some suggestions for an ideal workflow. From 93f6509191c80d10496d9880d25db51da714039c Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Mon, 26 Nov 2018 00:08:41 +0100 Subject: [PATCH 5/7] Use datetime2 for date printing and formatting --- template.tex | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/template.tex b/template.tex index 979b54e..5cf3fff 100644 --- a/template.tex +++ b/template.tex @@ -1,8 +1,7 @@ %!TEX TS-program = xelatex %!TEX encoding = UTF-8 Unicode -\documentclass[$fontsize$, a4paper]{article} - +\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper$endif$]{article} % LAYOUT %-------------------------------- \usepackage{geometry} @@ -87,9 +86,14 @@ % LANGUAGE %-------------------------------- \usepackage{polyglossia} -$if(language)$ -\usepackage[$language$]{isodate} -\setmainlanguage{$language$} +\setmainlanguage{$polyglossia-lang$} +\usepackage[ + useregional, + $if(datetime2)$ + $datetime2$ + $endif$]{datetime2} +$if(datestyle)$ +\DTMsetstyle{$datestyle$} $endif$ % PDF SETUP @@ -106,12 +110,6 @@ urlcolor=blue } -% To display custom date -% \usepackage[nodayofweek]{datetime} -% \newdate{date}{01}{12}{1867} -% \date{\displaydate{date}} -% Use this instead of \today: % \displaydate{date} - % DOCUMENT %-------------------------------- \begin{document} @@ -132,7 +130,7 @@ \begin{flushright} \small - $city$, $if(date)$$date$$else$\numdate\today$endif$ + $city$, $if(date)$\date{$date$}$else$\Today$endif$ \end{flushright} \vspace{1em} From 4a0d25b7096177bd992d2280cc7de99ce8b392f3 Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Mon, 26 Nov 2018 00:09:35 +0100 Subject: [PATCH 6/7] Fix whitespace --- template.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/template.tex b/template.tex index 5cf3fff..6c8a31e 100644 --- a/template.tex +++ b/template.tex @@ -4,13 +4,13 @@ \documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper$endif$]{article} % LAYOUT %-------------------------------- -\usepackage{geometry} +\usepackage{geometry} \geometry{$geometry$} % No page numbers \pagenumbering{gobble} -% Left align +% Left aligngit \usepackage[document]{ragged2e} $if(letterhead)$ @@ -21,7 +21,7 @@ % TYPOGRAPHY %-------------------------------- -\usepackage{fontspec} +\usepackage{fontspec} \usepackage{xunicode} \usepackage{xltxtra} From b63a20704b59b99dba1bec99ac49a8e7baad1c75 Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Mon, 26 Nov 2018 00:10:14 +0100 Subject: [PATCH 7/7] Tweak makefile --- makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index f5ed9b4..e668d87 100644 --- a/makefile +++ b/makefile @@ -1,10 +1,12 @@ -TEX = pandoc -src = template.tex details.yml +PANDOC = /usr/bin/env pandoc +TEMPLATE = template.tex +src = details.yml +out = output.pdf FLAGS = --pdf-engine=xelatex -output.pdf : $(src) - $(TEX) $(filter-out $<,$^ ) -o $@ --template=$< $(FLAGS) +render : $(src) + $(PANDOC) -o $(out) --template=$(TEMPLATE) $(FLAGS) --standalone -- $(src) .PHONY: clean clean : - rm output.pdf + rm $(name)