1

I have a longtable that breaks over two pages. It is referenced in a paragraph that also breaks over a page, and continues at the top of the next.

My issue is that I need to make it so the longtable occurs at the top of the page immediately following its reference in the paragraph. That is, I need it to interrupt the paragraph by being the first thing to appear on the second page.

None of the placement options seem to make any difference on where the longtable is being placed.

Here is a minimum example of the table is currently:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{longtable}

\title{test}
\author{John Smith}
\date{December 2014}

\begin{document}

\maketitle

\section{Introduction}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus luctus et metus vel pulvinar. Nunc fringilla at sapien at vestibulum. Phasellus ultricies elit metus, sit amet mattis mauris tristique in. Donec mollis turpis bibendum neque eleifend mollis. Donec efficitur ultricies mattis. Integer sagittis porta velit sit amet mattis. Praesent id dui in velit euismod tincidunt. Sed condimentum sapien magna, ut pharetra justo elementum vitae. Mauris malesuada lacinia volutpat. Proin quis mauris mattis tellus commodo mattis. Nam quis augue ut lacus commodo tincidunt. Cras fringilla urna a faucibus bibendum. Etiam vestibulum pharetra orci sit amet pharetra. Vestibulum quis quam aliquet TABLE \ref{tab:1} neque rhoncus auctor. Pellentesque feugiat justo sed dui interdum elementum. Vestibulum ut quam tincidunt, scelerisque est eget, aliquet dui. Vivamus vestibulum, libero a vestibulum pulvinar, dui lorem bibendum lorem, vitae blandit quam mauris vel risus. Phasellus vehicula dolor sagittis libero hendrerit convallis. Nam leo magna, placerat sed erat nec, sollicitudin varius augue. Nullam viverra et metus id pulvinar. Mauris nec ante sed turpis ornare interdum. Quisque tortor nisl, aliquam quis tortor eu, eleifend condimentum lorem. Duis metus erat, lacinia quis metus a, varius egestas elit. Aenean commodo pellentesque lectus, a venenatis purus consequat et. Cras ultrices tellus eget laoreet rutrum. Proin vitae dui vulputate, eleifend nunc a, suscipit odio. Morbi finibus, dolor sit amet pharetra dapibus, nisl urna pulvinar arcu, et elementum tellus augue eget purus. Maecenas viverra ipsum non maximus efficitur.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus luctus et metus vel pulvinar. Nunc fringilla at sapien at vestibulum. Phasellus ultricies elit metus, sit amet mattis mauris tristique in. Donec mollis turpis bibendum neque eleifend mollis. Donec efficitur ultricies mattis. Integer sagittis porta velit sit amet mattis. Praesent id dui in velit euismod tincidunt. Sed condimentum sapien magna, ut pharetra justo elementum vitae. Mauris malesuada lacinia volutpat. Proin quis mauris mattis tellus commodo mattis. Nam quis augue ut lacus commodo tincidunt. Cras fringilla urna a faucibus bibendum. Etiam vestibulum pharetra orci sit amet pharetra. Vestibulum quis quam aliquet neque rhoncus auctor. Pellentesque feugiat justo sed dui interdum elementum. Vestibulum ut quam tincidunt, scelerisque est eget, aliquet dui. Vivamus vestibulum, libero a vestibulum pulvinar, dui lorem bibendum lorem, vitae blandit quam mauris vel risus. Phasellus vehicula dolor sagittis libero hendrerit convallis. Nam leo magna, placerat sed erat nec, sollicitudin varius augue. Nullam viverra et metus id pulvinar. Mauris nec ante sed turpis ornare interdum. Quisque tortor nisl, aliquam quis tortor eu, eleifend condimentum lorem. Duis metus erat, lacinia quis metus a, varius egestas elit. Aenean commodo pellentesque lectus, a venenatis purus consequat et. Cras ultrices tellus eget laoreet rutrum. Proin vitae dui vulputate, eleifend nunc a, suscipit odio. Morbi finibus, dolor sit amet pharetra dapibus, nisl urna pulvinar arcu, et elementum tellus augue eget purus. Maecenas viverra ipsum non maximus efficitur.

\begin{longtable}[!t]{l l l}
    \caption{Test longtable.} \label{tab:1} \\
  % Here are our column headings
    \hline
    \hline
    Header1 & Header2 & Header3 \\
    \hline
    \endfirsthead

  % Here is the caption on other pages
    \caption*{\tablename\ \thetable{} (Continued)} \\
    \hline
    \hline
    Header1 & Header2 &  Header3\\
    \hline
    \endhead

    \hline
    \multicolumn{3}{r}{\textbf{(table continues)}}
    \endfoot

    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\


    \hline
\end{longtable}

\end{document}

To highlight the problem again: I would need the longtable positioned at the top of page two, displacing the text until after the longtable.

Is this possible?

