Archive for August, 2009

Cover letter with style - part three

This is the third part of the tutorial Cover letter with style. You can find the second part here.

It's time to setup a custom header for our cover letter. I usually put my name and my current job title in the header, accordingly to my big ego. In KOMA-Script, there are several ways to define your own header; each one offers an increasing degree of freedom but also an increasing complication in use. Luckily enough, for our purposes, we can use the easiest.

So, the simplest way to change your header is by the \firsthead command. That will set the custom header just for the first page of the document. But we're talking about a cover letter: don't even think to make it longer than a page. Enough said, I will modify the template now

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5.  
  6. % ==============================================
  7. %  PERSONAL DATA
  8. % ==============================================
  9. \setkomavar{fromname}{Iulius Caesar}
  10. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  11. \setkomavar{fromphone}{+31 (0)22 7394203}
  12. \setkomavar{fromemail}{iulius@gmail.com}
  13. \setkomavar{fromfax}{+31 (0)71 5144543}
  14. \setkomavar{fromurl}{http://stefano.italians.nl}
  15. \setkomavar{frombank}{Postbank 9307157}
  16. \setkomavar{place}{Amsterdam}
  17. \setkomavar{signature}{Iulius Caesar}
  18.  
  19. % ==============================================
  20. %  FORMATTING STUFF
  21. % ==============================================
  22.  
  23. % === font settings
  24. \defaultfontfeatures{Mapping=tex-text}
  25. \setmainfont {Adobe Garamond Pro}
  26. \setsansfont {Gill Sans Std}
  27.  
  28. %set the font size and leading
  29. \renewcommand{\normalsize}{\fontsize{12.5}{17}\selectfont}
  30.  
  31. \firsthead{
  32.    \centering
  33.          \usekomavar{fromname}\\
  34.          Programmer and Architect at Initech
  35. }
  36.  
  37. \endinput

So, I have specified the following: the header shall be centered and will be comprised of two lines (the \\ is the latex command to break the line). The first line will be our name. I didn't write it directly because it is already set at line 9. Instead, I used \usekomavar to lookup the fromname variable. Here I am adhering to the D-FRY principle: don't fucking repeat yourself. The second line is the job title. You can choose to define a variable as well, if you plan to use the job title more than once in your letter.

Now, render the letter again, to see the result

header one

Well, it sucks. I will increase the font size, and use the small caps version.

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5.  
  6. % ==============================================
  7. %  PERSONAL DATA
  8. % ==============================================
  9. \setkomavar{fromname}{Iulius Caesar}
  10. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  11. \setkomavar{fromphone}{+31 (0)22 7394203}
  12. \setkomavar{fromemail}{iulius@gmail.com}
  13. \setkomavar{fromfax}{+31 (0)71 5144543}
  14. \setkomavar{fromurl}{http://stefano.italians.nl}
  15. \setkomavar{frombank}{Postbank 9307157}
  16. \setkomavar{place}{Amsterdam}
  17. \setkomavar{signature}{Iulius Caesar}
  18.  
  19. % ==============================================
  20. %  FORMATTING STUFF
  21. % ==============================================
  22.  
  23. % === font settings
  24. \defaultfontfeatures{Mapping=tex-text}
  25. \setmainfont {Adobe Garamond Pro}
  26. \setsansfont {Gill Sans Std}
  27.  
  28. %set the font size and leading
  29. \renewcommand{\normalsize}{\fontsize{12.5}{17}\selectfont}
  30.  
  31. \firsthead{
  32.    \centering
  33.          \fontsize{36}{36}\selectfont\scshape \usekomavar{fromname}\\
  34.          \fontsize{21}{21}\selectfont\scshape Programmer and Architect at Initech
  35. }
  36.  
  37. \endinput

Now the header looks like this

header two

Much better. But I'm still not quite happy. So, I will increase the letter spacing, just for the first line. I will change the so called "feature" LetterSpace.

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5.  
  6. % ==============================================
  7. %  PERSONAL DATA
  8. % ==============================================
  9. \setkomavar{fromname}{Iulius Caesar}
  10. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  11. \setkomavar{fromphone}{+31 (0)22 7394203}
  12. \setkomavar{fromemail}{iulius@gmail.com}
  13. \setkomavar{fromfax}{+31 (0)71 5144543}
  14. \setkomavar{fromurl}{http://stefano.italians.nl}
  15. \setkomavar{frombank}{Postbank 9307157}
  16. \setkomavar{place}{Amsterdam}
  17. \setkomavar{signature}{Iulius Caesar}
  18.  
  19. % ==============================================
  20. %  FORMATTING STUFF
  21. % ==============================================
  22.  
  23. % === font settings
  24. \defaultfontfeatures{Mapping=tex-text}
  25. \setmainfont {Adobe Garamond Pro}
  26. \setsansfont {Gill Sans Std}
  27.  
  28. %set the font size and leading
  29. \renewcommand{\normalsize}{\fontsize{12.5}{17}\selectfont}
  30.  
  31. \firsthead{
  32.    \centering
  33.          {\addfontfeature{LetterSpace=20.0}\fontsize{36}{36}\selectfont\scshape \usekomavar{fromname}}\\[5mm]
  34.          \fontsize{21}{21}\selectfont\scshape Programmer and Architect at Initech
  35. }
  36.  
  37. \endinput

I used the command \addfontfeature to set the LetterSpace feature equal to 20. To find the right factor, I just did some experiments. Mind the use of a pair of {} to enclose the entire first line. In this way the change of letter spacing is local to the first line and don't apply to the second line. I also set up half centimeter of space between the lines, with the command \\[put your vertical distance here]

So, render again the letter and see the result:

header three

Well, now take a look at the entire page so far

step 4 completed

Perfect. In the next part I will show how to setup up the footer and then we will be ready for the watermarks, logo and barcode...

Cover letter with style - part two

This is the second part of the tutorial Cover letter with style. You can find the first part here.

In this second part, we will change the default fonts using fontspec. Forget importing Postscript fonts, classifying them under the NFSS1 and other crazy stuff: fontspec is able to load opentype fonts and select them very easily. You have just to install the fonts on your system. For example, I bought Garamond e Gill Sans fonts from Adobe and I'm using Ubuntu, so I copied the *.otf files somewhere under the

/usr/share/fonts

and then I updated the font cache with this command

sudo fc-cache -fv

Last thing you will need is to take note of the exact name of the font family, to be able to select it. For that, after having installed the lcdf-typetools ubuntu package, you can do something like

otfinfo -i /usr/share/fonts/AGaramondPro-Regular.otf | grep Family

Ok, after those few steps I have installed the fonts and discovered their family name, say, "Adobe Garamond Pro" and "Gill Sans Std". Now just change the template (remember, standard.lco) as this:

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5.  
  6. % ==============================================
  7. %  PERSONAL DATA
  8. % ==============================================
  9. \setkomavar{fromname}{Iulius Caesar}
  10. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  11. \setkomavar{fromphone}{+31 (0)22 7394203}
  12. \setkomavar{fromemail}{iulius@gmail.com}
  13. \setkomavar{fromfax}{+31 (0)71 5144543}
  14. \setkomavar{fromurl}{http://stefano.italians.nl}
  15. \setkomavar{frombank}{Postbank 9307157}
  16. \setkomavar{place}{Amsterdam}
  17. \setkomavar{signature}{Iulius Caesar}
  18.  
  19. % ==============================================
  20. %  FORMATTING STUFF
  21. % ==============================================
  22.  
  23. % === font settings
  24. \defaultfontfeatures{Mapping=tex-text}
  25. \setmainfont {Adobe Garamond Pro}
  26. \setsansfont {Gill Sans Std}
  27.  
  28.  
  29. \endinput

At line 4 I just imported the fontspec package. At line 24 I am instructing fontspec to add the ligatures TeX needs.2 At line 25 I set the main font and at line 26 I set the font to be used in case a sans serif one if needed.

Another important thing to set up, usually, is the font size and the lead. To do so, just add one more line:

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5.  
  6. % ==============================================
  7. %  PERSONAL DATA
  8. % ==============================================
  9. \setkomavar{fromname}{Iulius Caesar}
  10. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  11. \setkomavar{fromphone}{+31 (0)22 7394203}
  12. \setkomavar{fromemail}{iulius@gmail.com}
  13. \setkomavar{fromfax}{+31 (0)71 5144543}
  14. \setkomavar{fromurl}{http://stefano.italians.nl}
  15. \setkomavar{frombank}{Postbank 9307157}
  16. \setkomavar{place}{Amsterdam}
  17. \setkomavar{signature}{Iulius Caesar}
  18.  
  19. % ==============================================
  20. %  FORMATTING STUFF
  21. % ==============================================
  22.  
  23. % === font settings
  24. \defaultfontfeatures{Mapping=tex-text}
  25. \setmainfont {Adobe Garamond Pro}
  26. \setsansfont {Gill Sans Std}
  27.  
  28. %set the font size and leading
  29. \renewcommand{\normalsize}{\fontsize{12.5}{17}\selectfont}
  30.  
  31. \endinput

I just added the line 29, plain old Latex directive, to redefine the \normalsize macro3. In this way I can specify the height of the font and the space in point between the lines. The values one should use really depend on so many factors... but this is not a course on basic typography.

Ok, time to generate our cover letter again. To appreciate the differences, I first show the old version:

default font

And now with the professional fonts

professional font

Can you see the difference? I hope so. Note also the sender address: it has to be rendered in a smaller size, so KOMA-Script used the sans serif font because more legible; that's why we also specified a suitable family for sans serif font in our template.

For more information, examples and so on, I urge you to read the fontspec documentation, to get ready for the third part of the tutorial.

That's all folks. Now you can proceed to the third part.

  1. New Font Selection Scheme []
  2. Commercial fonts usually lacks ligatures like "--" (n-dash) and "---" (m-dash) but with this line TeX will still find them []
  3. There are other methods []

Cover letter with style - part one

Time flies and almost one year went by without me writing the 5th part of Your Curriculum in LaTeX series. You know what? I grew tired of the tutorial: you can figure out the rest1

Instead, I decided to start a new tutorial, this time illustrating a way to obtain a stylish cover letter with XeTeX (and XeLaTeX), which enables the easy use of OpenType fonts (through the fontspec package) and support for Unicode text (no need of escape extended characters anymore). Also, as in the other tutorial, KOMA-Script will be used.

The cover letter is the first thing they will read; possibly its form is as much important as its content. Even if you don't agree, a fancy letter doesn't do any harm, doesn't it? For example, what about a letter like this2

Sample letter one

Strong header, contact data in footer, logo as watermark. Even a barcode to pimp the destination address! Ok, the barcode is a little bit too nerdy, but it will give me the chance to show how easy is to use PSTricks from inside XeLaTex.

In this tutorial I will also show how to separate the content of your letters from the style, so you can swap the latter really easily, to obtain something completely different, like this for example:

Sample letter two

Ok, let's start. I assume you dutifully installed XeTeX, XeLaTeX, KOMA-Script and you are ready to follow me. Ready?

Create a .tex file and past the skeleton of the cover letter into it:

  1. \documentclass{scrlttr2}
  2.  
  3. \begin{document}
  4.  
  5. \begin{letter}{%
  6.        Damage Inc. --- HR Dept.\\%
  7.        Paulus Potterstraat 134\\%
  8.        1753KJ Amsterdam
  9. }
  10. \setkomavar{subject}{Cover Letter}
  11. \opening{Dear Recruiter,}
  12.  
  13. My name is Iulius Caesar bla bla bla...
  14.  
  15. \closing{Regards}
  16.  
  17.  
  18. \end{letter}
  19. \end{document}

At line 1 you are instructing XeLaTeX to load the letter class from KOMA-Script, which will format a nice letter for you. At lines 6,7,8 the destination address is specified. At line 13 the body of the letter. The other parts should be trivial to understand. Basically this is a template for any kind of letter you will write. Nothing difficult indeed. If you process this with XeLaTeX you will get:

barebone letter

Effortlessly we obtained a nice formatted letter. KOMA-Script even added three little dashes on the left border: they are guides to fold the letter with precision. The only thing is missing is the sender address. I could have added the KOMA instructions to set the sender address directly into the tex file, but there's a better method.

The letter document class defined by KOMA-Script support the loading of a setting/style file. In this file, with extension .lco, you can store things like your data (used to compose the sender address) or whatever latex instruction, to change the style for example. In this way the .tex will contain just the letter text and nothing else. This is handy for two reason: 1) you don't have to type your data for each letter you write; 2) you may have more .lco files that you can use to change altogether the look & feel.

So, create a file and call it standard.lco. Stick your data in it, like this:

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. % ==============================================
  5. %  PERSONAL DATA
  6. % ==============================================
  7. \setkomavar{fromname}{Iulius Caesar}
  8. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  9. \setkomavar{fromphone}{+31 (0)22 7394203}
  10. \setkomavar{fromemail}{iulius@gmail.com}
  11. \setkomavar{fromfax}{+31 (0)71 5144543}
  12. \setkomavar{fromurl}{http://stefano.italians.nl}
  13. \setkomavar{frombank}{Postbank 9307157}
  14. \setkomavar{place}{Amsterdam}
  15. \setkomavar{signature}{Iulius Caesar}
  16.  
  17. \endinput

Change accordingly your .tex file (containing the text of the letter) to instruct KOMA-Script to load the standard.lco file:

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

I've changed just the first line. Urge yourself to run XeLaTeX to see the results:

barebone letter with sender address

The sender address now appears where it is supposed to be. You will notice that KOMA-Script will also add the one-liner version, meant to pop up from the transparent window of the envelope - if any - together with the destination address.

Well, that's all for the first part. There's still lot to explain so please proceed to the second part.

  1. Oh, gentlemen, do you know, perhaps I consider myself an intelligent man, only because all my life I have been able neither to begin nor to finish anything [Dostoevskij - Notes From The Underground] []
  2. The content is completely fictitious and doesn't necessarily reflect my views []