26

I'm using this code to place an image in my page:

\begin{figure}[htp]
\begin{center}
  \includegraphics{img/helper-m.png}
  \caption[labelInTOC]{Helper klasse}
  \label{img:helper-m}
\end{center}
\end{figure}

I don't know why but this is taking up the entire page. The image isn't that big, it's 280*339px in size. I'm using the same code on some other places and it's working fine, only this particular image is giving a problem. Any ideas what's wrong?

Directly under the image there's a new section btw.

3
  • have you tried \includegraphics[width=something]{img/...}? Perhaps \includegraphics[width=.5\textwidth]{img/...} for example
    – cmhughes
    Sep 2, 2012 at 23:28
  • 1
    Is indeed the image itself displayed so large or is it just in the middle of an otherwise empty page? If the image is displayed like magnified, maybe it contains a wrong resolution declaration. pdftex isn't including the image as a collection of pixels (as PDF is a vector-based format), but as an object with a certain bounding box. For a bitmap image, the size of the bounding box results from the number of pixels and the resolution setting. Sep 2, 2012 at 23:32
  • The image resolution seems fine and it's in the middle of an empty page. It also seems to have skipped a part of my textblocks to avoid creating unnecessary whitespace. Is there any way to undo that? Sep 2, 2012 at 23:43

1 Answer 1

41

Most likely it ended up being a float page p because the constraints on size stopped it being a t float. in which case change [htp] which allows p and constrains the number and size of floats in the t area to [!ht] which does not allow p and removes the numeric and size constraints.

If that isn't sufficient, edit the question to add a complete example which shows the problem.

7
  • It worked for me! It is really strange because I have many figures of the exact same size, and one of them just took a whole page. But could you please explain what does [htp] and [!ht] mean?
    – LWZ
    Aug 2, 2013 at 5:30
  • 2
    @LWZ latex floats may be placed at the (t)op or (b)ottom or (h)ere-where they are defined or on a float-(p)age. If you use [ht] that constrains the float to here or top and doesn't allow bottom or page floats. Aug 4, 2013 at 19:47
  • Thanks! That means I should always avoid [p] if I don't want any figure ending up taking a whole page, right? What about the [!]? What does that mean?
    – LWZ
    Aug 4, 2013 at 20:11
  • 1
    @LWZ well avoiding p makes it highly likely that LaTeX can not position the float at all and so it will be held up to the end of the document taking all later floats with it. ! means to ignore some of the constraints such as number of floats allowed on a page, but again this should be used only vary rarely. Better to set the constraints you want rather than say to ignore the constraints on each float. Aug 4, 2013 at 20:15
  • What is the default condition for figures? What are the default options if none is set by the author?
    – DrSpill
    Oct 19, 2020 at 5:14

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.