Cover Letter with Style - Part Six

Jan 30, 2015

A tutorial illustrating a way to obtain stylish cover letters with XeLaTeX

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 with XeLaTex. For the purpose, you will need pstricks.

Installing pstricks is very easy on ubuntu: just open a terminal and issue the command:

sudo apt-get install texlive-pstricks

Now, for drawing a barcode we can use a pstricks sub package called 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

 1 \documentclass[standard,letterpaper,pagesize,UScommercial9]{scrlttr2}
 2 
 3 \usepackage{pst-barcode}
 4 
 5 \begin{document}
 6 
 7 \begin{letter}{
 8        Damage Inc. --- HR Dept.\\
 9        Paulus Potterstraat 134\\
10        1753KJ Amsterdam\\%
11        \psbarcode{1234567}{}{royalmail}
12 }
13 \setkomavar{subject}{Cover Letter}
14 \opening{Dear Recruiter,}
15 
16 My name is Iulius Caesar bla bla bla...
17 
18 \closing{Regards}
19 
20 
21 \end{letter}
22 \end{document}

At line 3 I import the package and at line 11 I specify a royalmail barcode, coding in the number 1234567 (just an example). If you typeset the document, you will obtain this:

bar1

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:

bar2

The entire cover letter, finally, appears like that:

Sample cover letter

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.

  1 \ProvidesFile{alternate.lco}[%
  2   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3 
  4 \usepackage{fontspec}
  5 \usepackage{fix-cm}
  6 \usepackage{xltxtra}
  7 \usepackage{marvosym}
  8 \usepackage{graphicx}
  9 \usepackage[dvipdfm]{geometry}
 10 \usepackage[english]{babel}
 11 
 12 % ==============================================
 13 %  PERSONAL DATA 
 14 % ==============================================
 15 \setkomavar{fromname}{Dhr. Iulius Caesar}
 16 \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
 17 \setkomavar{fromphone}{+31 (0)22 7394203}
 18 \setkomavar{fromemail}{iulius@gmail.com}
 19 \setkomavar{fromfax}{+31 (0)71 5144543}
 20 \setkomavar{fromurl}{http://www.kindoblue.nl}
 21 \setkomavar{frombank}{Postbank 9307157}
 22 \setkomavar{place}{Amsterdam}
 23 \setkomavar{signature}{Iulius Caesar}
 24 \setkomavar{fromlogo}{\includegraphics[width=3cm]{sample_logo.eps}}
 25 
 26 % define new variable company
 27 \newkomavar{company}
 28 \setkomavar{company}{Initech}
 29 
 30 
 31 % ==============================================
 32 %  FORMATTING STUFF 
 33 % ==============================================
 34 
 35 % === font settings
 36 \defaultfontfeatures{Mapping=tex-text}
 37 \setmainfont {Adobe Garamond Pro}
 38 \setsansfont {Gill Sans Std}
 39 
 40 
 41 % shift the page body on the left to make room for
 42 % our data and logo
 43 \setlength{\oddsidemargin}{\useplength{toaddrhpos}}
 44 \addtolength{\oddsidemargin}{-1in}
 45 \addtolength{\textwidth}{-0.5in}
 46 % Take care that the shift stays intact even after recalculating the page
 47 % layout (see Kohm & Morawski 2005, section C.7)
 48 \l@addto@macro{\@typearea@end}{
 49   \setlength{\oddsidemargin}{\useplength{toaddrhpos}}%
 50   \addtolength{\oddsidemargin}{-1in}%
 51 }
 52 
 53 
 54 % setup some lenghts
 55 \@setplength{firstheadvpos}{0pt}
 56 \@setplength{firstheadwidth}{\paperwidth}
 57 \@setplength{firstfootvpos}{\paperheight}
 58 \@addtoplength[-]{firstfootvpos}{\useplength{toaddrvpos}}
 59 \@addtoplength{refvpos}{-1.5\baselineskip}
 60 \@newplength{infocolwidth}
 61 \@setplength{infocolwidth}{.15\paperwidth}
 62 
 63 
 64 % fancy header for the first page
 65 \setkomavar{firsthead}{
 66   \fontsize{8}{9}\sffamily
 67   \hspace*{\fill}%
 68   \begin{picture}(0,0)%
 69     \put(0,0){\parbox[t]{\useplength{infocolwidth}}{%
 70         \vspace{\useplength{toaddrvpos}}%
 71         \usekomavar{fromlogo}%
 72       }%
 73     }%
 74     \put(0,0){\parbox[t]{\useplength{infocolwidth}}{%
 75         \raggedright
 76         \vspace{\useplength{refvpos}}%
 77         \vspace{\useplength{refaftervskip}}%
 78         \usekomavar{place}\usekomavar{placeseparator}\\
 79         \usekomavar{date}\\[10\baselineskip]
 80         \usekomavar{fromname}
 81         \ifkomavarempty{company}{}{%
 82           \\
 83           \usekomavar{company}%
 84         }\\[\baselineskip]
 85         \usekomavar{fromaddress}\\
 86         \usekomavar*{fromphone}\usekomavar{fromphone}\\
 87         \usekomavar*{fromfax}\usekomavar{fromfax}%
 88         \\[\baselineskip]
 89         \usekomavar{fromemail}\\
 90         \usekomavar{fromurl}
 91       }%
 92     }%
 93   \end{picture}%
 94   \hspace*{\useplength{infocolwidth}}%
 95 }%
 96 
 97 % avoid the display of the date in the default position
 98 \l@addto@macro\@firstheadfootfield{\setkomavar{date}{}}
 99 
100 \endinput

I won’t explain the details. Moreover, this template was not created by me: I just copied (and simplified) the template shown in this document: Replacing Latex standard classes with KOMA-Script by Yuri Robbers, Markus Kohm and Rasmus Pank Roulund

Save the above template as alternate.lco file. Now take your cover letter and in the first line specifiy you want to use this alternative template, like this

1 \documentclass[alternate]{scrlttr2}
2 
3 ...

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

Sample cover letter

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). A couple on notes: 1) if you plan to use more than one template, the personal data section could be put in a separate file and included by the templates; 2) the alternate template just shown could not play well with DIN standard, so you might need to fiddle with infocolwidth

So, I hope you enjoyed the tutorial. See you in seven years.