Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent text from creeping in between figures and tables

Tags:

text

image

latex

I have a question on floats in LaTeX, such as figures in tables. In my document, I have a section of consecutive images and tables that runs across several pages. I would like to keep this section free from the text of the following chapters. However, since the images and tables don't fill up the entire pages, some lines of text are placed at the bottom of the page, which is very irritating, because the text has nothing to do with the images and tables.

The float objects are defined like this:

\begin{figure}[!htb]
    \centering 
    \includegraphics[width=0.80\textwidth]{./img/img1.jpg}
    \caption{cap1}
\end{figure}

\begin{figure}[!htb]
    \centering 
    \includegraphics[width=0.80\textwidth]{./img/img2.jpg}
    \caption{cap2}
\end{figure}

....

I presume I have to tweak the [!htb] parameters in the first line of each float section, but I am not sure in which way. Any ideas anyone?

like image 548
marw Avatar asked Apr 18 '14 19:04

marw


Video Answer


1 Answers

It seems appropriate in this instance to force a page-of-floats. Moreover, perhaps to combine a number of images within the same float, yet with different \captions. Yes, you can have multiple \includegraphics and \captions within a single figure float.

enter image description here

\documentclass{article}
\usepackage{graphicx,lipsum}
\begin{document}

\section{A section}\lipsum[1]

\clearpage

\begin{figure}[p]
  \centering
  \includegraphics[width=.8\linewidth, height=.3\textheight]{example-image-a}
  \caption{A caption}

  \vspace{\floatsep}

  \includegraphics[width=.8\linewidth, height=.3\textheight]{example-image-b}
  \caption{Another caption}
\end{figure}

\begin{figure}[p]
  \centering
  \includegraphics[width=.8\linewidth, height=.3\textheight]{example-image-a}
  \caption{A caption}

  \vspace{\floatsep}

  \includegraphics[width=.8\linewidth, height=.3\textheight]{example-image-b}
  \caption{Another caption}
\end{figure}

\clearpage

\section{Another section}\lipsum[1-3]
\end{document}

In the above example, text would be written underneath the floats if one uses the [!htb] float specifier. \clearpage flushes all pending floats, setting them on their own pages, before starting the new sectional content.

For more information on floats and parameters that could influence them, see the layouts documentation (section 6 Float layouts, p 21; specifically Figure 13: Float parameters). Also, read up on How to influence the position of float environments like figure and table in LaTeX?

like image 130
Werner Avatar answered Oct 28 '22 10:10

Werner