Monday, May 25, 2015

Fancy Documents with LaTeX

This may not be overly obvious to most people, as Microsoft Office moved people away from the text format year's ago, but creating non text based documents is a fairly complicated process. 

Since I have moved to Linux I have spent a lot of time in a terminal and a text editor manipulating text documents. So much time in fact that I got used to wrapping other tools, like git, around these text documents to track changes, or create backups of my files. (Using git and how to get started / track changes is a topic for another day).

One of the best things about working from the command line, is that I have created an integrated workflow with these tools, and gotten used to my text editor, when it came time to make some professional looking documents (like a resume or cover letter), was not thrilled at the idea of moving to Libra Office, or some other word processor.

I have not ill will against these products, they do a fine job and are simple to use. However, they are not texted based (for the most part), and using tracking systems like git become challenging when you want to simply see what you changed between revisions (because of the editor formatting or xml).

So I began looking for a solution to my un-professional document issues and was able to find several good formats.

  • HTML + CSS
  • LaTeX

Of the list above I chose to move most of my professional documents to LaTeX, because of it allowed me to focus on the text (after the learning curve), and it integrated well with everything else that I use.  As my files(source) are stored in text documents I can use my editor of choice and version control system to track my changes, and why I made them (cleanly).

Because I am also a Fedora user I will also be demonstrating how easy it is to get started with some of the default tools provided by this distribution.

Requirements:

  • Fedora OS (LiveCD)
  • Evince (should be installed by default with Fedora) 
  • vim-latex.noarch package (again because I am using vim as my editor, but it also provides the LaTeX packages you need as well).
    • texlive-preprint-svn30447.2011-1.1.fc21.noarch (optional - I need this for my cover letters) with out this \usepackage{fullpage} does not work. 
    • texlive-lipsum-svn22098.v1.2-1.1.fc21.noarch (optional - I use this for sample text) with out this \usepackage{lipsum} does not work. 
  • Live Preview Script (optional - With out this you have to compile and open the pdf's with Evince by hand) 
With this installed you can start creating documents that not only look professional but are simple to manage or retain. 

Example: 

% Resume Cover Letter
\documentclass[10pt]{letter}
\usepackage{fullpage}
\usepackage{lipsum}
 
%only in this document to generate filler text.
%NOTES:
% \\ Provides a Return :)
% Prove to people its made with LaTeX
\newcommand{\madewith}[1]{
    \begin{flushright}\fontfamily{phv}\fontsize{8pt}{8pt}\selectfont#1\end{flushright}
}
\longindentation=4.5in %Configure letter to fit the page
\setlength{\topmargin}{1in}    % the way I would like it.
\address{1807 Glenwood St. NE \\ Palm Bay FL 32907}
\signature{Edward Andrew Neary (Ed)}
% Start Document
 
\begin{document}
% Start the Letter | State who you are sending it TO:
\begin{letter}{Research and Development\\
               PSC 450 Box 297
               APO AP 96206}  %TO LOCATION
 
\opening{To whom it may concern;}
% Letter to accompany Resume.
\lipsum
 
\closing{Respectfully,} 
\encl{Resume of EDR, BS Computer Science}
\madewith{made with \LaTeX}
\end{letter}
\end{document}
To compile this document into a PDF document you simply need to use some of the tools installed earlier. 
# pdflatex file.tex
If you want to see what your document will look like (as a pdf document) while you are writing it, you can also use this vim-plugin to start the Evince the compiles your document, on a regular interval.

Start the viewer in vim with:
:LLPStartPreview