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?

TTT
  • 173
  • \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. – David Carlisle Jun 10 '21 at 08: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. – Onur Gürdoğan Jun 10 '21 at 08:16
  • unrelated but \paragraph is a fourth level heading and should be used below \subsubsection not below \section – David Carlisle Jun 10 '21 at 08:17
  • I tried both h, ht and htbp. But figure is still at the end of chapter. – TTT Jun 10 '21 at 08:29
  • Solved using "\usepackage{float}" and \begin{figure}[H], as suggested in https://tex.stackexchange.com/questions/39017/how-to-influence-the-position-of-float-environments-like-figure-and-table-in-lat – TTT Jun 10 '21 at 08:38
  • @TTT that is NOT a proper solution. Instead please explain what exactly you are doing and what class you are using. Some classes changes the float placements. – daleif Jun 10 '21 at 08:50
  • Well, my question was closed saying that I should check that other question... Why is this not a proper solution? I can't put the file content online so cleaning it may take too much time, maybe I'll do it, not sure yet. – TTT Jun 10 '21 at 09:02
  • @TTT for example it may leave large gaps in your output. Feel free to send me the entire project in a zip to daleif@math.au.dk then I'll take a look at it. the H specifier has its usages, this is not one of them – daleif Jun 10 '21 at 09:08

1 Answers1

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.

  • 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. – David Carlisle Jun 10 '21 at 08:18
  • @DavidCarlisle I added a footnote to the answer. There, happy? – DJScythe21 Jun 10 '21 at 08:23
  • I tried both h, ht and htbp. But figure is still at the end of chapter. – TTT Jun 10 '21 at 08: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 https://tex.stackexchange.com/questions/tagged/floats?tab=Votes – David Carlisle Jun 10 '21 at 08: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 Jun 10 '21 at 08:36
  • Solved using "\usepackage{float}" and \begin{figure}[H], as suggested in https://tex.stackexchange.com/questions/39017/how-to-influence-the-position-of-float-environments-like-figure-and-table-in-lat – TTT Jun 10 '21 at 08:38