I have the following LaTeX file:
\documentclass[a4paper, 12pt]{report}
\usepackage{fancyhdr, caption, pgfplots, pdfpages, graphicx}
\pagestyle{fancy}
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
\setboolean{@twoside}{false}
\setlength\parindent{0pt}
\begin{document}
\includepdf[pages=-]{example-image.pdf}
\input{File 1}
\includepdf[pages=-]{example-image.pdf}
\input{File 1}
\includepdf[pages=-]{example-image.pdf}
\end{document}
File 1 is:
Some text
\begin{figure}
\begin{center}
\begin{tikzpicture}
\pgfplotsset{every x tick label/.append style={font=\tiny}, compat=1.3}
\begin{axis}[
title={Title},
xlabel={X Label},
ylabel={Y Label},
xmin=-100, xmax=100,
ymin=0, ymax=145,
ytick={0,10,...,140},
xtick={-100,-75,...,100},
ymajorgrids=true,
xmajorgrids=true,
grid style=dashed,
legend pos=outer north east,
]
\addplot[
color=blue,
mark=*,
]
coordinates {
(-100,1)(-75,1)(-50,1)(-25,1)(0,30)(25,60)(50,105)(75,10)(100,13)
};
\end{axis}
\end{tikzpicture}
\caption*{Caption}
\end{center}
\end{figure}
(In case it makes a difference, my actual file has more documents added to it than this, and the plots in File 1 and File 2 are different from each other and have many more addplots; I made this just as a MWE. It still reproduced the same problem when compiled.)
When I compile the document, all the \includepdfs are in the correct order, but the plots in both of the LaTeX files in the \input both go to the bottom of the document, even though I didn't place any of them there. The text in the \includepdfs stay in the correct place, but are separated from the plots. I need them to be in the positions I placed them in the file. They don't need to be on new pages (they're plots made with pgfplots), and (from my research) that's why I used \input instead of \include.
I also tried putting a line between each line of code but that didn't change anything.
What could be causing this problem?
\inputjust includes the input file at that point, it never moves. What is in the files you input? does it contain floats such as figures or tables? – David Carlisle Nov 08 '21 at 21:19tikzpictureand\pgfplotsset. – Just_A_User Nov 08 '21 at 21:22example-image.pdffor the pdfs as it is available for tests, and provide the input files that do not appear where you expect in a separate code block in teh question) – David Carlisle Nov 08 '21 at 21:24figureenvironment. This is unrelated to\inputyou would get the same if you copied the code directly to the main document. The only function offigureis to specify that its content may be moved. – David Carlisle Nov 08 '21 at 21:43figurefrom your answer to get the caption to work. So if I remove it I won't be able to have the caption. – Just_A_User Nov 08 '21 at 21:46\clearpageafter each\inputand the figure will not float past the clearpage. – David Carlisle Nov 08 '21 at 21:56\begin{figure}[!htbp]as suggested by the linked answer worked, thanks so much for the help. Feel free to write it as an answer if you wish. – Just_A_User Nov 08 '21 at 21:57