0

I have a serious problem of placing my figures in appropriate place of the two column paper. I searched all the online tips/guidance for it and applied but not working. I try to put my figure' code in one place and sometime it goes after and even between the references. Am I missing some libraries, some basics etc ?

The following libraries I used and then the code for my figure

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.
\usepackage{cite}
\usepackage{graphicx}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
 \usepackage{multirow}
 \usepackage{graphicx}
 \usepackage[utf8]{inputenc}
\usepackage[english]{babel}
 \usepackage{multicol}%set multicolumn features in page 
\usepackage{float}%Places the float at precisely the location in the LaTeX code
\usepackage[table,xcdraw]{xcolor}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}

Code for the figure 1

\begin{figure}[h] % I used with [h] and without [h] but doesnt help \begin{center} \includegraphics[width=8cm, height=6cm]{Picture4.png}

Figure 3: Some caption

\label{fig:my_label} \end{center} \end{figure}

\setlength{\parskip}{1em}

Code for the figure 2

\begin{figure}[] \begin{center} \includegraphics[width=8cm, height=6cm]{Picture5.png}

Figure 3: Some caption

\label{fig:my_label} \end{center} \end{figure}

\setlength{\parskip}{1em}

One of the two figures is shown inside the paper (though not the exact place I tried) and another between the references. Please guide me where am I doing wrong?

  • Hi! I also struggled with figure placement when I started to learn LaTeX. I recommend using the solution that I propose here: https://tex.stackexchange.com/questions/297564. In short, add \usepackage{float} to the preamble and use \begin{fihure}[H] instead of \begin{fihure}[h] etc. This way, the figure will appear exactly in the order you code it. – Dr. Manuel Kuehner Nov 24 '22 at 21:35

1 Answers1

-1

To actually let LaTeX place the figure where it is in the source code, you have to use [h!]. With [h] only, LaTeX will still try to determine the best position itself, which is overwritten by [!]. See https://www.overleaf.com/learn/latex/Positioning_of_Figures for more details.

ismxy
  • 19
  • 3
    Sorry but that is a highly misleading description. [h] and [h!] are both problematic settings that usually generate a warning that they are being changed to ht The ! setting should only be used in exceptional circumstances as its (only) effect is to ignore the documentclass-set limits on number of floats per page and the fraction of a text page that a float may use. – David Carlisle Feb 27 '22 at 18:26
  • @DavidCarlisle, so what should be used to put the figure exactly the same place where we mention in the code. I also used h! as suggested by ismxy but doesnt work. – Neha gupta Feb 27 '22 at 18:36
  • @DavidCarlisle, ok I am reading it. The problem is that one of my figure moved to after the 'references' section. This is my first project in Latex and its seriously thinking me to shift to MS word again. – Neha gupta Feb 27 '22 at 18:46
  • @DavidCarlisle, I did not understand. You mean I need to remove the \begin{figure}[] \end{figure} ?? – Neha gupta Feb 27 '22 at 18:53
  • @DavidCarlisle, I want to move it but latex does not move it to the appropriate place. Figure4 and Figure5 are related to each other and it need to be adjacent to each other but latex move Figure5 to the references area. – Neha gupta Feb 27 '22 at 19:05
  • @Nehagupta your example document is incomplete and can not be run and does not show your problem. You can put \clearpage before the references to stop floats floating past that point. – David Carlisle Feb 27 '22 at 19:07
  • @Nehagupta if you want it to move but not too far then see https://tex.stackexchange.com/questions/2275/keeping-tables-figures-close-to-where-they-are-mentioned – David Carlisle Feb 27 '22 at 19:09
  • @DavidCarlisle, thanks a lot. If I put \clearpage before even the 'Conclusion' section, it will not past the conclusion section too? – Neha gupta Feb 27 '22 at 19:09