I have this test document
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Firts subfigure.}
\label{fig:first}
\end{subfigure}
\vfill
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Second subfigure.}
\label{fig:second}
\end{subfigure}
\vfill
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Third subfigure.}
\label{fig:third}
\end{subfigure}
\caption{Creating subfigures in \LaTeX.}
\label{fig:figures}
\end{figure}
\end{document}
and everything looks like it should
But if put it in to my real document
\documentclass[a4paper,12pt,twoside]{article}
\oddsidemargin 0in
\headheight 0in
\usepackage{graphicx}
\usepackage{fancybox}
\usepackage[utf8]{inputenc}
\usepackage{epsfig}
\usepackage{multicol,pst-plot}
\usepackage{pstricks}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{eucal}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{siunitx}
\pagestyle{empty}
\usepackage{float}
\usepackage[caption = false]{subfig}
\usepackage{makecell}
\usepackage{listings}
\usepackage{color}
\usepackage{outlines}
\usepackage{upgreek}
\usepackage{subcaption}
% new commands
\newcommand{\cm}{, \si{cm}}
\newcommand{\mm}{, \si{mm}}
\newcommand{\s}{, \si{s}}
\newcommand{\kg}{, \si{kg}}
\newcommand{\g}{, \si{g}}
\newcommand{\mA}{, \si{mA}}
\newcommand{\A}{, \si{A}}
\newcommand{\V}{, \si{V}}
\newcommand{\Hz}{, \si{Hz}}
\newcommand{\K}{, \si{K}}
\newcommand{\kohm}{, \si{k\ohm}}
\newcommand{\OR}{OpenRocket }
\newcolumntype{?}{!{\vrule width 1pt}}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\def\shrug{\texttt{\raisebox{0.75em}{\char\_}\char\\char\_\kern-0.5ex(\kern-0.25ex\raisebox{0.25ex}{\rotatebox{45}{\raisebox{-.75ex}"\kern-1.5ex\rotatebox{-90})}}\kern-0.5ex)\kern-0.5ex\char_/\raisebox{0.75em}{\char`_}}}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
\begin{document}
\pagestyle{plain}
% Header ======================================================================
\begin{flushright}\vspace{-0cm}
\includegraphics[height=2.5cm]{logos/Logo_Print_300dpi_px2044x2044.png}
\end{flushright}
\begin{flushleft}\vspace{-3cm}
\includegraphics[height=2.5cm]{logos/Simulations_icon.png}
\end{flushleft}
\begin{center}\vspace{-3cm}
\textbf{\large Simulations Report}
\ \vspace{0.5cm}
\large NAME
\ \vspace{0.5cm}
\large March 2023
\end{center}
\noindent \rule{\linewidth}{0.1mm} % ==========================================
\lstset{language=Python}
\begin{abstract}
In this Report we optimise the fin design for altitude, while also taking in to account the stability as described in \cite{Stability_and_Fin_Design}.
\end{abstract}
\section{Roll Coupling}
\begin{figure}
\centering
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Firts subfigure.}
\label{fig:first}
\end{subfigure}
\vfill
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Second subfigure.}
\label{fig:second}
\end{subfigure}
\vfill
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Third subfigure.}
\label{fig:third}
\end{subfigure}
\caption{Creating subfigures in \LaTeX.}
\label{fig:figures}
\end{figure}
\bibliographystyle{References/plain}
\bibliography{References/References}
\end{document}
It says Environment subfigure undefined
Any idea why? I'm using Overleaf.

\usepackage[caption = false]{subfig}if you later want to load thesubcaptionpackage – samcarter_is_at_topanswers.xyz Mar 25 '23 at 12:40subcaptionpackage and in the real documentsubfig. Remove the latter and add the former – Juan Castaño Mar 25 '23 at 12:40\usepackage[caption = false]{subfig}also don't loadepsfigin any document written after 1993 – David Carlisle Mar 25 '23 at 12:41\vfills supposed to accomplish? If you just want to prevent the subfigures from winding up beside each other, a \par or blank line would do. – John Kormylo Mar 25 '23 at 16:01