Document ClassesText does not flow around a landscape-oriented longtable

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
HelenPol
Posts: 1
Joined: Wed Aug 27, 2008 6:40 pm

Text does not flow around a landscape-oriented longtable

Post by HelenPol »

Hi. I'm rather new to LaTeX so pardon me if my posts seem rather naive..

I'm writing a paper which has long and wide tables (of numerical results). I used the longtable and pdflscape packages, to make my multi-page wide tables. Everything about the table works well, but the main text does not flow around the two landscape-pages on which the table appears. That is, in my .tex file, I have some text (blah blah blah-1), then the table, and then I have some text (blah blah blah-2) after the table. I do not intend for the (blah blah blah-2) to necessarily come after the table in the paper. I do not mind whether it comes before or after the table. I would like LaTeX to typeset it nicely as appropriate. My problem though is that the text does not get typeset properly. The landscaped-longtable seems to cause a page break exactly where it is placed, and any text that comes after the landscaped-longtable gets put after the longtable in the typesetted text.

Is there a way for me to be able to make the text flow around the longtable, or am I doomed to have to manually try to fit in my text so that I do not end up with ugly big empty spaces before the landcsaped-longtable in my final typesetted paper ?

I would really appreciate any advice, comments, suggestions, anything ! By the way, I'm using TeXShop on a Mac.

Thanks !

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Text does not flow around a landscape-oriented longtable

Post by Juanjo »

Try this minimal example:

Code: Select all

\documentclass{article}
\usepackage{array,longtable,lipsum,afterpage,pdflscape}
\begin{document}
\lipsum[1]
\afterpage{
\begin{landscape}
\begin{longtable}{|c|>{\raggedright}p{0.7\linewidth}|}
  \hline
  A & \lipsum[1] \tabularnewline \hline
  B & \lipsum[2] \tabularnewline \hline
  C & \lipsum[3] \tabularnewline \hline
  D & \lipsum[4] \tabularnewline \hline
\end{longtable}
\end{landscape}
}
\lipsum[2-8]
\end{document}
The \lipsum command produces blind text. As you can see, the text written by the \lipsum command after the table flows to the first page. The trick is the use of the \afterpage command, which delays the execution of the code included in its mandatory argument until the corresponding page is completed.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply