[Tex/LaTex] How to make whole longtable align to the top

longtabletablesvertical alignment

\item
\begin{longtable}[l]{l l}
1 & 2 \\
3 & 4 \\
5 & 6 \\
\end{longtable}

Inside an enumerate environment, the above code produces a longtable that is not beside the item number but rather before it. If I don't need a multi-page table, the following does exactly what I want:

\item
\begin{tabular}[t]{l l}
1 & 2 \\
3 & 4 \\
5 & 6 \\
\end{tabular}

but I do need a multi-page table. How to make longtable vertically align to the top (like the tabular example)? I am open to replacing longtable with tabularx, xtabular, or longtabu if they can do this.

Best Answer

Elaborating a little on Harish Kumar's answer, you'll probably want the longtable to the left.

To do that, don't use the optional argument for longtable but issue

\setlength{\LTleft}{\leftmargin}

This should give you what you want:

\documentclass{article}
\usepackage{longtable}
\begin{document}
  \begin{enumerate}
    \item \mbox{}\vspace*{-1.68\baselineskip}\setlength{\LTleft}{\leftmargin}
        \begin{longtable}{l l}
            1 & 2 \\
            3 & 4 \\
            5 & 6 \\
        \end{longtable}
    \item another item
  \end{enumerate}
\end{document} 

Output

enter image description here

or, if you prefer perfect alignment (thanks Mico for the comment)

\documentclass{article}
\usepackage{longtable}
\begin{document}
  \begin{enumerate}
    \item \mbox{}\vspace*{-1.68\baselineskip}\setlength{\LTleft}{\leftmargin}
        \begin{longtable}{@{} l l}
            1 & 2 \\
            3 & 4 \\
            5 & 6 \\
        \end{longtable}
    \item another item
  \end{enumerate}
\end{document} 

Output

enter image description here

Related Question