1

I need help fine tuning this document. I basically need three things:

  1. Get rid of the duplicate company information on top of "Client"
  2. Be able to stamp today's date automatically. I tried using "datetime" package but every time I run the script it collapses.
  3. Calculate the tax automatically (can that be done in LaTeX?)

PS: the example comes with an external file called "template.lco" Inside that file I found the following:

\ProvidesFile{template.loc}[]

% firstfootvpos has to have more space to the bottom
\@setplength{firstfootvpos}{\paperheight}
\@addtoplength[-]{firstfootvpos}{30mm}

And here's the code for the actual document:

\documentclass[DIN, pagenumber=false, parskip=half, 
fromalign=right, 
fromphone=true, 
fromfax=false,
fromrule=false]{scrlttr2}

\usepackage[spanish]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{eurosym}
\usepackage{datetime}

\LoadLetterOption{template}
\newcommand{\stdlohn}[0]{18 \% }
\renewcommand*{\raggedsignature}{\raggedright} 

\setkomavar{fromname}{Company}
\setkomavar{fromphone}{+49 (0) 123 / 1234 1234}
\setkomavar{fromaddress}{Address}
\setkomavar{frombank}{Bank info}

\setkomavar{subject}[]{Service description}
\setkomavar{yourmail}[Code]{BAG-EB-00001}
\setkomavar{date}[Date]{06 July 2015}

\firstfoot{
\parbox[t]{\textwidth}{\footnotesize 

\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Company:}}\\ 
Info \\
\end{tabular}
\hfill{}
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Bank:}}\\ 
Bank name\\
\end{tabular}
}}

\begin{document}

\begin{letter}{
\textbf{Client}\\ 
Name\\
}

\opening{\ }
\vspace{-1.9cm}

\begin{longtable}{p{7.8cm}p{1.0cm}p{1cm}p{2.7cm}p{2.5cm}}
\hline  
Description & Amount & U & Price & Total\\
\hline 

\textbf{Service}\\
Service & 1 & H & USD 60.00 {} & USD 60.00{}\\ \\
\hline\hline 
\end{longtable}

\begin{longtable}{p{5.5cm}p{3cm}p{3cm}}
\hline A & \stdlohn Tax & B\\
\hline 
USD 6,000.00{} & USD 6,000.00 & \textbf{USD 6,000.00}{}\\
\hline 
\hline  
\end{longtable}

\end{letter}
\end{document}
1

EDIT: I changed the code to a MWE.

With the two commands you can print the taxes only or the sum of both values. You can place them wherever you want them to appear.

enter image description here

\documentclass{standalone}
\usepackage{pgf,pgfmath}

\pgfkeys{/pgf/number format/.cd,
    fixed,
    fixed zerofill,
    precision=2,
    set thousands separator={.},
    set decimal separator={,}
    }

\newcommand{\taxes}[2]{%
    \pgfmathparse{#1*#2/100}%
    \pgfmathprintnumber{\pgfmathresult}%
    }

\newcommand{\addtaxes}[2]{%
    \pgfmathparse{#1+#1*#2/100}%
    \pgfmathprintnumber{\pgfmathresult}%
    }

\def\taxval{18}
\def\money{4.5}

\begin{document}
\begin{tabular}{cr}
Worktime & \pgfmathprintnumber{\money} \\
Taxes (\taxval\,\%)& \taxes{\money}{\taxval} \\
Sum & \addtaxes{\money}{\taxval}
\end{tabular}
\end{document}
  • When I insert the script for "\pgfmathprintnumber" I receive the following error: ! Undefined control sequence. l.22 \pgfkeys {/pgf/number format/.cd, ? – killthepixelnow Jul 7 '15 at 10:50
  • apart from that, how do I apply that command to my document. That means, how do I calculate the tax automatically and also the final price of the invoice (Tax = A*1.18; B = A + Tax). I hope this makes things more clear. – killthepixelnow Jul 7 '15 at 10:53
  • 1
    @killthepixelnow I changed my answer to an working example. – Daniel Schlegel Jul 7 '15 at 11:11
  • 1
    I didn't get that error before. But it appears to be a problem in the default math engine. A solution is described here: tex.stackexchange.com/a/54803/79099. Just add '\usepackage{pgfplots}' and '\pgfkeys{/pgf/fpu}' to your file and it should work. – Daniel Schlegel Jul 7 '15 at 13:44
  • 1
    I get the correct result when I change the separators. – Daniel Schlegel Jul 8 '15 at 6:02
3

I will only answer the first two questions.

If you do not want the back address on top of the "Client" use the class option

backaddress=false

To set the to set the todays stamp automatically in spanish remove \usepackage{datetime} and remove \setkomavar{date}[Date]{06 July 2015}.

enter image description here

Code:

\begin{filecontents*}{template.lco}
\ProvidesFile{template.lco}[]

% firstfootvpos has to have more space to the bottom
\@setplength{firstfootvpos}{\paperheight}
\@addtoplength[-]{firstfootvpos}{30mm}
\end{filecontents*}

\documentclass[DIN, pagenumber=false, parskip=half, 
fromalign=right, 
fromphone=true, 
fromfax=false,
fromrule=false,
backaddress=false,
% numericaldate
]{scrlttr2}

\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{eurosym}
%\usepackage{datetime}% <- removed

\LoadLetterOption{template}
\newcommand{\stdlohn}[0]{18 \% }
\renewcommand*{\raggedsignature}{\raggedright} 

\setkomavar{fromname}{Company}
\setkomavar{fromphone}{+49 (0) 123 / 1234 1234}
\setkomavar{fromaddress}{Address}
\setkomavar{frombank}{Bank info}

\setkomavar{subject}[]{Service description}
\setkomavar{yourmail}[Code]{BAG-EB-00001}
%\setkomavar{date}[Date]{06 July 2015}% <-removed

\setkomavar{firstfoot}{% <- changed
\parbox[t]{\textwidth}{\footnotesize 

\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Company:}}\\ 
Info \\
\end{tabular}
\hfill{}
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Bank:}}\\ 
Bank name\\
\end{tabular}
}}

\begin{document}

\begin{letter}{
\textbf{Client}\\ 
Name\\
}

\opening{\ }
\vspace{-1.9cm}
\begin{longtable}{p{7.8cm}p{1.0cm}p{1cm}p{2.7cm}p{2.5cm}}
\hline  
Description & Amount & U & Price & Total\\
\hline 

\textbf{Service}\\
Service & 1 & H & USD 60.00 {} & USD 60.00{}\\ \\
\hline\hline 
\end{longtable}
\begin{longtable}{p{5.5cm}p{3cm}p{3cm}}
\hline A & \stdlohn Tax & B\\
\hline 
USD 6,000.00{} & USD 6,000.00 & \textbf{USD 6,000.00}{}\\
\hline 
\hline  
\end{longtable}
\end{letter}
\end{document}

Note that I have changed \firstfoot{...} to \setkomavar{firstfoot}{...}. That is the uptodate syntax.


If the language of your document is english you can change the babel option to english. Then use

\usepackage[english]{isodate}\cleanlookdateon

instead loading datetime and remove \setkomavar{date}[Date]{06 July 2015} to set the todays stamp automatically in the same format.

enter image description here

  • backaddress command worked fine! Concerning the date, I want it to be in Spanish, but I tried the script in English like you suggested and I can't export the document. – killthepixelnow Jul 7 '15 at 10:47
  • 1
    I have changed my answer. Note that you have to remove package datetime. – esdd Jul 7 '15 at 11:23
  • Great, that worked perfectly! – killthepixelnow Jul 7 '15 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.