I'm trying to get images in my document in two different ways:
- On top of the entire page, centered
- On top of a single column
I tried it with both twocols and multicols. I ruled out twocols because it forces a new page every time you turn it on, because I need the abstract to be wide and the rest of the cover page to be two columns.
Here are some examples of both points (screenshot from a downloaded PDF):
I want to achieve both, but somehow I can only solve the first point with:
\end{multicols}
\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{figure}
\caption{Dataflow pipeline of the edge detector}
\label{fig:workflowedge}
\end{figure}
\begin{multicols}{2}
Is it awkward to turn off multicols, then turn it back on again?
For my second point, I've tried everything, but almost always, the image doesn't show up at all! The only way I can get it to show at all is by specifying the H
placement specifier, but that places the image inside the text where I defined it, not on top of the column.
This is my best try, but it hides the image and breaks all references to ??
:
\begin{figure}[t!]
\centering
\includegraphics[width=0.25\textwidth]{figure}
\caption{Dataflow pipeline of the edge detector}
\label{fig:workflowedge}
\end{figure}
and I'm getting the warning:
Package multicol Warning: Floats and marginpars not allowed inside `multicols' environment!.
How can I make a figure a non-float?
I also tried the figure*
environment, but that just creates an image centered on top of the page, like my first point.
Best Answer
The
multicol
environment is not designed to support column floats. The concept of balancing makes this next to impossible to automatically provide correct results in the general case and therefore I decided not to extendmulticol
in this direction for 2e.For example, with
multicol
you can change the number of columns mid-page, how should that reflect on float placements, given that TeX can't re-break prargraphs so that they flow around floats that then not fit the column width any longer.For the less general case, e.g., fixed 2-column layout with only a little bit of balancing, one could probably extend
multicol
to support this, but it would then break in the more generic cases, and as I said it isn't there.Update
Having said the above, I couldn't resist the challenge to implement at least a trivial implementation of this. The idea is simple: we offer a command that takes 3 arguments: a page number, a column number, and a float body, e.g.
The above is using
\captionof
from thecaption
package as this isn't really a float so\caption
would complain unless it gets modified which I didn't do.This command can be used inside a
multicols
environment and asks for this float to be placed on top column 2 on page 1. So a lot of manual work if the amount of text is changing or themulticols
environment is moved. This could be done differently and better, but that is more than I had time for.So here is the code and a test file, a mixture of patching some hooks into
multicol
and implementing the new functionality as a LaTeX3 property list.As a result one gets the following output on the first page with the three floats placed in column one and two:
With only one
\lipsum
in the test file, themulticols
ends on the next page and thus the float for page 2 column one isn't typeset and we get the following error message as well:Not really great :-) but then this is just a proto-type anyway. In fact, if a
multicols
environment starts in the middle of a page then the float will appear on the top of the column of the multicol not at the top of the page. After all, the column sizes might differ, So that is rather a feature not a bug ... hey anything on this is a feature as I said totally unsupported in this shape --- enjoy nevertheless