matkant_invoice/pandoc/template.tex

160 lines
4.0 KiB
TeX

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[$fontsize$, a4paper]{article}
% LAYOUT
%--------------------------------
\usepackage{geometry}
\geometry{$geometry$}
% No page numbers
\pagenumbering{gobble}
% Left align
\usepackage[document]{ragged2e}
$if(letterhead)$
% To include the letterhead
\usepackage{wallpaper}
\ULCornerWallPaper{1}{letterhead.pdf}
$endif$
$if(draft)$
\usepackage{draftwatermark}
\SetWatermarkText{$drafttext$}
\SetWatermarkScale{1}
$endif$
% TYPOGRAPHY
%--------------------------------
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
% converts LaTeX specials (quotes, dashes etc.) to Unicode
\defaultfontfeatures{Mapping=tex-text}
\setromanfont [Ligatures={Common}, Numbers={OldStyle}]{$seriffont$}
\setsansfont[Scale=0.9]{$sansfont$}
% Set paragraph break
\setlength{\parskip}{1em}
% Custom ampersand
\newcommand{\amper}{{\fontspec[Scale=.95]{$seriffont$}\selectfont\itshape\&}}
$if(seriffont)$
\setmainfont[SmallCapsFeatures={LetterSpace=5,Letters=SmallCaps}]{$seriffont$}
$endif$
$if(sansfont)$
\setsansfont{$sansfont$}
$endif$
% Command required by how Pandoc handles the list conversion
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
% TABLE CUSTOMIZATION
%--------------------------------
\usepackage{spreadtab}
\usepackage[compact]{titlesec} % For customizing title sections
\titlespacing*{\section}{0pt}{3pt}{-7pt} % Remove margin bottom from the title
\usepackage{arydshln} % For the dotted line on the table
\renewcommand{\arraystretch}{1.2} % Apply vertical padding to table cells
\usepackage{hhline} % For single-cell borders
\usepackage{enumitem} % For customizing lists
\setlist{nolistsep} % No whitespace around list items
\setlist[itemize]{leftmargin=0.5cm} % Reduce list left indent
\setlength{\tabcolsep}{9pt} % Larger gutter between columns
% LANGUAGE
%--------------------------------
$if(lang)$
\usepackage{polyglossia}
\setmainlanguage{$lang$}
$endif$
% PDF SETUP
%--------------------------------
\usepackage[xetex, bookmarks, colorlinks, breaklinks]{hyperref}
\hypersetup
{
pdfauthor=$author$,
pdfsubject=Faktura nr. $invoice-nr$,
pdftitle=Faktura nr. $invoice-nr$,
linkcolor=blue,
citecolor=blue,
filecolor=black,
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}
\small
\textsc{\textbf{$author$}}
$for(from)$
\textbullet{} \textsc{$from$}
$endfor$
\vspace{1em}
\normalsize \sffamily
$for(to)$
$to$\\
$endfor$
%\vspace{6em}
\begin{flushright}
\small
$city$, \today
\end{flushright}
\vspace{1em}
\section*{\textsc{Faktura} \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 t t]{lp{7.2cm}ccr}}
\hdashline[1pt/1pt]
@ \noalign{\vskip 2mm} \textbf{\#} & @ \textbf{Produkt} & @ \textbf{Antal} & @ \textbf{Pris pr. stk.} & @ \textbf{Samlet pris i $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.amount$ & $service.pieceprice$ & $service.price$\\$endfor$ \noalign{\vskip 2mm} \hline
@ & @ \multicolumn{3}{r}{Subtotal:} & :={sum(e1:[0,-1])} \\ \hhline{~~~~-}
@ & @ \multicolumn{3}{r}{Rabat fra kantinekort (-10\%):} & -(100-90)/100*[0,-1] \\ \hhline{~~~~-}
@ & @ \multicolumn{3}{r}{\textbf{Total:}} & \textbf{:={[0,-2]+[0,-1]}} \\ \hhline{~~~~-}
\end{spreadtab}
\vspace{15mm}
\sffamily
\small
$closingnote$
\medskip
$author$
$if(qrcode)$
\includegraphics[width=4cm]{qr.png}
$endif$
\end{document}