# work-work.work

A blog about goals and obstacles, motivation and procrastination, life's random events and getting things done.

# Writing Letters in LaTeX

Sometimes I simply love doing stuff the nerdy way and waste more time really digging into stuff.

Today I had to write a letter because I want to end my cable subscription. No online form or e-mail can do that. They make you jump through hoops and mail them a good old fashioned letter.

Opening my LibreOffice, I notice that I don't have a proper template or example letter on this computer. I could just start with a blank page or one of their ugly templates, or I could take the nerdy route.

Nothing has a higher procrastination value than TeX, the typesetting system created by none other than Donald Knuth himself. I prefer LaTeX to be more precise.

TeX is free as in freedom, but you don't just download a TeX program, no you install a TeX-distribution because there is an ecosystem of packages for everything. I use MacTeX on my Apple MacBook Air.

The markup is arguably ugly and it has an extreme learning curve, but I love the warm fuzzy feeling you get when something compiles.

I could have written a latex-letter that can be reused next time, but I wanted more, so I created a templace called personalletter.lco.tex.

\ProvidesFile{personalletter.lco}

\KOMAoptions{fromalign=center,fromrule=aftername,firstfoot=true}
\setkomavar{fromname}{John Doe}
\setkomavar{fromphone}{+12345679}
\setkomavar{fromfax}{+1234568}
\setkomavar{fromemail}{firstname.lastname@example.org}
\setkomavar{place}{Place}
\setkomavar{frombank}{Bank Details go here}

\firstfoot{
\hrule
\parbox[t]{\linewidth}{\scriptsize\sffamily%
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{Telefon:}\\
\usekomavar{fromphone}
\end{tabular}
\ifkomavarempty{fromfax}{}{
\hfill
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\usekomavar*{fromfax}}\\
\usekomavar{fromfax}
\end{tabular}
}
\hfill
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{E-Mail:}\\
\usekomavar{fromemail}
\end{tabular}
\hfill
\ifkomavarempty{frombank}{}{
\hfill
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\usekomavar*{frombank}}\\
\usekomavar{frombank}
\end{tabular}
}
}
}


A LaTeX letter with the filename myletter.tex could look like this:

\documentclass[personalletter,parskip=half+,enlargefirstpage=on]{scrlttr2}
\usepackage[utf8]{inputenc}

\begin{document}
\sffamily

\setkomavar{subject}{Example letter}

This is my example letter!

\closing{Best regards}

\end{letter}

\end{document}


And when I call

\$ pdflatex myletter


I get a beautiful pdf letter that would have been so much easier in LibreOffice or any other WYSIWYG editor. But who wants to fiddle with all those formatting options when you can write some nerdy instructions?

This plaintext version of my letter and the template can now be committed into my personal git repository and I can track changes easily. Isn't that something?

I know - now I'm wasting even more time blogging about it.