Cover letter with style - part six
This is the sixth part of the tutorial Cover letter with style. You can find the fifth part here.
In this part I will show you how to add a barcode in the destination address. It's a kind of nerdy, but it will serve to illustrate how to do graphics stuff easily with XeLaTex. For the purpose, you have to install pstricks and let Xe(La)Tex know about it.
Installing pstricks is very easy on ubuntu: just open a terminal and issue the command:
sudo apt-get install texlive-pstricks
Then, we need to inform Xe(La)Tex where to find the pstricks configuration file for the xdvipdfmx driver (this is the driver XeLaTex uses to output your pdf). To do so, first create a couple of directories
mkdir -p /usr/share/texmf-texlive/tex/xetex/xetex-pstricks/
mkdir -p /usr/share/texmf-texlive/tex/xelatex/xetex-pstricks/
Then you need to copy this pstricks.con file in those directories. You need also to copy this xdvipdfmx.con file in
/usr/share/texmf-texlive/tex/generic/pstricks
To finish, run
sudo texhash
All this, to have graphics in your pdf's in just one go, through XeLaTex. For those who are not fully aware of the problem, I just saved you from this mess:

Consider also that the above instructions are done once for all. After this setup, we are ready to use pstricks packages.
So, for drawing a barcode we can use pst-barcode. It is pretty easy to use and its documentation says it all.
This time, instead of changing the template file (standard.lco, remember?) I will change the letter itself, because the destination address is in there. So here it is the letter with the barcode added
-
\documentclass[standard]{scrlttr2}
-
-
\usepackage{pst-barcode}
-
-
\begin{document}
-
-
\begin{letter}{%
-
Damage Inc. --- HR Dept.\\%
-
Paulus Potterstraat 134\\%
-
1753KJ Amsterdam\\%
-
\psbarcode{1234567}{}{royalmail}
-
}
-
\setkomavar{subject}{Cover Letter}
-
\opening{Dear Recruiter,}
-
-
My name is Iulius Caesar bla bla bla...
-
-
\closing{Regards}
-
-
-
\end{letter}
-
\end{document}
At line 3 I import the package and at line 11 I specify a royalmail barcode, coding the number 1234567 (just an example). If you typeset the document, you will obtain this

Cool, isnt' it? Further, we can adjust the barcode position, specifing the optional parameters, transx and transy
\psbarcode[transy=-0.2cm,transx=0.1cm]{1234567}{}{royalmail}
The result now is

The entire cover letter, finally, appears like that

