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

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:

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.

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

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). 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.