Image not showing up when using figure environment
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 thefigure
ortable
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}
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}