Graphics, Figures & Tables ⇒ Fixing figure position with respect to code position
Fixing figure position with respect to code position
***************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"?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Fixing figure position with respect to code position
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¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10