Hi, consider the following:
***************code begins
Hello
\begin{figure}
\centering
\resizebox{3in}{!}{\includegraphics{Bgraph3.png}}
\end{figure}
Goodbye
**************code ends
In some situations a figure will be postponed due to the fact that it can't fill the end of the page.
What can I do to the code so that image Bgraph3.png will ALWAYS be after the text "Hello" and ALWAYS before the text "goodbye"?
Graphics, Figures & Tables ⇒ Fixing figure position with respect to code position
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Fixing figure position with respect to code position
You can start with some suitable placement parameters for the figure environment.
This will pace the figure in most case where declared in the source. Floats are only appear when there is enough space on the page.
Another possible solution is to omit the figure environment. You don't hacto stick to this environment when including an external graphics file. If you need a caption you can use the \captionof command provided by the caption package.
Some other solutions are provided by the float package. Refer to its manual to learn more.
Remark:
When posting code, please use the code environment by clicking the according button right above the input window.
Best regards
Thorsten¹
Code: Select all
\begin{figure}[!ht]
\centering
\includegraphics[width=3in]{Bgraph3}
\end{figure}
Another possible solution is to omit the figure environment. You don't hacto stick to this environment when including an external graphics file. If you need a caption you can use the \captionof command provided by the caption package.
Code: Select all
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=3in]{Bgraph3}
\captionof{figure}{A sample caption}\label{fig:bgraph3}
\end{minipage}
Remark:
When posting code, please use the code environment by clicking the according button right above the input window.
Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10