Thank you.

  • 1
    longtable environments do not float. They stay where you put them. So either you need to place at the point in the text you want. Or you need to use a float instead. In general, floats cannot break over pages. So if the table is longer than a page, you cannot use a float. – cfr Dec 4 '14 at 22:33
  • neither ! not t is legal in that optional argument. – David Carlisle Dec 4 '14 at 22:46
  • Thank you two for clarifying; that makes complete sense. – ionick Dec 5 '14 at 3:34
5

longtable is not a floating environment. You can however delay starting the table using afterpage.

\begin{filecontents}{\jobname.lt1}
\begin{longtable}{l l l}
    \caption{Test longtable.} \label{tab:1} \\
  % Here are our column headings
    \hline
    \hline
    Header1 & Header2 & Header3 \\
    \hline
    \endfirsthead

  % Here is the caption on other pages
    \caption*{\tablename\ \thetable{} (Continued)} \\
    \hline
    \hline
    Header1 & Header2 &  Header3\\
    \hline
    \endhead

    \hline
    \multicolumn{3}{r}{\textbf{(table continues)}}
    \endfoot

    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\
    content & content & content \\


    \hline
\end{longtable}
\end{filecontents}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{afterpage,longtable}

\title{test}
\author{John Smith}
\date{December 2014}

\begin{document}

\maketitle

\section{Introduction}

\afterpage{\input{\jobname.lt1}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus luctus et metus vel pulvinar. Nunc fringilla at sapien at vestibulum. Phasellus ultricies elit metus, sit amet mattis mauris tristique in. Donec mollis turpis bibendum neque eleifend mollis. Donec efficitur ultricies mattis. Integer sagittis porta velit sit amet mattis. Praesent id dui in velit euismod tincidunt. Sed condimentum sapien magna, ut pharetra justo elementum vitae. Mauris malesuada lacinia volutpat. Proin quis mauris mattis tellus commodo mattis. Nam quis augue ut lacus commodo tincidunt. Cras fringilla urna a faucibus bibendum. Etiam vestibulum pharetra orci sit amet pharetra. Vestibulum quis quam aliquet TABLE \ref{tab:1} neque rhoncus auctor. Pellentesque feugiat justo sed dui interdum elementum. Vestibulum ut quam tincidunt, scelerisque est eget, aliquet dui. Vivamus vestibulum, libero a vestibulum pulvinar, dui lorem bibendum lorem, vitae blandit quam mauris vel risus. Phasellus vehicula dolor sagittis libero hendrerit convallis. Nam leo magna, placerat sed erat nec, sollicitudin varius augue. Nullam viverra et metus id pulvinar. Mauris nec ante sed turpis ornare interdum. Quisque tortor nisl, aliquam quis tortor eu, eleifend condimentum lorem. Duis metus erat, lacinia quis metus a, varius egestas elit. Aenean commodo pellentesque lectus, a venenatis purus consequat et. Cras ultrices tellus eget laoreet rutrum. Proin vitae dui vulputate, eleifend nunc a, suscipit odio. Morbi finibus, dolor sit amet pharetra dapibus, nisl urna pulvinar arcu, et elementum tellus augue eget purus. Maecenas viverra ipsum non maximus efficitur.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus luctus et metus vel pulvinar. Nunc fringilla at sapien at vestibulum. Phasellus ultricies elit metus, sit amet mattis mauris tristique in. Donec mollis turpis bibendum neque eleifend mollis. Donec efficitur ultricies mattis. Integer sagittis porta velit sit amet mattis. Praesent id dui in velit euismod tincidunt. Sed condimentum sapien magna, ut pharetra justo elementum vitae. Mauris malesuada lacinia volutpat. Proin quis mauris mattis tellus commodo mattis. Nam quis augue ut lacus commodo tincidunt. Cras fringilla urna a faucibus bibendum. Etiam vestibulum pharetra orci sit amet pharetra. Vestibulum quis quam aliquet neque rhoncus auctor. Pellentesque feugiat justo sed dui interdum elementum. Vestibulum ut quam tincidunt, scelerisque est eget, aliquet dui. Vivamus vestibulum, libero a vestibulum pulvinar, dui lorem bibendum lorem, vitae blandit quam mauris vel risus. Phasellus vehicula dolor sagittis libero hendrerit convallis. Nam leo magna, placerat sed erat nec, sollicitudin varius augue. Nullam viverra et metus id pulvinar. Mauris nec ante sed turpis ornare interdum. Quisque tortor nisl, aliquam quis tortor eu, eleifend condimentum lorem. Duis metus erat, lacinia quis metus a, varius egestas elit. Aenean commodo pellentesque lectus, a venenatis purus consequat et. Cras ultrices tellus eget laoreet rutrum. Proin vitae dui vulputate, eleifend nunc a, suscipit odio. Morbi finibus, dolor sit amet pharetra dapibus, nisl urna pulvinar arcu, et elementum tellus augue eget purus. Maecenas viverra ipsum non maximus efficitur.



\end{document}
  • Thank you for point out this package, I think I'll be able to work with manually breaking the paragraph. – ionick Dec 5 '14 at 3:35

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.