CV Tip: Align Columns of Different LaTeX Tables with \settowidth

by Alessandro

setToWidth

The problem with tables in a CV is that they are usually typeset as pairs of date => some job title, or piece of research.

For example, on the left, you can see three different sections:

  • A Work Experience section;
  • The Education section;
  • Another Section for Scholarships

So what happens when you are typesetting the columns of the document, especially the ones with dates?

Dates can be of different length, consider for a moment how Summer and Fall 2010 will generate totally different column width, and the style of a one page document like a CV will suffer from this asymmetry.

So the idea I tried to implement in the document is that of considering all dates as if they belong to the same column (and to the same table obviously), therefore the leftmost column contaning the dates will be as wide as the widest date element.

This date element happens to be Summer 2007, which is quite long indeed, therefore all we need to do now is to create a new length that will store the Summer 2007 length and apply it to the columns.

1. Length Manipulation Macros: \setlength, \newlength, \settowidth

1.a Declaring and Naming a new Dimension Container

\newlength{\datebox}

1.b Storing the length of a Text String into the just created Length \datebox

\settowidth{\datebox}{Summer 2007} % string of text works here
\typeout{\the\datebox} % outputs 75.84961pt

1.c Manually assigning a value to a previously declared Length

\setlength{\datebox}{<dimension>} % string of text doesnt work here
\typeout{\the\datebox} % outputs <dimension>pt

Example usage of \setlength might be

\setlength{\datebox}{1em}
\setlength{\datebox}{1mm}
\setlength{\datebox}{1cm}
\setlength{\datebox}{1pt}

2. Setting the Fixed Table Column Width

Option 1 involves setting the left hand side column as a justified paragraph of length \datebox.

%Table 1
\begin{tabular}{p{\datebox}l}
% first row
[...] & % first cell - width: \datebox
[...]    % second cell - width: variable
 
%Table 2
\begin{tabular}{p{\datebox}l}
% first row
[...] & % first cell - width: \datebox
[...]    % second cell - width: variable
\end{tabular}

Another option is to use \parbox{dimen}{text}

%Table 1
\begin{tabular}{rl} %notice r in place of p{\datebox}
% first row
\parbox{\datebox}{[...text...]} & % first cell - width of the parbox: \datebox
[...]    % second cell - width: variable
 
%Table 2
\begin{tabular}{p{\datebox}l}
% first row
\parbox{\datebox}{[...text...]} & % first cell - width of the parbox: \datebox
[...]    % second cell - width: variable
\end{tabular}

3. Final Result, as per Option 2 \parbox

equalWidth

Useful Links on the Topic: Wikibooks
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Live
  • PDF
  • Reddit
  • StumbleUpon
  • Twitter
  • Design Float
  • FriendFeed
  • Upnews
  • RSS

Related posts:

  1. LaTeX Guide to putting a picture in your CV
  2. Alternate Row Shading in LaTeX Table
  3. CurrVita & ClassicThesis LaTeX CV Template – 100 lines of code
  4. Wrapping Text in Rounded Corners ColorBox in LaTeX with TikZ and PGF
  5. Advanced two-column LaTeX CV Template | Part 2 + TeX Source