minimalia blog

Cover Letter with Style - Part Five

4 min read · tagged latex, tutorial, xelatex

Contents

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

The logo as watermark

In this part I will show you how to add your logo as a watermark to your cover letter. I created one by using inkscape (vector graphics software) and then saved as Encapsulated PostScript (EPS) file. To follow along you can download mine here.

For the purpose I will use two packages: graphicx and eso-pic. From the first one I will use the command includegraphics and from the second one AddToShipoutPicture.

\ProvidesFile{standard.lco}[%
  2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]

\usepackage[english]{babel}
\usepackage{fontspec}
\usepackage{marvosym}
\usepackage{graphicx}\usepackage{eso-pic}.
.
.

\newcommand\BackgroundPicture{   \put(0,0){     \parbox[b][\paperheight]{\paperwidth}{       \vfill       \centering\includegraphics[width=0.8\paperwidth,height=0.8\paperheight,keepaspectratio]{sample_logo_transparent.eps}       \vfill     }}}\AddToShipoutPicture{\BackgroundPicture}
\endinput

At line 7 and 8 I imported the packages and at line 20 I added the background picture, defined by declaring at lines 13-23 the command BackgroundPicture . This will put a box big as the entire page. Inside the box, the image, centered horizontally (with \centering as usual) and vertically (with a pair of enclosing \vfill)

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

The barcode

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 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:

\documentclass[standard,letterpaper,pagesize,UScommercial9]{scrlttr2}

\usepackage{lipsum}
\usepackage{pst-barcode}
\begin{document}

\begin{letter}{%
       Damage Inc. --- HR Dept.\\
       Paulus Potterstraat 134\\
       {\scshape 1753kj Amsterdam}\\
       \psbarcode[transy=-0.2cm,transx=0.1cm]{1234567}{}{royalmail}}
\setkomavar{subject}{Cover Letter}
\opening{Dear Recruiter,}

\lipsum[5]

\closing{Regards}


\end{letter}
\end{document}

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

Alternative template

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. This template was not created by me. I just copied from 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 specify you want to use this alternative template, like this (standard replaced with alternate, at line 1)

\documentclass[alternate,letterpaper,pagesize,UScommercial9]{scrlttr2}
\usepackage{lipsum}
\usepackage{pst-barcode}

\begin{document}

\begin{letter}{%
       Damage Inc. --- HR Dept.\\
       Paulus Potterstraat 134\\
       {\scshape 1753kj Amsterdam}\\
       \psbarcode[transy=-0.2cm,transx=0.1cm]{1234567}{}{royalmail}
}
\setkomavar{subject}{Cover Letter}
\opening{Dear Recruiter,}

\lipsum[5]

\closing{Regards}


\end{letter}
\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:

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


Stefano software developer

...
powered by @gatsby