Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

2 Answers 2

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.