13

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?

4
  • 1
    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. Commented Oct 8, 2012 at 14:32
  • Is it the only figure?
    – egreg
    Commented Oct 8, 2012 at 14:32
  • How are you doing twocolumn, with the standard twocolumn option or with multicol package? Commented Oct 8, 2012 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
    Commented Oct 9, 2012 at 4:53

2 Answers 2

20

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:

enter image description here

\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.

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

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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .