[Tex/LaTex] Tabular, parbox, vertical alignment

line-breakingtablesvertical alignment

What i want to achieve is really simple:

I want to be able to align cell content at the top (which is the default behavior of tabular) while being able to manually break lines (and anything you could normally do in a paragraph environment). For instance:

enter image description here

I would expect this to work:

\begin{tabular}{|r|l|}
    \hline
    \parbox{3cm}{\raggedleft First Line\\SecondLine} &
    \parbox{5cm}{\textbf{First line goes here}\\
                 Second line would be here\\
                 And so on, ...\\
                 ... until the very end.} \\
    \hline
\end{tabular}

However this produces the following result:

enter image description here

The left parbox is vertically centered. During the past two days, I've searched the whole LaTeX community in vain for a solution to this problem. I've come across solutions consisting in the use of raisebox that force you to manually grope for the right difference value depending on the content of the two cells. That is no solution to me. I want this to be automatic as it is in any document editor… I would be very surprised if LaTeX didn't allow this kind of construction!

Regards

Best Answer

You can adjust the inner-text using the optional parameters for parbox

\parbox[position][height][inner-pos]{width}{text}

Here is a minimal example.

\documentclass{article}
\begin{document}
\begin{tabular}{|r|l|}
    \hline
    \parbox[t][][t]{3cm}{\raggedleft First Line\\SecondLine} &
    \parbox[t][][t]{5cm}{\textbf{First line goes here}\\
                 Second line would be here\\
                 And so on, ...\\
                 ... until the very end.} \\
    \hline
\end{tabular}
\end{document}

You can read more at TUG's LaTeX tutorial

Related Question