5

I would like the content of the first and second column to be vertically aligned on top, since the 3rd column will contain a bunch of data so it would not be readable if vertically centered (which is the case right now).

Here is a MWE:

\documentclass{minimal}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}

\begin{longtable}[t]{p{1cm}p{4cm}p{6cm}}
\toprule
C1    & C2    & C3 \\
\midrule
Data1 & Data2 & 
                \begin{tabular}{ll}
                foo & bar \\
                foo & bar \\
                fo & bar
                \end{tabular} \\

% bis repetita...
\bottomrule

\end{longtable}
\end{document}

How can I vertically align on top the content of the C1 and C2 columns ?

1 Answer 1

3

you put the t on the wrong place (longtable doesn't take t anyway it takes l c r)

You want it on the tabular in the third column so that entry is top aligned with the first two columns. I also added @{} so you do not get double cell padding from the outer and inner table.

\documentclass{minimal}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}

\begin{longtable}{p{1cm}p{4cm}p{6cm}}
\toprule
C1    & C2    & C3 \\
\midrule
Data1 & Data2 & 
                \begin{tabular}[t]{@{}ll@{}}
                foo & bar \\
                foo & bar \\
                fo & bar
                \end{tabular} \\

% bis repetita...
\bottomrule

\end{longtable}
\end{document}
3
  • I really need 100 \begin{tabular}[t] for 100 lines of data? Apr 21, 2021 at 10:07
  • @Thomas I don't understand your comment. you don't normally have nested tabular at all. this old questions was along how to align a nested tabular if you do have one Apr 21, 2021 at 12:27
  • Oh. Sorry. I was looking for a way to valign=top all cells in the longtable. Mine are all valign=center. Apr 21, 2021 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy