# Insert figure in a multicol article

I am trying to insert a figure with a caption into a multicol article. When the figure was inserted on its own, it was fine: includegraphics[width=0.5cm]{image}

However, when I tried to insert the caption [see below], the caption did not appear anywhere in the article and the figure disappeared.

\documentclass{article}
\usepackage[hmarginratio=1:1,top=30 mm,columnsep=20pt,hmargin=2.5cm]{geometry}
\usepackage[font=it]{caption}
\usepackage{paralist}
\usepackage{multicol}
\usepackage{setspace}
\usepackage{graphicx}

\begin{document}
\begin{multicols}{2}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\begin{figure}[h!]
\caption{Fig.1 xxxxx}
\includegraphics[width=0.5cm]{image}
\end{figure}

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\end{multicols}
\end{document}


What might be the issue and how could I fix it?

-
it's usually a bad idea to use [h]. Try [!htp] otherwise you will need to edit the question to add a small complete document that shows the problem so that we can debug it. –  David Carlisle Oct 8 '12 at 14:32
Is it the only figure? –  egreg Oct 8 '12 at 14:32
How are you doing twocolumn, with the standard twocolumn option or with multicol package? –  David Carlisle Oct 8 '12 at 14:40
The [!htp] didn't work. It was the only figure at moment. The multicol package was used. Please see the edited question. Thanks. –  xuan Oct 9 '12 at 4:53

Note the warning issues by multicol:

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

One way around this is to not make your floats float. The float package provides the [H] float specifier which avoids this:

\documentclass{article}
\usepackage[hmarginratio=1:1,top=30 mm,columnsep=20pt,hmargin=2.5cm]{geometry}% http://ctan.org/pkg/geometry
\usepackage[font=it]{caption}% http://ctan.org/pkg/caption
\usepackage{multicol,lipsum,graphicx,float}% http://ctan.org/pkg/{multicol,lipsum,graphicx,float}

\begin{document}
\begin{multicols}{2}
\lipsum[1-2]

\begin{figure}[H]
\caption{This is a caption}
\includegraphics[width=0.5cm]{example-image-a}
\end{figure}

\lipsum[3-4]
\end{multicols}
\end{document}


example-image-a was taken from the mwe package, while lipsum provided dummy text, Lorem ipsum style.

-
I found so many not-working-well solutions, but your hint with the [H] really was it! thanks so much. –  leo Mar 22 at 20:26

One option is to avoid floats altogether. You can use capt-of package to get the captions.

\documentclass[twocolumn]{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{capt-of}%%To get the caption

\begin{document}
\lipsum[1-5]
\begingroup
\centering
\includegraphics[width=2cm]{example-image-a}
\captionof{figure}{This is the caption}\label{fig:a}
\endgroup
From figure~\ref{fig:a} we get nothing.

\lipsum[6-8]

\end{document}


-