## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ multicol | Figures inside a multi-columned Document

Information and discussion about graphics, figures & tables in LaTeX documents.
muath
Posts: 30
Joined: Thu Jul 15, 2010 11:34 am

### multicol | Figures inside a multi-columned Document

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.

This is the code:
\documentclass{article}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{a4wide}

\begin{document}

\begin{multicols}{2}
aa
\begin{figure}
%  \centering
\includegraphics[width=2.5cm] {cc.jpg}
\caption{s}
\label{fig:cc}
\end{figure}
\end{multicols}

\end{document}

LaTeXguide.org • LaTeX-Cookbook.net

coachbennett1981
Posts: 257
Joined: Fri Feb 05, 2010 10:15 pm

### multicol | Figures inside a multi-columned Document

Have you tried this code:

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



muath
Posts: 30
Joined: Thu Jul 15, 2010 11:34 am

### multicol | Figures inside a multi-columned Document

coachbennett1981 wrote:Have you tried this code:

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


I do not need the complete article in two columns.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

### multicol | Figures inside a multi-columned Document

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

\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
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1