1

I have a MWE as given below:

/*Packages that are being used
...
...
*/

\chapter{...}
\section{...}
\paragraph{...}
\section{...}
...
\section{...}
\paragraph{...}
(some text)
\begin{figure}
\includegraphics[scale=0.675,angle=90]{filename}
    \caption[reference]{caption}
\end{figure}

\section{...}
\paragraph{...}

Instead of appearing in the place I expected in the middle of the text, my figure ends up at the end of the chapter after the last paragraph. How could I solve this?

Following suggestions I tried \begin{figure}[h], \begin{figure}[ht] and \begin{figure}[htbp] but figure still goes to the end of chapter.


Solved using \usepackage{float} and \begin{figure}[H], as suggested in How to influence the position of float environments like figure and table in LaTeX?

8
  • \includegraphics includes the image, the purpose of the figure environment is to take the content out of the document flow and allow it to be inserted elsewhere to help with page breaking. By default leaving it in place isn't allowed but you can use \begin{figure}[htbp] to allow it to stay in place if it fits. Commented Jun 10, 2021 at 8:16
  • You may want to use "[H]" statement just after the \begin{figure}. Like this: \begin{figure}[H]. To do that you should also add a new package called \usepackage{float}. Anyway, further information can be seen here. Commented Jun 10, 2021 at 8:16
  • unrelated but \paragraph is a fourth level heading and should be used below \subsubsection not below \section Commented Jun 10, 2021 at 8:17
  • I tried both h, ht and htbp. But figure is still at the end of chapter.
    – TTT
    Commented Jun 10, 2021 at 8:29
  • Solved using "\usepackage{float}" and \begin{figure}[H], as suggested in tex.stackexchange.com/questions/39017/…
    – TTT
    Commented Jun 10, 2021 at 8:38

1 Answer 1

0

You forgot to include a a figure placement specifier. Your code should look like this:

\begin{figure}[h]
\includegraphics[scale=0.675,angle=90]{filename}
    \caption[reference]{caption}
\end{figure}

Note the addition of [h] to the \begin{figure}. There are a few different placement specifiers, but it seems like you want [h], which means place it here.

EDIT: At the request of a commenter, I will add that it is recommended never to use just [h] on its own, but instead to use [ht], meaning place the float here, but if not at the top of the next page.

6
  • 4
    No this is wrong: using [h] prevents the float being placed in most cases and usually generates a warning that it is being changed to [ht] but including p as well is better in almost all cases. Commented Jun 10, 2021 at 8:18
  • @DavidCarlisle I added a footnote to the answer. There, happy?
    – DJScythe21
    Commented Jun 10, 2021 at 8:23
  • I tried both h, ht and htbp. But figure is still at the end of chapter.
    – TTT
    Commented Jun 10, 2021 at 8:27
  • @TTT that is not totally unexpected (using htp or even [!htbp] to allow all placements is more permissive) but the placement depends on the rest of the document so without an example it is hard to comment. The entire purpose of the figure environemnt is to allow the content to move so basically it is working as designed. see the first few answers here tex.stackexchange.com/questions/tagged/floats?tab=Votes Commented Jun 10, 2021 at 8:29
  • @TTT We cannot guess what is wrong exactly in your document with the code that you show. Edit the question to show a minimal working example (MWE) that illustrates your problem. You can use the lipsum package to make fake text and use the fake images of the mwe package to reproduce your problem without effort , and without us having to guess what else are you doing.
    – Fran
    Commented Jun 10, 2021 at 8:36

Not the answer you're looking for? Browse other questions tagged .