Latex. Pagebreak into a table

33.6k views Asked by At

I've made a longtable in Latex but it is too long to be in one page, how can I insert a pagebreak to continue the table into the next page?

I've tried with the \pagebreak and it didn't work...

enter image description here

Here it is the code:

\begin{table} [h]
\footnotesize 
\setlength\LTleft{-30pt}
\setlength\LTright{-30pt}   
\caption{ Communicate static definition} 
\centering 
\begin{longtable}{@{\extracolsep{\fill}}c c c c@{}} 
\hline\hline %inserts double horizontal lines
Segment & Meaning & Usage & Card.\\ [0.5ex]  
\hline
MSH & Message Header & R & [1..1]\\
[{SFT}] & Software Segment & X & [0..0]\\
\{ & PATIENT RESULT begin & & \\ \relax
[ & PATIENT BEGIN & & \\
PID & Patient Identification & R & [1..1]\\ \relax
[PID1] & Aditional Demographics & X & [0..0]\\ \relax
..[\{NTE\}] & Notes and Comments & X & [0..0]\\ \relax
..[\{NK1\}] & Next of Kin/Associated Parties & X & [0..0]\\
\{ & VISIT begin & & \\
PV1 & Patient Visit & O & [0..1]\\ \relax
[PV2] & Patient Visit Additional Info & X & [0..0]\\ \relax
] & VISIT end & & \\ \relax
] & PATIENT end & & \\ \relax
\{ & ORDER OBSERVATION begin & & \\ \relax
[ORC] & Order Common & O & [0..1]\\
OBR & Observation Request & R & [1..1]\\ \relax
[\{NTE\}] & Notes and Comments & O & [0..1]\\ \relax
[\{&TIMING QTY begin & & \\
TQ1 & Timming/Quantity & O & [0..1]\\  \relax
[\{TQ2\}] & Timming/Quantity Order Sequence & X & \\ \relax
\{] & TIMING QTY end & & \\ \relax
[CTD] & Contact Data & X & [0..0]\\ \relax
[\{ & OBSERVATION begin & & \\
OBX & Observation Result & R & [1..1]\\ \relax
[\{NTE\}] & Notes and Comments & & \\ \relax
\}] & OBSERVATION end & & \\ \relax
[\{FT1\}] & Financial Transaction & X & [0..0]\\ \relax
[\{CT1\}] & Cllinical Trial Identification & X & [0..0]\\ \relax
[\{ & SPECIMEN begin & & \\ \relax
SPM & Specimen & X & [0..0]\\ \relax
[\{OBX\}] & Observation related to Specimen & X & [0..0]\\ \relax
\}] & SPECIMEN end & & \\ \relax
\} & ORDER OBSERVATION end & & \\ \relax
\} & PATIENT RESULT end & & \\ \relax
[DSC] & Continuation Pointer & X & [0..0]\\
[1ex] % [1ex] adds vertical space
\hline %inserts single line
\end{longtable}
\label{table:nonlin} % is used to refer this table in the text
\end{table}
1

There are 1 answers

2
Werner On BEST ANSWER

In order to have a longtable break across the page boundary, you need to place it on its own and not inside a floating table environment; the latter is unbreakable. Here is an example that shows you how to use it:

enter image description here

\documentclass{article}
\usepackage{longtable}
\usepackage{lipsum}% Just for this example
\begin{document}

\lipsum[1-2]

\begingroup
  \footnotesize 
  \setlength\LTleft{-30pt}%
  \setlength\LTright{-30pt}%
  \centering 
  \begin{longtable}{@{\extracolsep{\fill}}c c c c@{}} 
    \caption{Communicate static definition\label{table:nonlin}}\\ % is used to refer this table in the text
    \hline\hline %inserts double horizontal lines
    Segment & Meaning & Usage & Card.\\ [0.5ex]  
    \hline
    MSH&Message Header&R&[1..1]\\ \relax
    [{SFT}] &Software Segment&X&[0..0]\\
    \{&PATIENT RESULT begin&&\\ \relax
    [&PATIENT BEGIN&&\\
    PID&Patient Identification&R&[1..1]\\ \relax
    [PID1]&Aditional Demographics&X&[0..0]\\ \relax
    ..[\{NTE\}]&Notes and Comments&X&[0..0]\\ \relax
    ..[\{NK1\}]&Next of Kin/Associated Parties&X&[0..0]\\
    \{&VISIT begin&&\\
    PV1&Patient Visit&O&[0..1]\\ \relax
    [PV2]&Patient Visit Additional Info&X&[0..0]\\
    ]&VISIT end&&\\
    ]&PATIENT end&&\\
    \{&ORDER OBSERVATION begin&&\\ \relax
    [ORC]&Order Common&O&[0..1]\\
    OBR&Observation Request&R&[1..1]\\ \relax
    [\{NTE\}]&Notes and Comments&O&[0..1]\\ \relax
    [\{&TIMING QTY begin&&\\
    TQ1&Timming/Quantity&O&[0..1]\\ \relax
    [\{TQ2\}]&Timming/Quantity Order Sequence&X&\\
    \{]&TIMING QTY end&&\\ \relax
    [CTD]&Contact Data&X&[0..0]\\ \relax
    [\{&OBSERVATION begin&&\\
    OBX&Observation Result&R&[1..1]\\ \relax
    [\{NTE\}]&Notes and Comments&&\\ \relax
    \}]&OBSERVATION end&&\\ \relax
    [\{FT1\}]&Financial Transaction&X&[0..0]\\ \relax
    [\{CT1\}]&Cllinical Trial Identification&X&[0..0]\\ \relax
    [\{&SPECIMEN begin&&\\ \relax
    SPM&Specimen&X&[0..0]\\ \relax
    [\{OBX\}]&Observation related to Specimen&X&[0..0]\\ \relax
    \}]&SPECIMEN end&&\\ \relax
    \}&ORDER OBSERVATION end&&\\ \relax
    \}&PATIENT RESULT end&&\\ \relax
    [DSC]&Continuation Pointer&X&[0..0]\\
    [1ex] % [1ex] adds vertical space
    \hline %inserts single line
  \end{longtable}
\endgroup

\lipsum[1-2]

\end{document}