Well, it was a long journey but now we got a stylish cover letter to show off. I hope you like it.
I am still not done! I have to show one thing more: an alternative template you can use to completely change the look and feel of your cover letter. Keeping the template separated from the content permits us to easily swap style as changing one line only.
First of all, I will provide you a new template.
-
\ProvidesFile{alternate.lco}[%
-
2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
-
-
\usepackage{fontspec}
-
\usepackage{xltxtra}
-
\usepackage{marvosym}
-
\usepackage{graphicx}
-
\usepackage[dvipdfm]{geometry}
-
-
% ==============================================
-
% PERSONAL DATA
-
% ==============================================
-
\setkomavar{fromname}{Iulius Caesar}
-
\setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
-
\setkomavar{fromphone}{+31 (0)22 7394203}
-
\setkomavar{fromemail}{iulius@gmail.com}
-
\setkomavar{fromfax}{+31 (0)71 5144543}
-
\setkomavar{fromurl}{http://stefano.italians.nl}
-
\setkomavar{frombank}{Postbank 9307157}
-
\setkomavar{place}{Amsterdam}
-
\setkomavar{signature}{Iulius Caesar}
-
\setkomavar{fromlogo}{\includegraphics[width=3cm]{sample_logo.eps}}
-
-
% DIN standard
-
%\LoadLetterOption{DINmtext}
-
-
-
% ==============================================
-
% FORMATTING STUFF
-
% ==============================================
-
-
% === font settings
-
\defaultfontfeatures{Mapping=tex-text}
-
\setmainfont {Adobe Garamond Pro}
-
\setsansfont {Gill Sans Std}
-
-
-
% shift the page body on the left to make room for
-
% our data and logo
-
\setlength{\oddsidemargin}{\useplength{toaddrhpos}}%
-
\addtolength{\oddsidemargin}{-1in}%
-
% Take care that the shift stays intact even after recalculating the page
-
% layout (see Kohm & Morawski 2005, section C.7)
-
\l@addto@macro{\@typearea@end}{%
-
\setlength{\oddsidemargin}{\useplength{toaddrhpos}}%
-
\addtolength{\oddsidemargin}{-1in}%
-
}
-
-
-
% setup some lenghts
-
\@setplength{firstheadvpos}{0pt}%
-
\@setplength{firstheadwidth}{\paperwidth}%
-
\@setplength{firstfootvpos}{\paperheight}%
-
\@addtoplength[-]{firstfootvpos}{\useplength{toaddrvpos}}%
-
\@addtoplength{refvpos}{-1.5\baselineskip}%
-
\@newplength{infocolwidth}%
-
% Kohm & Morawski 2005, C.7. Modifikationen (Modifications)
-
\ifdim \textwidth<0.666\paperwidth
-
\@setplength{infocolwidth}{.22222\paperwidth}%
-
\else
-
\@setplength{infocolwidth}{0.1667\paperwidth}%
-
\fi
-
-
% define new variable company
-
\newkomavar{company}%
-
\setkomavar{company}{Initech}
-
-
-
% fancy header for the first page
-
\firsthead{%
-
\fontsize{8}{9}\sffamily
-
\hspace*{\fill}%
-
\begin{picture}(0,0)%
-
\put(0,0){\parbox[t]{\useplength{infocolwidth}}{%
-
\vspace{\useplength{toaddrvpos}}%
-
\usekomavar{fromlogo}%
-
}%
-
}%
-
\put(0,0){\parbox[t]{\useplength{infocolwidth}}{%
-
\raggedright
-
\vspace{\useplength{refvpos}}%
-
\vspace{\useplength{refaftervskip}}%
-
\usekomavar{place}\usekomavar{placeseparator}\\
-
\usekomavar{date}\\[10\baselineskip]
-
\usekomavar{fromname}
-
\ifkomavarempty{company}{}{%
-
\\
-
\usekomavar{company}%
-
}\\[\baselineskip]
-
\usekomavar{fromaddress}\\
-
\usekomavar*{fromphone}\usekomavar{fromphone}\\
-
\usekomavar*{fromfax}\usekomavar{fromfax}%
-
\\[\baselineskip]
-
\usekomavar{fromemail}\\
-
\usekomavar{fromurl}
-
}%
-
}%
-
\end{picture}%
-
\hspace*{\useplength{infocolwidth}}%
-
}%
-
-
% avoid the display of the date in the default position
-
\l@addto@macro\@firstheadfootfield{\setkomavar{date}{}}
-
-
\endinput
I won't explain the details. Moreover, this template was not created by me: I just copied (and somewhat simplified) the template shown in this document [Replacing LATEX2# standard classes with KOMA-Script by Yuri Robbers, Markus Kohm and Rasmus Pank Roulund].
Save the above template in alternate.lco file. Also, check the line 22, where the name of your logo should be specified. Now take your cover letter and in the first line specifiy you want to use this alternative template, like this
-
\documentclass[alternate]{scrlttr2}
-
-
\usepackage{pst-barcode}
-
-
\begin{document}
-
-
\begin{letter}{%
-
Damage Inc. --- HR Dept.\\%
-
Paulus Potterstraat 134\\%
-
1753KJ Amsterdam
-
\psbarcode{1234567}{}{royalmail}
-
}
-
\setkomavar{subject}{Cover Letter}
-
\opening{Dear Recruiter,}
-
-
My name is Iulius Caesar bla bla bla...
-
-
\closing{Regards}
-
-
-
\end{letter}
-
\end{document}
That's all. I just changed the first line, instructing KOMA-Script to load the alternate file (no need to specify the .lco extension). If you typeset the document, your cover letter now will look like this

Mind that the logo was not the one I used in the previous part. I edited it to have the outlines in stronger colors (it has to be in the foreground, this time)
So, I hope you enjoyed the tutorial. And I hope you can sport those cover letters in the next job application; maybe they will give you more points, who knows....
See you in seven years
Comments(1)


















