# Image not showing up when using figure environment

I want to add an image to my paper but I have a problem.

When I add the image with just \includegraphics[]{} tag, everything works fine, and the picture shows up when I compile my document.

When I use \begin{figure} \includegraphics[]{} \end{figure} - syntax the image does not appear in the compiled document.

The relevant part of my header include is :

 \usepackage{graphicx}
\graphicspath{ {pics/} }


And later on I add the image with this block:

%This does not work

\begin{figure}
\centering
\includegraphics[width=.4\textwidth]{generalPolya}
\label{generalPolya}
\end{figure}

%This works

\includegraphics[width=.4\textwidth]{generalPolya}


I guess it's some sort of issue in the graphics package, but I've copied the setup from a previous paper I had, so it should work. Any ideas on what's wrong? Thanks in advance.

Edit:

Thanks for all the responses. I created a minimal working example. Apparently multicols messes with the figure tag:

\documentclass[]{article}
\usepackage{multicol} % Used for the two-column layout of the document
\usepackage{amsmath}
\usepackage{graphicx}
\graphicspath{ {pics/} }
\title{\vspace{-15mm}\fontsize{24pt}{10pt}\selectfont\textbf{Lorem ipsum}} % Article title
\begin{document}
\maketitle % Insert title
\begin{multicols}{2} %
%This does not show up
\begin{figure}[h]
\includegraphics[width=.4\textwidth]{generalPolya}
\end{figure}
%This shows up.
\begin{center}
\includegraphics[width=.5\textwidth]{chair}
\end{center}
\end{multicols}
\end{document}


What shows up after compiling the document is this

What is wrong with this syntax?

• Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – user31729 Jul 14 '15 at 7:32
• And additionally: Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jul 14 '15 at 7:32
• Your \label in the first code snippet is of no use, since it does not generate a label for your figure -- you have to use \caption for a \label to be effective there. Here you generate a label for the last counter incremented outside of the figure environment, e.g. a chapter counter – user31729 Jul 14 '15 at 7:33
• Are you sure the float did not just float to a different page? you might also want to use \begin{figure}[htbp] as the default (\begin{figure}) is the same as \begin{figure}[tbp] note no h (remember h does not mean HERE, it means here about) – daleif Jul 14 '15 at 7:35
• @PanagiotisChatzichristodoulou: multicols disables the figure environment, such that nothing shows up – user31729 Jul 14 '15 at 8:38

Try using a minipage as this:

\documentclass[12pt,a4paper]{article}
\usepackage{caption}
\usepackage{graphicx}
\begin{document}

\makebox[0pt][l]{%
\begin{minipage}{\textwidth}
\centering
\includegraphics[width=.4\textwidth]{example-image.pdf}
\captionof{figure}{figure caption}
\label{fig:fig1}
\end{minipage}
}

\medskip

I used Figure \ref{fig:fig1} above and referred to it.

\end{document}


• Thanks for the response. What you suggest works, so I'll accept the answer. I still don't understand why this and a simple \includegraphics work, but the figure environment does not compile. – Panagiotis Chatzichristodoulou Jul 14 '15 at 7:57
• @PanagiotisChatzichristodoulou: It will remain a mystery if you don't provide the faulty document which caused the error ;-) – user31729 Jul 14 '15 at 7:58
• What's the point of including the makebox and mintage environments? – Skeleton Bow Aug 10 '20 at 14:54

This is why I like compiling on the command line and not with TeXMaker etc. stuff:

There is a clear warning in the .log file (and a often occurring error:) No floats inside multicols environment:

Package multicol Warning: Floats and marginpars not allowed inside multicols' environment!.


This is documented behaviour, the multicol manual describes this warning and clearly states what will happen (emphasis mine):

Floats and marginpars not allowed inside ‘multicols’ environment!


This message appears if you try to use the \marginpar command or an unstarred version of the figure or table environment. Such floats will disappear!

If a figure (or table) with caption shall be used in a multicols environment, then use \captionof{figure}{Caption text} instead of \caption and omit the figure environment completely (or the table env.) In this sense, my answer is basically the same as the solution by AboAmmar, but without the box and minipage.

\documentclass[]{article}
\usepackage{multicol} % Used for the two-column layout of the document
\usepackage{amsmath}
\usepackage{caption}
\usepackage[demo]{graphicx}
\graphicspath{ {pics/} }
% I disable this since it's not relevant
%\title{\vspace{-15mm}\fontsize{24pt}{10pt}\selectfont\textbf{Lorem ipsum}} % Article title
\begin{document}
%  \maketitle % Insert title
\begin{multicols}{2} %
%This does not show up
%\begin{figure}[h]  % Drop this
\includegraphics[width=.4\textwidth]{generalPolya}
\captionof{figure}{My figure which should be inside the multicols}
%\end{figure} % Drop this
%This shows up.
\begin{center}
\includegraphics[width=.5\textwidth]{chair}
\end{center}
\end{multicols}
\end{document}

• Hope you don't mind my edit. – Torbjørn T. Jul 14 '15 at 8:44

I had a similar issue with a figure not showing up when using multicol

I fixed with the help of this answer: https://tex.stackexchange.com/a/483689/152952

\usepackage{float}
[...]
\begin{figure}[H]
[...]
\end{figure}
`