1

I am trying to put a graph inside my TeX file it somehow misses its original places and moves somewhere else. What can I do to fix it?

Here is my code:

\documentclass{article}
\usepackage{paralist,pst-func, pst-plot, pst-math, pstricks-add,pgfplots}


\documentclass{article}
\usepackage{paralist,pst-func, pst-plot, pst-math, pstricks-add,pgfplots}

\begin{document}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
\begin{figure}
\begin{center}
    \advance\leftskip-3cm
    \advance\rightskip-3cm
    \includegraphics[width=300pt]{uniform.eps}
    \caption{Mean Square Error calculated for different number of unlabeled $x$ values each in $300$ trials.} 
    \label{fig:MSE}
\end{center}
\end{figure}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
\end{document}

The result is: enter image description here

marked as duplicate by Werner, mafp, Xavier, Torbjørn T., egreg May 2 '13 at 21:59

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
    You should use \centering in your figure environment instead of \begin{center}...\end{center} - avoids extra whitespace around your figure. Also, the figure does not look like it is taking the whole page? – ach May 2 '13 at 17:56
  • @ach I forgot to correct my question after I changed the topic! I am sorry! Thanks for the centering help though! But now my problem is to put the image to the place it belongs! – Naji May 2 '13 at 18:16
  • Try to use \begin{figure}[h]. – Sigur May 2 '13 at 18:17
  • 1
    You should read How to influence the position of float environments like figure and table in LaTeX? and/or Keeping tables/figures close to where they are mentioned, both of which make this question a duplicate. Give some feedback once you've had a chance to look them over. – Werner May 2 '13 at 18:19
  • 1
    By the way, why does this have the tikz tag? As far as I can tell, the pgfplots package is loaded but not actually used for anything. – Charles Staats May 2 '13 at 19:25
1

use

\begin{figure}[!htb]

and it should work

  • Actually it worked for three of my plots but still the last one jumps to the next section in my TeX file! Ridiculous! – Naji May 2 '13 at 18:45
  • 1
    @Naji: then there is not enough space on that page for the float. – user2478 May 2 '13 at 20:05

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