Take the 2-minute tour ×
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 am trying to insert an image in the middle of the page, but it is going to the top of the page. why the hell is it happening?

I tried this:

\begin{figure}
  \begin{minipage}{\textwidth}
    \includegraphics[width=75.5mm]{myimage}
  \end{minipage}
\end{figure}

I am looking for solution for 2 hours, not a single sign of success!

share|improve this question

migrated from stackoverflow.com Apr 7 at 16:26

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Adam Liter, Heiko Oberdiek, Svend Tveskæg, Ludovic C., dustin Apr 7 at 17:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 7 down vote accepted

The only purpose of the figure environment is to allow LaTeX to move the figure, and a minipage inside figure has no purpose at all unless you have footnotes, so you just need

%\begin{figure}
% \begin{minipage}{\textwidth}
    \includegraphics[width=75.5mm]{myimage}
%  \end{minipage}
%\end{figure}

and the image will appear wherever you have \includegraphics in the source.

Note the rules for placing images are the same as the rules for placing X Normally if you enter X it comes where you put it, either part of the current line, or perhaps indented at start of a paragraph. If you do

\begin{figure}
X
\end{figure}

Then the X will float and be positioned by the page breaking routines. \includegraphics works in exactly the same way, or said more correctly, the float placement routines have no information about the content of the figure environment.

share|improve this answer

Figure is an floating object and minipage is not, so by encapsulating a minipage in a figure object you make the minipage floating.

Another option is using the "H" position specifier; http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions

That being said, I prefer to let LaTeX control the position of the image and use a reference to that figure in your text. Letting LaTeX control the position of all elements of your page is in my option a more robust and neat solution.

share|improve this answer
    
thanks man, helped a lot –  doniyor Apr 7 at 16:24
4  
If you put a figure inside a minipage you will get a syntax error and the float will be discarded. –  David Carlisle Apr 7 at 16:29
    
you are absolutely right, I updated my answer –  Robert Apr 7 at 20:28

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