LaTeX and getting the figure in the right place

If you use LaTeX and sometimes want to override the TeX macro to get your figure right there you can do it.

You can use the exclamation point !


\begin{figure}[!ht] \begin{center} \includegraphics[scale=0.50]{image.png} \end{center} \end{figure}

However the results is not really nice as when Tex take care to do the layout. So the win-win solution would be to have Tex taking care of the layout, but force it to put all the figure that belong to a section within that section.

Well that’s pretty easy and the command

\clearpage{}

Just does the trick.

If instead you refer to a figure but instead of the number of the figure you can read the number of the section, this is because you have misplaced the caption with the label.

The label has to go after the caption, otherwise it will refer to the section not to the figure.

Right way:

\begin{figure}[htb]
\begin{center}
\includegraphics[scale=0.50]{image.png}
\caption{A wonderful image!}
\label{fig: image}
\end{center}
\end{figure}

Note the relax [htb]. LaTeX will take care of the position for you.

7 Comments

  1. “The author is responsible for the content, and let latex do the typesetting!”, I think this the spirit of latex. So just let the figure be float, and latex will make it in the right place!

  2. Working great..
    Thanks.

  3. Thanks, somehow now my pictures are in the right place! This is black magic:D

  4. First off I want to say awesome blog! I had a quick question which I’d like
    to ask if you do not mind. I was interested to know how you center yourself and clear your mind prior to writing.

    I’ve had a difficult time clearing my mind in getting
    my thoughts out there. I truly do take pleasure in writing however it just seems
    like the first 10 to 15 minutes are generally wasted simply just trying to figure out
    how to begin. Any recommendations or hints?
    Appreciate it!

    • Hi, unfortunately I don’t know if I am the right person to ask, because I’ve just wrote one blog post last year only. (Not counting the result).

      I think the major thing is to actually start do it, and give it a good two hours slot.

      For example I have some ideas for two posts in my head at the moment, however I know if I don’t open a new post and start working on it right away I will loose interest and end up not publishing.

      So my best and only advice is start do it, and than you are at half od the job 🙂

      Good luck!

Leave a Reply