[Tex/LaTex] Left and right aligned minipages, with table layout

minipagetablesvertical alignment

I am trying to create a layout with two "columns," where the right-hand column itself has two columns, which are right and left aligned, respectively. For instance:

This is some text in the first                Label  Foo
column.                               Another Label  Foo Bar Baz

I am familiar with the technique to create left and righ aligned text on the same line via minipage environments, so extending that idea I've setup the right-hand column to contain a tabular to line up its labels and text. Here's what I have:

\documentclass[letterpaper,12pt]{report}
\usepackage[margin=1in]{geometry}
\begin{document}

\noindent
\begin{minipage}[t]{.49\textwidth}
\flushleft
Some long testing text to illustrate the alignment problem.
\end{minipage}
%
\hfill
%
\noindent
\begin{minipage}[t]{.49\textwidth}
\flushright
\begin{tabular}{r l}
\textbf{Some Long Label} & Bar \\
\textbf{Another Long Label} & Foo Bar Baz \\
\end{tabular}
\end{minipage}

\end{document}

This compiles and mostly works, except for one problem: the top of the text in the table appears somewhat higher than the top of the text in the left minipage. I believe this is due to the fact that tabular's naturally have some extra vertical space before and after them, but I do not know how to fix the problem.

My question is either, how can I fix my code to have the lines of text in each minipage line up vertically or, alternatively, is there some cleaner way of creating this layout without using tabular?

Best Answer

You forgot to use [t] also in the tabular:

\documentclass[letterpaper,12pt]{report}
\usepackage[margin=1in]{geometry}
\begin{document}

\noindent
\begin{minipage}[t]{.49\textwidth}
\raggedright
Some long testing text to illustrate the alignment problem.
\end{minipage}% <-- Don't forget this one
%
\hfill
%
\begin{minipage}[t]{.49\textwidth}
\raggedleft
\begin{tabular}[t]{@{} r l @{}}% <-- Don't forget @{}!
\textbf{Some Long Label} & Bar \\
\textbf{Another Long Label} & Foo Bar Baz \\
\end{tabular}
\end{minipage}

\end{document}

enter image description here

Never use \flushleft and \flushright as commands: they exist only because there are the environments flushleft and flushright. The commands to use are \raggedright and \raggedleft.

An easier approach is with tabular*:

\documentclass[letterpaper,12pt]{report}
\usepackage[margin=1in,showframe]{geometry}
\begin{document}

\noindent
\begin{tabular*}{\textwidth}{@{}p{.45\textwidth}@{\extracolsep{\fill}}r@{}}
\raggedright
Some long testing text to illustrate the alignment problem.
&
\begin{tabular}[t]{@{}r l@{}}
\textbf{Some Long Label} & Bar \\
\textbf{Another Long Label} & Foo Bar Baz \\
\end{tabular}
\end{tabular*}

\end{document}

I added showframe just to show the margins.

enter image description here