24

As per question title, how can I convert the following table to longtable with the same result (but being able to break across pages)?

\begin{center}
\renewcommand*{\arraystretch}{1.5}
\begin{table}[h]
    \begin{tabular}{ | p{1.9cm} | p{9.9cm} | p{1.7cm} |  }
    \hline
    {\bf First} & {\bf Second} & {\bf Third} \\ \hline

    Text   & Other Text    & Other Text 2 \\ 
           & Other Text 3  &              \\ 
           & Other Text 4  &              \\ \hline

    Text 5 & Other Text 6  & Other Text 7 \\ 
           & Other Text 8  &              \\ 
           & Other Text 9  &              \\ \hline    
    \end{tabular}

\caption{My Table}
  \label{myTable}
\end{table}
\end{center}

There are many more lines in my table.

34

Add \usepackage{longtable} to the preamble, remove table environment and change tabular to longtable.

enter image description here

\documentclass{article}
\usepackage[a6paper,vmargin=6cm,hmargin=5mm]{geometry}
\usepackage{array,longtable}
\renewcommand*{\arraystretch}{1.5}

\begin{document}
    \begin{longtable}{|*3{p{2cm}|}}
    \hline
    {\bf First} & {\bf Second} & {\bf Third} \\ \hline

    Text   & Other Text    & Other Text 2 \\ 
           & Other Text 3  &              \\ 
           & Other Text 4  &              \\ \hline

    Text 5 & Other Text 6  & Other Text 7 \\ 
           & Other Text 8  &              \\ 
           & Other Text 9  &              \\ \hline    
    \end{longtable}
\end{document}

Adding caption and label is also supported, it is very easy. Read the details Sample Long Table.

  • 2
    Thanks, it worked! I had to move the caption to the beginning and the label as well. – Weslei Jul 17 '11 at 17:25
  • @Weslei: Visit the given link, adding caption and label is easy. :-) The given example is self-explanatory. – xport Jul 17 '11 at 17:28

Your Answer

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

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