4

I am trying to add two figures in the same pages and Latex automatically puts one at the top and other at the bottom:

enter image description here

I would like to reduce the space between both, so the blank space will be at the end of the page and not in the middle. Any solution?

\begin{figure}[H]
  \centering
  \includegraphics [width=1.0\textwidth]{ff4}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}

\begin{figure}[H]
  \centering
  \includegraphics [width=1.0\textwidth]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

EDIT:

As I was asked I reproduced a minimal example, the problem happens when I have other Figure after these first two:

\documentclass[11pt,twoside]{mitthesis}

\pagestyle{plain}


\usepackage{graphicx}
\usepackage{float}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage{amsmath,nccmath}
\usepackage{amssymb}
\usepackage{array,booktabs}
\usepackage{enumerate}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\usepackage[polutonikogreek,english]{babel}
\usepackage{textgreek}

\usepackage{fancyhdr}

\pagestyle{fancy}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}



\usepackage{emptypage}

\setcounter{MaxMatrixCols}{20}

\begin{document}


\begin{figure}[H]
  \centering
  \includegraphics [width=1.0\textwidth]{ff4}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}

\begin{figure}[H]
  \centering
  \includegraphics [width=1.0\textwidth]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

\begin{figure}[H]
  \centering
  \includegraphics [width=1.0\textwidth]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

text text text text text text text text text text text text text text text 
text text text text text
text text text text text text text text text text
t  ext text text text text text text text text texttext text text text text 
text text text text texttext text text text text text text text text 
texttext text text text text text text text text text

text text text text text text text text text texttext text text text text 
text text text text texttext text text text text text text text text 
texttext text text text text text text text text text
text text text text text text text text text texttext text text text text 
text text text text text


t  ext text text text text text text text text texttext text text text text 
text text text text texttext text text text text text text text text text

\end{document}
  • Your code snipppet should produce the result you want. However, with an incomplete code, it's hard to guess what may cause this behaviour. Could you provide a complete Minimal Working Example, typically starting with \documentclass and ending with \end{document} that includes all the packages that are needed to reproduce the problem? – Tiuri Jun 3 '17 at 9:01
  • Just as note: Have a look at this post. – TeXnician Jun 3 '17 at 9:11
  • Look at the related links on the right side, mabye they are hepful ... – Bobyandbob Jun 3 '17 at 9:20
  • @TeXnician I tried with tbp and htbp and still is not working – Fernando Bastos García Jun 3 '17 at 9:22
  • 3
    you have used [H] so bad white space is inevitable, presumably you have \flushbottom in effect and so the only way to achieve that is to expand the space in the middle. just put \clearpage after the second figure. – David Carlisle Jun 3 '17 at 9:31
5

Let floats float.

If you want those two big floats in a single page, declare them with the [p] option. For the placement like you ask, change the relevant parameters.

\documentclass[11pt,twoside]{book}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage{emptypage}

\usepackage{graphicx}
\usepackage{fancyhdr}

\usepackage{lipsum}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
\setlength{\headheight}{13.6pt} % fancyhdr keeps asking this

\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpsep}{4ex}
%\setlength{\@fpbot}{0pt plus 1fil} % already default
\makeatother

\begin{document}

\lipsum[1-4]

\begin{figure}[p]
  \centering
  \includegraphics [width=1.0\textwidth,height=6cm]{example-image}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}

\begin{figure}[p]
  \centering
  \includegraphics [width=1.0\textwidth,height=6cm]{example-image}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

\begin{figure}[htp]
  \centering
  \includegraphics [width=1.0\textwidth,height=6cm]{example-image}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

\lipsum

\end{document}

enter image description here

4

This is a typical case where you can see the advantage of floats. In your figure environment you have chosen [H], which more or less means do not float. I reconstructed it with

\begin{figure}[H]
  \centering
  \includegraphics [width=0.6\textwidth]{example-image-a}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}

\begin{figure}[H]
  \centering
  \includegraphics [width=0.6\textwidth]{example-image-b}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

\begin{figure}[H]
  \centering
  \includegraphics [width=0.7\textwidth]{example-image-c}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

enter image description here

The three images you put after each other are seen as three (big) letters. Since they do not fit on one page LaTeX has no choise but to place the first two on the first page and the third on the second. Then follows the rest of the text. Now, if you instead use [htb] you allow LaTeX to place the figures where they are best suited in the text.

\begin{figure}[htb]%[H]
  \centering
  \includegraphics [width=0.6\textwidth]{example-image-a}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}

\begin{figure}[htb]%[H]
  \centering
  \includegraphics [width=0.6\textwidth]{example-image-b}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

\begin{figure}[htb]%[H]
  \centering
  \includegraphics [width=0.7\textwidth]{example-image-c}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}

enter image description here

For more info have a look at Why should the "H" option not be used in floats?

  • Sorry but definitely this is not a solution, I have more figures (7 in total) and I want them to be one after the other without text between them. So as in your second case but all the text should be after C – Fernando Bastos García Jun 3 '17 at 10:39
  • @FernandoBastosGarcía: You should not try to fight LaTeX typesetting rules, you should use them. There is a reason for having features like floats and cross references implemented. Normally that gives the best result in the end. Anyway, you can try to follow @DavidCarlisle's comment and play with \clearpage. – StefanH Jun 3 '17 at 12:31
1

Interestingly, this behaviour only appears with the twoside option of the article class. Using article without twoside, the floats will be placed as you want them to be.

However, to solve your issue: You can manually insert a \newpage after two graphs each. This will disable the automatic page filling by whitespace insertion, and each two graphs will just be positioned at the top of the respective page.

\documentclass[twoside]{article}

\usepackage[demo]{graphicx}
\usepackage{float}

\begin{document}

\begin{figure}[H]
    \centering
    \includegraphics[width=1.0\textwidth, height=0.3\textheight]{ff4}
    \caption{Derivatives in equation \ref{eq9}.}
\end{figure}

\begin{figure}[H]
    \centering
    \includegraphics[width=1.0\textwidth, height=0.3\textheight]{ff5}
    \caption{Derivatives in equation \ref{eq4}.}
\end{figure}

\newpage

\begin{figure}[H]
    \centering
    \includegraphics[width=1.0\textwidth, height=0.3\textheight]{ff5}
    \caption{Derivatives in equation \ref{eq4}.}
\end{figure}

\end{document}

enter image description here

  • 1
    twoside isn't really the issue. as I said in a comment under the question, it's \flushbottom (which is the default for twoside articles) If you specify flushbottom and make a page with just two items and stretchy glue in between then naturally that glue stretches to achieve the specified bottom baseline. – David Carlisle Jun 3 '17 at 12:06

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.