Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

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.

share|improve this answer

This is a duplicate of a question posted at LaTeX Community. I'll post the same thing I did there:

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|>{\raggedleft}p{3cm}|>{\raggedright\arraybackslash}p{5cm}|}
\hline
First line\\ Second line
&
\textbf{First line goes here}\newline
Second line would be here\newline
And so on, \ldots \newline
\ldots\ until the very end. \\
\hline
\end{tabular}
\end{document}

But there is more discussion there.

share|improve this answer
\documentclass{article}
\usepackage{array,ragged2e}

\begin{document}
\begin{tabular}{|>{\RaggedLeft}p{3cm}|>{\RaggedRight}p{5cm}|}\hline
 First Line\newline 
 SecondLine             
&
 \textbf{First line goes here}\newline
  Second line would be here\newline
  And so on, ...\newline
  ... until the very end. \tabularnewline\hline
\end{tabular}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.