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 have a simple two-column text, and want to place figures within the text. I used this code

\documentclass{article}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{caption}

\begin{document}
\begin{multicols}{2}
First text
\begin{center}
    \includegraphics[width=0.5\textwidth]{ebooks.jpg}
    \captionof{figure}{This is a test}
    \label{fig: 11}
\end{center}
Second text
\end{multicols}
\end{document}

My problem is that the figure will be placed exactly after First text no matter where it is. For example, if First text needs 80% space and figure needs 30%; figure will be pushed to the second page, and we will have 20% gap in the first page.

How can I make the structure flexible. In this example, put 70% of First text in the first page (with 30% space needed for figure to make 100% filled page); then, flow the remaining 10% of First text to the second page.

share|improve this question
2  
Did you try using the figure environment: \begin{figure} and \end{figure}? You can also add \centering inside the environment to centre the picture. –  ienissei Feb 27 '12 at 17:27
    
@ienissei Probably something is wrong with my code (though it is very simple). First, I tried figure but when wrapping center within figure, the image will not be displayed at all. –  All Feb 27 '12 at 17:32
2  
Try loading the float package as well. And write: \begin{figure}[H]\centering … \end{figure}. It should display… but I am no expert regarding the multicol package, though I know it causes some issues with floats. –  ienissei Feb 27 '12 at 17:47
    
From what I've read a moment ago, only figure* and table* floats work inside multicols - they spread the entire textwidth, not just a single column. If everything else fails, you can manually put the graphics someplace earlier in text. –  Frg Feb 27 '12 at 17:47
1  
see this answer to my question: tex.stackexchange.com/a/45936/10862 it should do what you need. –  s0rce Feb 27 '12 at 23:31
add comment

1 Answer

up vote 12 down vote accepted

There are a couple of possibilities here. For two-column text in the article class, you don't need the multicols environment other than to balance the columns at the end, or if you want to switch to single-column and back without incurring a page break. Just pass the twocolumn option to article. In that case, using the figure environment will indeed give you a single-column floating figure (that will usually appear at the top of the next column, but you can tweak the positioning if you need to).

Second, if you truly need the multicols environment, then the package documentation states that single-column floats are incompatible with multicols. You can use the starred forms (figure* or table*) which will take up a full page width, as @Frg points out. As it turns out, positioning floats is very complicated, and made even more so in the multi-column case. See for instance this document, which documents some of the challenges involved; both this document and the multicol package were written by Frank Mittelbach, who is heavily involved in the LaTeX3 effort, so I'd guess that if multicol doesn't support floats yet, it's still not a solved problem :)

Finally, you can abandon flexibility, and resort to trial-and-error: move the content you wish to float around in your source, and recompile and try again until it looks good. If this is your only viable approach, I'd suggest waiting until the surrounding text has mostly stabilized, so you don't waste time perfecting a layout that will just break with the next edit...

share|improve this answer
    
wow, thanks for the descriptive answer. I learned a lot :) –  All Feb 28 '12 at 0:21
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.