Hi, I am using the following code to insert a figure. I want it here or on top, but LaTex places it below for some reason. Any help appreciated.
Javier
\begin{figure}[!ht]
\caption{fig}\label{Fig: ergodic}
\centering
\includegraphics[width=6in,height=5in]{myfig}\\
\end{figure}
Graphics, Figures & Tables ⇒ placement graphics
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
placement graphics
This code snippet alone is insufficient. Build a minimal working example (MWE) that shows the behaviour you described.
Omit the \\ command for a line break. It is completely superfluous.
Best regards
Thorsten¹
Omit the \\ command for a line break. It is completely superfluous.
Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
placement graphics
Hi Javier,
Stefan
if you want to avoid floating have a look at the possibilities listed here: Prevent floating of figures or tables. Or try the package placeins and its command \FloatBarrier.rockybalboa wrote:I want it here or on top, but LaTex places it below for some reason.
Stefan
LaTeX.org admin
Re: placement graphics
Hi there,
Your problem might come from the fact that you are misplacing the commands. Firstly, in a figure environment, LaTeX expects the caption and the label after the figure itself. Secondly, like said by localghost, you don't need to tell LaTeX that you want a linebreak after a figure, it is automatic. Thirdly, I believe you are confusing your compiler with the command \begin{figure}[!ht]. It tells your compiler that you want to "force" (!) your figure to be here (h) or on top (t). Try to image if I would force you to be on two different place at once, you would choose the one you like. So keep this information simple, with \begin{figure}[!t]. I don't remember if you are not suppose to add the exclamation after the location [t!]. At last, by define the width and the height of your figure, you will most probably change its original ratio. Why don't you specify one dimension, to keep the ratio of the figure intact.
Hope this helps. Cheers
Your problem might come from the fact that you are misplacing the commands. Firstly, in a figure environment, LaTeX expects the caption and the label after the figure itself. Secondly, like said by localghost, you don't need to tell LaTeX that you want a linebreak after a figure, it is automatic. Thirdly, I believe you are confusing your compiler with the command \begin{figure}[!ht]. It tells your compiler that you want to "force" (!) your figure to be here (h) or on top (t). Try to image if I would force you to be on two different place at once, you would choose the one you like. So keep this information simple, with \begin{figure}[!t]. I don't remember if you are not suppose to add the exclamation after the location [t!]. At last, by define the width and the height of your figure, you will most probably change its original ratio. Why don't you specify one dimension, to keep the ratio of the figure intact.
Hope this helps. Cheers
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
placement graphics
The sequence of commands is completely irrelevant to the placement of the float. But in fact, the caption of a figure belongs underneath.fatra2 wrote:[...] Your problem might come from the fact that you are misplacing the commands. Firstly, in a figure environment, LaTeX expects the caption and the label after the figure itself. [...]
There will be no confusion for the compiler. The exclamation mark doesn't force the output of a float, but makes the compiler neglect the default settings for placing floats on a page (by reducing the according values). One single parameter will be overwritten with an according warning in the log file. The given combination yields very good results.fatra2 wrote:[...] Thirdly, I believe you are confusing your compiler with the command \begin{figure}[!ht]. It tells your compiler that you want to "force" (!) your figure to be here (h) or on top (t). Try to image if I would force you to be on two different place at once, you would choose the one you like. So keep this information simple, with \begin{figure}[!t]. I don't remember if you are not suppose to add the exclamation after the location [t!]. [...]
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
-
- Posts: 15
- Joined: Wed Mar 04, 2009 12:33 am
Re: placement graphics
Thanks a lot for all suggestions. I found the command \FloatBarrier and \usepackage{placeins} particularly hepful.
Javier
Javier