2

UPDATE. The combination of the longtable and figure given below results in misplacement of the following text. The text must go to the third page, but it doesn't. Instead of this it crosses the border of the second page.

\documentclass[a4paper]{article}
\usepackage[cm]{fullpage}
\usepackage[dvips]{graphicx}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}

\lipsum[1-8]

\begin{figure}[ht]
  \rule{7cm}{7cm}\\
  Picture 1.
\end{figure}

\lipsum[1-2]

 \begin{longtable}{|c|}
    \hline      
     N \\
    \endfirsthead 
        \hline      
    1  \\
    \hline      
    2  \\
    \hline      
    3  \\
    \hline      
    4  \\
    \hline      
    5  \\
    \hline      
    6  \\
    \hline      
    7  \\
    \hline      
    8  \\
    \hline      
    9  \\
    \hline      
    10  \\
    \hline
  \end{longtable}   

\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]

\end{document}
David Carlisle
  • 757,742
Ivan Bychkov
  • 731
  • 1
  • 6
  • 13

1 Answers1

1

Temporary answer, might help someone else making an answer. I'll update or delete later.

This looks like it should be a repeat of

longtabu and floats: wrong table breaks on pages with floats

But the following is supposed to be equivalent to applying the patch in the latex bug database, but doesn't appear to fix your test case, I'll look later but I'm out of time. If anyone else answers I'll delete this non answer.

\documentclass[a4paper]{article}
\usepackage[cm]{fullpage}
\usepackage[dvips]{graphicx}
\usepackage{longtable}
\usepackage{lipsum}

\makeatletter

\def\LT@start{%
  \let\LT@start\endgraf
  \endgraf\penalty\z@\vskip\LTpre
  \dimen@\pagetotal
  \advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
  \advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
  \advance\dimen@ \ht\LT@foot
  \dimen@ii\vfuzz
  \vfuzz\maxdimen
    \setbox\tw@\copy\z@
    \setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
    \setbox\tw@\vbox{\unvbox\tw@}%
  \vfuzz\dimen@ii
  \advance\dimen@ \ht
        \ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
  \advance\dimen@\dp
        \ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
  \advance\dimen@ -\pagegoal
  \ifdim \dimen@>\z@\vfil\break\fi
      \global\@colroom\@colht
  \ifvoid\LT@foot\else
%    \advance\vsize-\ht\LT@foot
    \global\advance\vsize-\ht\LT@foot
%
    \global\advance\@colroom-\ht\LT@foot
    \dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
    \maxdepth\z@
  \fi
  \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
  \output{\LT@output}}


\def\endlongtable{%
  \crcr
  \noalign{%
    \let\LT@entry\LT@entry@chop
    \xdef\LT@save@row{\LT@save@row}}%
  \LT@echunk
  \LT@start
  \unvbox\z@
  \LT@get@widths
  \if@filesw
    {\let\LT@entry\LT@entry@write\immediate\write\@auxout{%
      \gdef\expandafter\noexpand
        \csname LT@\romannumeral\c@LT@tables\endcsname
          {\LT@save@row}}}%
  \fi
  \ifx\LT@save@row\LT@@save@row
  \else
    \LT@warn{Column \@width s have changed\MessageBreak
             in table \thetable}%
    \LT@final@warn
  \fi
  \endgraf\penalty -\LT@end@pen
%
  \ifvoid\LT@foot\else
    \global\advance\vsize\ht\LT@foot
    \global\advance\@colroom\ht\LT@foot
    \dimen@\pagegoal\advance\dimen@\ht\LT@foot\pagegoal\dimen@
  \fi
%
  \endgroup
  \global\@mparbottom\z@
%  \pagegoal\vsize
  \endgraf\penalty\z@\addvspace\LTpost
  \ifvoid\footins\else\insert\footins{}\fi}


\def\LT@output{%
  \ifnum\outputpenalty <-\@Mi
    \ifnum\outputpenalty > -\LT@end@pen
      \LT@err{floats and marginpars not allowed in a longtable}\@ehc
    \else
      \setbox\z@\vbox{\unvbox\@cclv}%
      \ifdim \ht\LT@lastfoot>\ht\LT@foot
        \dimen@\pagegoal
%
        \advance\dimen@\ht\LT@foot
%
        \advance\dimen@-\ht\LT@lastfoot
        \ifdim\dimen@<\ht\z@
          \setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
          \@makecol
          \@outputpage
%
\global\vsize\@colroom
%
          \setbox\z@\vbox{\box\LT@head}%
        \fi
      \fi
%      \global\@colroom\@colht
%      \global\vsize\@colht
%      \vbox
%        {\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
     \unvbox\z@\ifvoid\LT@lastfoot\copy\LT@foot\else\box\LT@lastfoot\fi
%
    \fi
  \else
    \setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
    \@makecol
    \@outputpage
      \global\vsize\@colroom
    \copy\LT@head\nobreak
  \fi}



\makeatother
\begin{document}

\lipsum[1-8]

\begin{figure}[ht]
  \rule{7cm}{7cm}\\
  Picture 1.
\end{figure}

\lipsum[1-2]

 \begin{longtable}{|c|}
    \hline      
     N \\
    \endfirsthead 
        \hline      
    1  \\
    \hline      
    2  \\
    \hline      
    3  \\
    \hline      
    4  \\
    \hline      
    5  \\
    \hline      
    6  \\
    \hline      
    7  \\
    \hline      
    8  \\
    \hline      
    9  \\
    \hline      
    10  \\
    \hline
  \end{longtable}   

\lipsum[1-2]

% Wrong figure!!!
\begin{figure}[ht]
  This figure goes out of paper. \\ 
  \rule{5cm}{10cm}\\
\end{figure}

\end{document}
David Carlisle
  • 757,742