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.

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.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
1  
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

 
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.