muath wrote:Hi there,
When I put a figure inside tow columns environment, it is not appeared and I get the following warning.
Floats and margins are not allowed inside multlcoulmns environment.
[…]
The warning says it all. Multi-columned environments simply don't allow floating objects. And that does not depend on whether you set up this environment by the
twocolumn
document class option or by the
multicol package.
A possible solution is to use figures (and tables) at fixed positions without any float environment. For this purpose the
caption package provides the
\captionof
command. The below code shows a short example derived from your code.
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{geometry} % Setup for page and paper dimensions
\usepackage{caption}
\captionsetup{
font=small,
labelfont=bf,
tableposition=top
}
\usepackage{multicol}
\usepackage{graphicx} % Use »demo« option for examples in questions on forums
\usepackage{lipsum} % Create some dummy text, to be dropped in the actual document
\begin{document}
\lipsum[1]
\begin{multicols}{2}
\lipsum[2]
\bigskip
\noindent % Very important in case that \parindent is not 0pt
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=2.5cm]{cc.jpg}
\captionof{figure}{Figure caption}
\label{fig:cc}
\end{minipage}
\lipsum[3]
\end{multicols}
\lipsum[4]
\end{document}
For details please take a close look at the respective package manuals. To keep the figure and its caption together, an additional
{minipage}
environment has been used. Otherwise it can happen that they are split across column (or page) breaks.
By the way, the
a4wide package is
obsolete. You better use the
geometry package along with the corresponding option
a4paper
for the document class to set up the page layout (see above code).
The
lipsum package has only been used to create some dummy text, thus is not part of the solution and can be dropped in the actual document.
coachbennt1981 wrote:Have you tried this code:
Code: Select all
\documentclass[twocolumn]{article}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{graphics}
\begin{document}
aa
\begin{figure}
% \centering
\includegraphics[width=2.5cm] {cc.jpg}
\caption{s}
\label{fig:cc}
\end{figure}
\end{document}
It absolutely superfluous to load
graphics because it is already loaded by
graphicx. Furthermore this code won't work at all.
Thorsten