I am having a lot of trouble placing images where I want them in my document. With the first 3 images the it stops working. I am new to latex and still struggling to learn it. I have included the initial commands too.
\documentclass[letterpaper,11pt]{article}
\usepackage{graphicx}
The code I used to display the image where I want it
\begin{figure}[h]
\centering
\includegraphics[width=15cm]{all_sky_map.png}
\caption{All sky map}
\label{fig:all sky map}
\end{figure}
This is the image
This bit of code does not work and does not display the image where I want it
\subsection{Producing peaks in a spectrum}
\begin{figure}[h]
\centering
\includegraphics{peaks_spectrum_1.png}
\caption{Peaks in HI 21-cm Spectrum at (26.76, -1.54)}
\label{fig:peaks spectrum}
\end{figure}
and this is the image used in the second bit of code

Can someone help me?

\includegraphicsthat never moves. You have also usedfigure, the only purpose of thefigureenvironment is to allow the figure to move to help with page breaking, but you have restricted the places it can move to you should normally iue[htbp](or no option) rather than[h]. Your question is basically a duplicate of https://tex.stackexchange.com/questions/2275/keeping-tables-figures-close-to-where-they-are-mentioned – David Carlisle Feb 16 '22 at 08:36