LaTeX forum ⇒ Graphics, Figures & TablesImage appears on next page if I use a caption

Information and discussion about graphics, figures & tables in LaTeX documents.
jessie tex
Posts: 2
Joined: Thu Sep 24, 2015 6:07 pm

Image appears on next page if I use a caption

Postby jessie tex » Thu Sep 24, 2015 6:19 pm

If I don't include a caption then my image sits under my writing, eg:
  1. \documentclass[11pt]{article}
  2. \usepackage{graphicx}
  3. \title{Trying}
  4. \author{Ksks}
  5. \begin{document}
  6. \maketitle
  7. Hello.
  8. \begin{figure}[!h]
  9. \centering
  10. \includegraphics[scale=0.75]{plot.jpg}
  11. \end{figure}
  12. \end{document}

But when I include a caption then it jumps to the next page. My image is small and doesn't take up much space (it's not like it's near the bottom of the page in the first one).

Any help would be hugely appreciated.


User avatar
Site Moderator
Posts: 3795
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Sep 24, 2015 6:33 pm

Welcome, do you know why you are using the {figure} environment? That floating is on purpose. If you want to decide where a picture goes, you can use the Hammer method provided by package float, but I advise you not to and let LaTeX do all the positioning.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

jessie tex
Posts: 2
Joined: Thu Sep 24, 2015 6:07 pm

Postby jessie tex » Thu Sep 24, 2015 7:39 pm

I'm not sure, I followed a YouTube tutorial. Do you know what I should use instead?

Actually, done it. Thank you for your help!

User avatar
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Fri Sep 25, 2015 9:58 am

It is hard to believe that the small example you posted compiles to two pages.

However, the caption may very well make the contents of the {figure} environment too big for the remaining space. And then the floating property of the {figure} environment shows its effect.

The {figure} environment (like the {table}) is a floating environment. It is used to allow its contents to be moved to a place where it fits best.

By saying [!h] you only allow the float to be placed here. That is – not quite: h means place here if it fits. As this very often isn't the case LaTeX will very likely change this into ht and then place the float in the top area (t) of the next page. In the small example the bang is completely irrelevant (IIRC it only comes into effect if several floats are to be placed).

Frank Mittelbach has written a detailed explanation on how the floating mechanism works and how it can be influenced.

If you don't want your figure to float then there are easier ways than [!h] (which doesn't prevent floating, anyway)
chemmacros · chemformula · leadsheets · xsim

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 12 guests