Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a problem when a lot of figures are in question. Some figures tend to "fly around", that is, be a paragraph below, although I placed them before that paragraph. I use code:

\begin{figure}[ht]
\begin{center}
\advance\leftskip-3cm
\advance\rightskip-3cm
\includegraphics[keepaspectratio=true,scale=0.6]{slike/visina8}
\caption{}
\label{visina8}
\end{center}\end{figure}

to place my figures. How can I tell latex I REALLY want the figure in that specific place, no matter how much whitespace will be left?

Also, for the same reason I believe, \newpage doesn't work :( I put it before a \subsection, but it remains on current page...

share|improve this question
You're asking two questions here. If you still need help on the question about \newpage, please start a new question. – Juan A. Navarro Jan 10 '11 at 12:06
A tip: you can use backticks ` to mark your inline code as I did in my edit. (Moreover, please don't use introductions like "Hello" in your questions.) – Hendrik Vogt Jan 10 '11 at 14:08
thanks to both of you! – Marin Jan 11 '11 at 17:18

2 Answers

up vote 60 down vote accepted

The short answer: use the “float” package and then the [H] option for your figure.

\usepackage{float}

...

\begin{figure}[H]
\centering
\includegraphics{slike/visina8}
\caption{Write some caption here}\label{visina8}
\end{figure}

The longer answer: The default behaviour of figures is to float, so that LaTeX can find the best way to arrange them in your document and make it look better. If you have a look, this is how books are often typeset. So, usually the best thing to do is just to let LaTeX do its work and don't try to force the placement of figures at specific locations. This also means that you should avoid using phrases such as “in the following figure:”, which requires the figure to be set a specific location, and use “in Figure~\ref{..}“ instead, taking advantage of LaTeX's cross-references.

If for some reason you really want some particular figure to be placed “HERE”, and not where LaTeX wants to put it, then use the [H] option of the “float” package which basically turns the floating figure into a regular non-float.

Also note that, if you don't want to add a caption to your figure, then you don't need to use the figure environment at all! You can use the \includegraphics command anywhere in your document to insert an image.

share|improve this answer
the here package is obsolet and not needed – Herbert Jan 10 '11 at 12:06
1  
thanks for noting this! I wasn't aware of the change. H doesn't seem to work without any packages, but does work loading float. Is H from float the same as !h? – Juan A. Navarro Jan 10 '11 at 12:12
2  
no, [!h] is changed anyway by most documentclasses to [!ht]. And the meaning of h is only: here, if possible, but not absolutely here. The ! allows LaTeX to minimze all counters and lengths which refer to floating environments. – Herbert Jan 10 '11 at 12:18
Thanks for the info. I've then updated my answer using float instead of here. – Juan A. Navarro Jan 10 '11 at 12:21
1  
thanks, worked for me! I usually let latex place it where it wants, but sometimes i simply need it where I want. – Marin Jan 11 '11 at 17:16

do not use a floating environment if you do not want it float.

\usepackage{caption}
...
\noindent%
\begin{minipage}{\linewidth}
\makebox[\linewidth]{%
  \includegraphics[keepaspectratio=true,scale=0.6]{slike/visina8}}
\captionof{figure}{...}% only if needed
\label{visina8}
\end{minipage}
share|improve this answer
3  
Hi @Herbert - thanks a LOT for this answer! I had never before understood that \begin{figure} is a floating environment - while \begin{minipage} is not! I had a problem with wanting to include an image on bottom of page w/ text, and not even [H] helped; only this! I just replaced minipage for figure - and captionof for caption - and finally got what I wanted!! Thanks a lot again, cheers! – sdaau Jan 27 '11 at 12:26
1  
Why do you use a \makebox? Doesn’t it look the same without it? – Tobi Dec 7 '12 at 12:28
1  
@Tobi: if the image is not larger than \textwidth yes, otherwise not! \makebox centers the image independently from its width – Herbert Dec 7 '12 at 12:46
Ahh :-) Thank you! – Tobi Dec 7 '12 at 19:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.