I have created my latex code with a "main" tex file, in which I am calling many other sub-files using the below command.


In each subfile, I have written my text and presenting tables and figures. I have stored each table and figure in a separate file in order to keep my subfiles organized. Thus, I am calling the tables and figures using a code like below:


Some of the figures are created using pgfplots. Although I am asking latex to put the figures exactly where I want (each figure file has a structure like below,) they appear 5 or 6 pages after where they have to appear. What is the problem in your opinion?

        \begin{tikzpicture}[scale=0.75, transform shape]
              % Some codes here

        \begin{tikzpicture}[scale=0.75, transform shape]
              % Some codes here

Hopefully, my explanations make sense! Thanks in advance.

  • In normal circumstance floats appear close to their insertion point (on the same page or on (the top of) the next page). However, this depends on of contents of document nearby of this point. Without knowing it, is impossible to say anything useful. It may help to insert \usepackage[section]{placeins} in the preamble or use \FloatBarrier at point before it which you like to have your images.
    – Zarko
    Commented May 3, 2021 at 22:37
  • It helped. Thanks!
    – mdslt
    Commented May 3, 2021 at 23:14

1 Answer 1


As suggested by one of the experts, I just needed to insert \usepackage[section]{placeins} in the preamble to resolve the problem.

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