Archive for the 'XeLaTeX' Category

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

Cover letter with style - part five

This is the fifth part of the tutorial Cover letter with style. You can find the fourth part here.

In this part I will show you how to add your logo as a watermark to your cover letter1

Ok, ready to go. Well...almost: you need a logo. For this time, I will provide one (Save link as...) so you can proceed with the tutorial. It is a simple vectorial image, edited with Inkscape. If you don't have Inkscape installed, you already know what to do:

sudo apt-get install inkscape

Actually, if you are able to, I suggest to compile and install Inkscape from the svn sources, but it is not mandatory.

Another thing you need is to install a couple of fonts in a way the logo will look like as I designed. The fonts are: Diavlo and Fontin. Designed by Jos Buivenga, they are free to use. I already explained how to install new fonts in linux, so I won't bother you further.

Once the fonts and Inkscape are installed, grab the svg sample logo I made for you. Launch Inkscape, open the file and customize a little bit. For example, you could select the name

edit

replace it and then adjust the its displacement with ALT+(arrows up/down/left/right) which are the keys to adjust the font tracking and kerning in Inkscape. There's a plenty of Inkscape tutorials out there, so I am confident you will come up with a decent logo for yourself.

For the moment, I suggest you to do just little changes and save the file as Encapsulated Postscript (.eps). Before saving, Inkscape shows you this dialog:

dialog

There's only one option you should change: enable the "Convert texts to paths". What it does is converting... well, text into vectorial outlines (so font informations are then discarded) If you don't check that option, acrobat reader will consider text as text in your final pdf document. In brief, it will make the text selectable, like this

selectable

And, in general, you don't want that happening for a background image, don't you?

Anyway, now you should have your beautiful logo, says sample_logo_transparent.eps. A little digression: for the name of my logo I used the word transparent, but the eps's don't really support transparency. If you go back to Inkscape and look carefully at the fill properties:

fill

you will notice that the opacity is 100% and the color of the outlines is just a light gray, giving the impression, in the final document, of transparency. At first one could think to use indeed opacity parameter and save the logo as pdf (which supports transparency) but the final result is awful.

bad

