0

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

All sky map

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 peaks spectrum

Can someone help me?

David Carlisle
  • 757,742
  • You should provide complete small document which reproduce your problem. From showed fragment can not be concluded, that i anything wrong with your figures. – Zarko Feb 16 '22 at 08:04
  • 1
    the figure is included by \includegraphics that never moves. You have also used figure, the only purpose of the figure environment 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
  • It is one of the features of LaTeX that figures can float. The rules are described here https://tex.stackexchange.com/a/39020/2388. You can use the float package and its H option to prevent it, you can read about the pros and cons here https://tex.stackexchange.com/q/370627/2388 – Ulrike Fischer Feb 16 '22 at 08:36
  • my problem got solved after i removed \beginfigure command – Ritu Kelkar Feb 16 '22 at 15:23

0 Answers0