Getting two tables in LaTeX to have the same (right-aligned) column width

vahidg picture vahidg · Feb 19, 2010 · Viewed 20.9k times · Source

I have two very short and consecutive sections (for a CV), each containing a small table:

\section{Work Experience}

\begin{tabular}{r|p{11cm}}
Current & Your job at Your Company, Town \\
Jan 2009 & What your company does \\
& A description of what you do\\
\multicolumn{2}{c}{}\ 
\end{tabular}

\section{Education}

\begin{tabular}{r|p{11cm}}
Slightly wider first column & University, Town \\
Jan 2009 & Thesis subject \\
& A description of what you did\\
\multicolumn{2}{c}{}\ 
\end{tabular}

So each table has two columns: The first containing the period, aligned to the right. The second: some more info with a certain width, top (and left) aligned.

The problem is that the width of the left column in the two tables is different, and doesn't look nice since the sections (therefore tables) are consecutive and in one page. I cannot give r a width like p:

\begin{tabular}{r{11cm}|p{11cm}}

Does not work. How can I get the widths of the first columns of the two tables the same length while also having them right aligned?

EDIT Thanks for the answers, they all work for me so I upvoted all of them, and accepted the one that appealed to me the most (and most upvoted), since you don't have to specify the \hfill in each row. However if you don't want to use the array package for any reason then the other solutions are also great.

Answer

Ramashalanka picture Ramashalanka · Feb 19, 2010

If you use the array package, you can put the \hfill in the header as follows, so you don't have to remember to put it (or a \parbox) in each row.

\documentclass{article}
\usepackage{multicol}
\usepackage{array}
\begin{document}
\section{Work Experience}

\begin{tabular}{>{\hfill}p{5cm}|p{11cm}}
  Current & Your job at Your Company, Town \\
  Jan 2009 & What your company does \\
  & A description of what you do\\
  \multicolumn{2}{c}{} 
\end{tabular}

\section{Education}

\begin{tabular}{>{\hfill}p{5cm}|p{11cm}}
  Slightly wider first column & University, Town \\
  Jan 2009 & Thesis subject \\
  & A description of what you did\\
  \multicolumn{2}{c}{} 
\end{tabular}
\end{document}

to give:

alt text http://www.freeimagehosting.net/uploads/5e29f675e3.jpg