Graphics, Figures & TablesImages appear in random places!?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
verbal-l
Posts: 3
Joined: Mon Aug 10, 2009 9:06 pm

Images appear in random places!?

Post by verbal-l »

Hi,

I insert pictures via the menu bar into my text, when I render to pdf I get one or two images in the right position, but then other ones just disappear and pop up pages later completely arbitrary as it seems. When I compile I do not get any error messages.

Has anybody got any idea how this can happen? Very frustrating. Here is how I embedd them. This one works once, then I do it again a few lines later and it doesnt. Makes no sense!

\begin{figure}[hp]
\centering
\includegraphics[scale=0.50]{D:/MSc/Project/images/AI/images/gaussian.jpg}
\label{fig:gaussian_blur}
\end{figure}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Images appear in random places!?

Post by frabjous »

This is because the "p" in the option "hp" tells LaTeX that if the figure can't be placed here (not enough room), it should be placed on a special page for floats later on. You might try !ht or !hb instead.

The placement commands are (copied from lshort):

h = here at the very place in the text where it occurred. This is useful mainly for small floats.

t = at the top of a page

b = at the bottom of a page

p = on a special page containing only floats.

! = without considering most of the internal parameters, which could stop this float from being placed. (Basically tells it to try harder to place it where you next say to.)

If you list more than one, it tries one, and if I can't do it, it then tries the next option. So \begin{figure}[!hb] will try really hard to place it here, and if that doesn't work, it'll then try to place it at the bottom of the page, and so on.
verbal-l
Posts: 3
Joined: Mon Aug 10, 2009 9:06 pm

Re: Images appear in random places!?

Post by verbal-l »

Thank you that is very kind - I think i fixed it now with a combination of your comments and some /newpage commands in the right places.


However I still have a strange issue with the centering othe images - they seem to be centered in most cases but not if I am in a subsection and two /begin{enumerate} down, i.e.
Section 1 - image centers fine
Section\Subsection 1.1 - image centers fine
Section\Subsection 1.1\Item 1 - image centers fine
Section\Subsection 1.1\Item 1\Item a - image is leftbound?

How do I always get it to be at the center of the page, no matter what section i am in?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Images appear in random places!?

Post by localghost »

In a list environment you should not use a float environment because the image is not supposed to float. Use the \captionof command provided by the caption package and put the image into a center environment. The image then will be centered according to the current line width.


Best regards and welcome to the board
Thorsten
Post Reply