[Tex/LaTex] How to interrupt longtable to place float (figure)

floatslongtablepositioning

I am writing a document describing a process step by step. After trying with enumerate (which did not look so appealing) I switched to longtable.

This longtable can span more than two full pages.

The problem I ran into is illustrated by the MWE below. Since there is not sufficient space on the first page to place the figure, it is moved after the longtable. Is there a way of placing floats so they interrupt the longtable? The figure should be on the top of page 2.

Or is there a different LaTeX macro that will allow me to typeset the process steps in the same way but will be treated as text (and can thus be interrupted by floats)? Requirement is that the step number can be referenced.

\documentclass[a4paper,10pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{paralist}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{lipsum}


%% Compact list to be used within tabular for step listing
\newenvironment{PCitem}
{
  \begin{minipage}[t]{\linewidth}\begin{compactitem}
} {
  \end{compactitem}\end{minipage}
}

%% counter step listing, right aligned
\newcounter{PCstep}
\newcommand{\PC}{%
    \refstepcounter{PCstep}%
    \hfill\thePCstep.}


%% dummy table content     
\newcommand{\tablecontent}{
\PC & Doing this & Take care!\vspace{1ex}\\

\PC & Doing that & Doing that is very complicated and is divided into the following steps

\begin{PCitem}
\item Cleaning
\item Making dirty
\item Cleaning, again
\item Making dirty, again
\item oh stop it!
\end{PCitem}\vspace{1ex}\\
}



\begin{document}

\section{Page almost filled, so no space for float}

\lipsum[3-6]

\section{Beginning}

This is some text, and soon there will be a longtable spanning three pages. But before Figure~\ref{fig:label} is inserted, which should be ideally be placed on the next page, effectively interrupting the longtable.


%% Figure
\begin{figure}[!tb] % Here Top Bottom
\centering
  \begin{center}
  \rule{400pt}{100pt}
  \caption{This figure is actually supposed to be placed before the longtable.} 
  \label{fig:label}
  \end{center}    
\end{figure}


%% Longtable
\begin{longtable}{p{25pt}>{\textbf\bgroup}p{117pt}<{\egroup}p{240pt}}

& \textbf{\itshape Step} & \textbf{\itshape Details} \vspace{1ex}\endfirsthead

\tablecontent
\tablecontent
\tablecontent
\tablecontent
\tablecontent
\tablecontent
\tablecontent
\tablecontent
\tablecontent

\end{longtable}

\end{document}

Best Answer

can't really interupt the longtable but you can put \clearpage before it to stop the float floating past it.

Incidentally the optional argument

[!tb] % Here Top Bottom

increases the chance of the float going to the end of the document as it does not allow p also, despite the comment it doesn't allow here floats (you need to include h) for that.

Related Question