I have a document in overleaf with some text before a figure, however when it is compiled, the figure appears above the text, including the header. Why is this happening and how can I fix it? I have the following packages active:
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[citestyle=authoryear, style=apa]{biblatex}
\addbibresource{References.bib}
\usepackage[margin=2cm]{geometry}
\usepackage{caption, stackengine}
\usepackage{wrapfig}
\usepackage{subfigure}
\usepackage[table,xcdraw]{xcolor}
\usepackage{subfiles}
\usepackage{gensymb}
\usepackage{siunitx}
\sisetup{group-minimum-digits = 4, detect-display-math = true, detect-weight, detect-mode = true, math-rm, group-separator = {,} }
\usepackage[version=4]{mhchem}
\usepackage{hyperref}
\usepackage{chngcntr} % IMPORTANT FOR THE NUMBERING OF SECTIONS AND EQUATIONS
\usepackage{tikz} % SKETCHING PACKAGE
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{adjustbox}
\usepackage[parfill]{parskip}
\usepackage[none]{hyphenat}
\sloppy
\usepackage{lipsum}
\usepackage{svg}
\usepackage[super]{nth}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{xcolor}
\usepackage{lscape}
\usepackage{nomencl}
\fancypagestyle{style1}{
\fancyhead{}
\fancyfoot{}
\fancyfoot[R]{Page \thepage \hspace{1pt} of \pageref{LastPage}}}
relevant document:
\documentclass[../main.tex]{subfiles}
\begin{document}
\section*{Introduction}
Xylenes are a class of highly useful chemical raw materials. Their chemical formulae are shown in Figure \ref{fig:xylene_strucutres}.
\begin{figure}
\centering
\includesvg[scale=0.43]{Introduction/Xylene_structures}
\caption{Chemical formulae of p-xylene, o-xylene, and m-xylene}
\label{fig:xylene_strucutres}
\end{figure}
P-xylene enjoys the largest market among the three isomers.
\end{document}
figureenvironment (by definition a "float"), and whether you have specified any options. (Most of the packages you show are probably irrelevant.) Reformulate your example, starting with\documentclassand ending with\end{document}, so that it produces the problem you describe, so that helpers can compile it. – barbara beeton Mar 09 '20 at 01:28\begin{figure}[ht}and if there is room "here", that's where it will be placed; if there's not room, it will move to the top of the next page. There's lots of useful information about figure positioning in this question: How to influence the position of float environments like figure and table in LaTeX? – barbara beeton Mar 09 '20 at 02:34figureis to take its content out of the main document flow and mark it as a float that may be re-inserted elsewhere to help with page breaking. So what you describe is the expected behaviour – David Carlisle Mar 09 '20 at 07:54