The above picture is not a screenshot gone bad, it is the actual result if you try to import the image as pdf (supporting transparency) instead of an encapsulated postscript (which doesn't support transparency, so you are forced to fake using light colors). If someone obtains better results in importing images as pdf's, let me know, please. End of digression.

Ok, time is come to add our picture as the page background. For the purpose I will use a tiny package called eso-pic.

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5. \usepackage{marvosym}
  6. \usepackage{eso-pic}
  7.  
  8. % ==============================================
  9. %  PERSONAL DATA
  10. % ==============================================
  11. \setkomavar{fromname}{Iulius Caesar}
  12. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  13. \setkomavar{fromphone}{+31 (0)22 7394203}
  14. \setkomavar{fromemail}{iulius@gmail.com}
  15. \setkomavar{fromfax}{+31 (0)71 5144543}
  16. \setkomavar{fromurl}{http://stefano.italians.nl}
  17. \setkomavar{frombank}{Postbank 9307157}
  18. \setkomavar{place}{Amsterdam}
  19. \setkomavar{signature}{Iulius Caesar}
  20.  
  21. % ==============================================
  22. %  FORMATTING STUFF
  23. % ==============================================
  24.  
  25. % === font settings
  26. \defaultfontfeatures{Mapping=tex-text}
  27. \setmainfont {Adobe Garamond Pro}
  28. \setsansfont {Gill Sans Std}
  29.  
  30. %set the font size and leading
  31. \renewcommand{\normalsize}{\fontsize{12.5}{17}\selectfont}
  32.  
  33. % === header settings
  34. \firsthead{
  35.    \centering
  36.          {\addfontfeature{LetterSpace=20.0}\fontsize{36}{36}\selectfont\scshape \usekomavar{fromname}}\\[5mm]
  37.          \fontsize{21}{21}\selectfont\scshape Programmer and Architect at Initech
  38. }
  39.  
  40. % === footer settings
  41. \firstfoot{
  42.   \centering
  43.   \addfontfeature{LetterSpace=20.0}\scshape
  44.   {
  45.       \renewcommand{\\}{\ {\large\textperiodcentered}\ }
  46.       \usekomavar{fromaddress}
  47.   }\\
  48.   {\Large\Letter} \usekomavar{fromemail} \ {\Large\Telefon} \usekomavar{fromphone}
  49.  
  50. % === watermark settings
  51. \newcommand\BackgroundPicture{
  52.    \put(0,0){
  53.      \parbox[b][\paperheight]{\paperwidth}{
  54.        \vfill
  55.        \centering
  56.        \includegraphics[width=0.8\paperwidth,height=0.8\paperheight,%
  57.                         keepaspectratio]{sample_logo_transparent.eps}%
  58.        \vfill
  59.      }}}
  60.  
  61. % the picture is centered on the page background
  62. \AddToShipoutPicture{\BackgroundPicture}
  63.  
  64.  
  65. \endinput

At line 6 I imported the package and at line 62 I added the background picture, which is defined in lines 51-59. The command \BackgroundPicture will put a box big as the entire page. Inside the box, the image, centered orizontally (with \centering) and vertically (with a pair of enclosing \vfill)

Finally! Let's run xelatex and see the result:

step 6

Our mighty page came to life. Hope you like it. Happy experimenting.

Click here for the last part of the tutorial.

  1. Note that in this part of the tutorial there is nothing specific to XeLaTex, so ideally you can use these instructions to add a watermark also to plain Latex documents. []

Cover letter with style - part four

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

After the header, I will take care of the footer. To change the default I will use the \firstfoot command. Basically it works like \firsthead, so I have nothing special to add. I will update the template with:

  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. % === header settings
  32. \firsthead{
  33.    \centering
  34.          {\addfontfeature{LetterSpace=20.0}\fontsize{36}{36}\selectfont\scshape \usekomavar{fromname}}\\[5mm]
  35.          \fontsize{21}{21}\selectfont\scshape Programmer and Architect at Initech
  36. }
  37.  
  38. % === footer settings
  39. \firstfoot{
  40.   \centering
  41.     \usekomavar{fromaddress} \\
  42.     \usekomavar{fromemail} \usekomavar{fromphone}
  43. }
  44.  
  45. \endinput

At line 39 I've declared my new footer. I wanted the material in the footer to be centered (line 40) and I've read the content of the variable fromaddress and used it as the first line, then the break line (\\) and then the email and phone (also read from the corresponding variables). The result is the following:

footer one

There's a problem with the way I declared the fromaddress: to have KOMA-Script rendering my address on three lines, I used the break line command (\\) but now I would like a one-liner address in the footer. I could declare yet another variable, this time avoiding to put the line breaks, but it will be an ugly duplication. Instead, I will use \renewcommand{}{}. As first parameter it takes the command to be redefined and as second parameter you declare the new material to use instead. Well, let's proceed:

  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. % === header settings
  32. \firsthead{
  33.    \centering
  34.          {\addfontfeature{LetterSpace=20.0}\fontsize{36}{36}\selectfont\scshape \usekomavar{fromname}}\\[5mm]
  35.          \fontsize{21}{21}\selectfont\scshape Programmer and Architect at Initech
  36. }
  37.  
  38. % === footer settings
  39. \firstfoot{
  40.   \centering
  41.     {
  42.       \renewcommand{\\}{\textperiodcentered}
  43.       \usekomavar{fromaddress}
  44.     }\\
  45.     \usekomavar{fromemail} \usekomavar{fromphone}
  46. }
  47.  
  48. \endinput

First of all, I enclose the first line in curly braces (line 41 and 44). In this way the effect of \renewcommand will remain local and will not affect the entire document. At line 42 I redefine the meaning of the \\ command, specifying it has to be replaced by a dot. That's all. Let's look at the result

footer two

So, only for the first line in the footer, the line breaks in my address were replaced by a dot. Now just enlarge the dots and add some space before and after them:

  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. % === header settings
  32. \firsthead{
  33.    \centering
  34.          {\addfontfeature{LetterSpace=20.0}\fontsize{36}{36}\selectfont\scshape \usekomavar{fromname}}\\[5mm]
  35.          \fontsize{21}{21}\selectfont\scshape Programmer and Architect at Initech
  36. }
  37.  
  38. % === footer settings
  39. \firstfoot{
  40.   \centering
  41.     {
  42.       \renewcommand{\\}{\ {\large\textperiodcentered}\ }
  43.       \usekomavar{fromaddress}
  44.     }\\
  45.     \usekomavar{fromemail} \usekomavar{fromphone}
  46. }
  47.  
  48. \endinput

Look carefully at line 42. First of all, I used the escaped space (a backslash followed by a white space) to instruct TeX to put literally two spaces around the dot. Without escaping the spaces, TeX will happily swallow them. Secondly, I applied the \large modifier to the dot character and I enclosed in curly braces (otherwise the trailing space would be enlarged too). The result will be the following

footer three

Nice, we have our address on one line now. It's time to take care of the second line. For the email and the phone contacts, I will use a couple of symbols from the marvosym package. The template so becomes:

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

At line 5 I included the marvosym package; the rest is happening at line 46. Nothing special: I used the enlarged version of the symbols \Letter and \Telefon. I also used an escaped space to keep the email address separated from the telephone number.

footer four

Now, the final touch: I will letterspace the entire footer and use the small caps. So, here it is:

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

Basically I just added the line 42. The result?

footer six

Quite a long journey for a fucking footer, but we're done and I hope you will like the final result so far. Please mind that the above screenshot was made smaller in respect of the others. To see the footer in respect of the entire page, here it is the last picture

step five

I think it is already quite a good letter, but in the next part we will watermark our logo.

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 []