[Tex/LaTex] How to remove empty pages in document class article

page-breakingsectioning

Between sections/section or sections/subsection I have empty pages if a pre-section or pre-subsection does fill one page.
My document class:

\documentclass[9pt]{article}

How can I avoid this?
Thanks for help.

Here is the minimal example, which produces an emtpy page between chapter 1 and 2:

\begin{document}
\section{Chapter1}
\begin{table}[H]
\begin{tabular}{ll}
\hline
x & y  \\ 
\hline
1 & 2  \\ \hline
\end{tabular}
\end{table}

\section{Chapter2}
\begin{figure}[H]
\setkeys{Gin}{width=1.4\textwidth}
\includegraphics[angle=90]{figure.pdf}
\end{figure}
\end{document}

If I change width to 1.3 or change angle to 0 there is no empty page between chapter 1 and 2.

Best Answer

Using H as a float specifier implies you're using the float package, which causes floats to stop floating or "really means "here" (and starts a new page first if necessary)" (see How to influence the position of float environments like figure and table in LaTeX?). So, you have two options:

  1. Enlarge your document real estate using the geometry package. For example,

    \usepackage[margin=1cm]{geometry}% http://ctan.org/pkg/geometry
    

    would increase the text block as far as is needed (in all directions) and leave only a 1cm margin between the text block and the page boundary. This will allow you to fit more on a page, perhaps allowing the figure to be set where you want it to.

    Note that this option will have no effect if you're using a text block related length (like \textwidth), since the proportional modification would translate to the figure as well.

  2. Modify the image dimensions to make it fit on the page. For example,

    \usepackage{graphicx}% http://ctan.org/pkg/graphicx
    %...
    \resizebox{\textwidth}{!}{\includegraphics[angle=90]{figure}}
    

    would make sure that the resulting turned image fits within the \textwidth block. Of course, if it is taller than the text block, constraining the height would be more appropriate. Using

    \resizebox{!}{\textheight}{\includegraphics[angle=90]{figure}}
    

    in your case would not suffice, since the non-floating nature of an "H-figure" immediately after a \section causes LaTeX to keep them together. As such, you have less than \textheight to play with in terms of the figure height.