[Tex/LaTex] Aligning two text boxes with a few lines

horizontal alignmentline-breakingvertical alignment

Here are the two text boxes:

\begin{tabular}{l@{}}
     Date: 3 Jan. 2500  \\
     Place: Moon \\
\end{tabular}


\null\hfill\begin{tabular}{l@{}}
     Prof. Neil Armstrong \\
     Department of Moon Studies \\
     Moon University
\end{tabular}

What is the easy way to make those boxes start on the same line? The first box should be on the right, and second one should be on the left. The text in the box should be flushed left. The first two lines of text in both the boxes should be on the same horizontal line.

Best Answer

First of all remove the empty line between them, they are producing a paragraph break. The tabulars can be top align using the optional argument of tabular.

Putting a \hfill between both tabulars without any empty lines should already do the trick. You can however also use an \hbox with a fixed width to ensure that they are always on the same line.

\documentclass{article}

\begin{document}
\noindent
\leavevmode\hbox to \linewidth{%
\begin{tabular}[t]{l@{}}
     Date: 3 Jan. 2500  \\
     Place: Moon \\
\end{tabular}
\hfill
\begin{tabular}[t]{l@{}}
     Prof. Neil Armstrong \\
     Department of Moon Studies \\
     Moon University
\end{tabular}%
}

\end{document}

Output:

enter image description here

Related Question