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:

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

  1. \documentclass[standard]{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 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

step7

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

  1. \documentclass[alternate]{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}

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

alternate

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

5 Comments so far

  1. YHG on February 26th, 2010

    Why did it take me five days to find this website? Five useless days wrestling with Koma and Lyx, and then finally I find this, and I am saved! Thanks for a perfect explanation!.

  2. steve on July 14th, 2010

    Hi. Just wondering if you had any input from a previous question asked on this website - about the absence of the footer.

    Thanks
    Steve

    P.S. Really nice layout. Thanks much!

  3. kindoblue on July 14th, 2010

    No Steve, no input regarding missing footers.

  4. andré on March 11th, 2011

    first, congratulations for the amazing layout and thank you for sharing it with us.

    I found a small mistake in the code (a missing }) but someone has already pointed that out.

    I have a question: is it possible to use a /href with mailto: code? if so, how?

    thank you

  5. […] with two letterhead styles for the scrlettr2 document class (provided by the KOMA-Script package): http://stefano.italians.nl/archi…TeX Catalogue entry for KOMA-Script:http://mirror.ctan.org/help/Cata…This answer .Please specify […]

Leave a reply