26

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.

1 Answer 1

37

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
  • 2
    Thanks, it worked! I had to move the caption to the beginning and the label as well.
    – Weslei
    Jul 17, 2011 at 17:25
  • @Weslei: Visit the given link, adding caption and label is easy. :-) The given example is self-explanatory. Jul 17, 2011 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .