I have a weird layout problem in LaTeX, in which, for some reason, floats that can clearly fit on one page, are spread out on two pages, even when using big vspaces.

Layout problem

The attached picture shows the compiled result of the following code:

\caption{Test ID S2.1 - sensor 2}

\caption{Test ID S2.1 - sensor 3}

I've had this problem on several occasions with this template. Weirdly enough, if I do manage to reduce the size sufficiently to gather the floats on one page, I can still add some text on that same page, without messing up the layout. Even when the size reduction is 1 % different from what doesn't fit on the page.

This is my preamble.


%% Formatting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[USenglish]{babel} %francais, polish, spanish, ...
\usepackage{lmodern} %Type1-font for non-english texts and characters

%% Packages for Graphics & Figures %%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx} %%For loading graphic files

%% Packages for tables:
\usepackage{tabularx} % Include for better table functionality
\usepackage{tablefootnote} % Include to allow for footnotes in tables
\usepackage{multirow} % Write one entry for multiple rows and columns in tables
\usepackage{booktabs} % Insert divider rules in tables

%% Color Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength{\arrayrulewidth}{0.4mm} % witdh of lines
\setlength{\tabcolsep}{8pt} % width of each row
\definecolor{stoneblack}{rgb}{0.234375  ,  0.2734375 ,  0.29296875}
\definecolor{snow}{rgb}{0.99609375  ,  0.99609375 ,  0.99609375}
\definecolor{yellow}{rgb}{0.99609375,  0.72265625,  0}
\definecolor{black}{rgb}{0  ,  0 ,  0}
\definecolor{red2}{rgb}{0.68359375,  0.13671875,  0.37109375}

%% Math Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{siunitx} % Allows for easy unit input

%% Line Spacing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\singlespacing        %% 1-spacing (default)
%\onehalfspacing       %% 1,5-spacing
%\doublespacing        %% 2-spacing

%% Other Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[pdftex,bookmarks=true,hidelinks]{hyperref} % Allows for inserting urls with \url{}
\usepackage[absolute,overlay]{textpos} % Used for textblock on frontpage
\usepackage{lastpage} % Included so that \LastPage can be used to get pagenumber for last page
\usepackage{titlesec} % Include to control chapter and section display
\usepackage{tcolorbox} % Included to be able to make colored, rounded textboxes

%% My commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Sorry for the big code-snippet, but I am clueless as to where it goes wrong.

  • 2
    Well, you say \begin{figure}[ht], which means "here or on top". Try changing it to [htp], which adds the option to place the figure on a floats-only page. – yo' Feb 12 '18 at 12:23
  • Thanks for the suggestion, but just tried it out, and it doesn't work. – Anders Olsen Feb 12 '18 at 13:10
  • 1
    As a last resort you can always position the figure(s) manually: tex.stackexchange.com/questions/375068 – Dr. Manuel Kuehner Feb 12 '18 at 19:24
  • Eurika! The package "float" combined with [H] as a placement option does exactly what I want! Thanks a lot. :) – Anders Olsen Feb 13 '18 at 13:05

The default, and often the best, location for floats is [tbp] (top, bottom, page). There are macros you can use to change how a float may be located on a page. These, together with the default value in parentheses, are

Change these with \setcounter:

topnumber (2) max number of floats at top of page

bottomnumber (1) max number of floats at bottom of page

totalnumber (3) max number of floats on a text page

dbltopnumber (2) like topnumber for double column floats

Change the following with \renewcommand:

\topfraction (0.7) max fraction of page reserved for top floats

\bottomfraction (0.3) max fraction of page for bottom floats

\textfraction (0.2) min fraction of page that must have text

\dbltopfraction (0.7) like \topfraction for double column floats

\floatpagefraction (0.5) min fraction of a float page that must have float(s)

\dblfloatpagefraction (0.5) like \floatpagefraction for double column floats

There are also macros for controlling the spacing around floats.

The memoir class documentation (< texdoc memoir) gives more details in its section 10.4 Where LaTeX puts floats.

Adjust the above parameters until you get the layout that suits you.

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.