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.

It's almost embarrassing to ask: How can I vertically align the contents of one column to the top beside a second column holding nested tables. Please have a look at the minimal working example:

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{cl}
  \textbf{top/center} & \textbf{top/left} \\
  \midrule
  foo &
  \begin{tabular}{ll}
    bla & blub \\
    bla & blub \\
    bla & blub \\
  \end{tabular} \\
  \midrule
  bar &
  \begin{tabular}{ll}
    bla & blub \\
    bla & blub \\
    bla & blub \\
    bla & blub \\
  \end{tabular} \\
\end{tabular}

\end{document}

In this example, "foo" and "bar" should be aligned to the top vertically and to the center horizontally. The nested tables should be aligned top left.

The contents of the tables are filled dynamically. Thus, I cannot apply tricks like using \raisebox or something (or at least I don't know how to apply such tricks dynamically in my case).

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can use [t] option on any tabular to top align it.

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{cl}
  \textbf{top/center} & \textbf{top/left} \\
  \midrule
  foo &
  \begin{tabular}[t]{ll}
    bla & blub \\
    bla & blub \\
    bla & blub \\
  \end{tabular} \\
  \midrule
  bar &
  \begin{tabular}[t]{ll}
    bla & blub \\
    bla & blub \\
    bla & blub \\
    bla & blub \\
  \end{tabular} \\
\end{tabular}
\end{document}

enter image description here

share|improve this answer
    
Like I said, really embarrassing! ;) Thanks for your answer. That did the trick. But I find it somewhat surprising: I set the vertical alignment of the tables in the right column, which affects the alignment of "foo" and "bar" outside of these tables in the left column... oO –  Flinsch Dec 1 '11 at 12:22
    
look at this previous questions problem-with-table-vertical-alignment, how-to-vertically-center-the-text-of-the-cells. May be they help you to understand it. You can also look at Related questions on the right. –  Ignasi Dec 1 '11 at 15:20

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.