3

The multicols package does not support single-column floats, only the *-form floats. I use multicols, and I have block elements (tables, figures, etc.) I'd like to float to the top (usually) of single columns.

I am prepared to 'manually float' the objects. I can see where the column break is and thus what appears immediately before and immediately after the object I want to insert. How can I insert the block element without ending the paragraph?

I sense that wrapfig with a width of \linewidth (which can be placed 'between words' of a paragraph, retaining the line/paragraph ends correctly... it might interfere with hyphenation, but if I'm at this stage of manual tweaking I can change words to avoid the hyphenation) will be the answer, but I wonder if there's another or a better way.

Edit: I just realized a probably-related question regarding 'floating longtables'. Sometimes this data has tables that run longer than the text height. I could start them immediately (possibly ending a multicols environment) and let things pick up where they will, but it might be nice to be able to say "at the end of this page, add this block-containing-a-longtable". That is, I take responsibility for decision, and LaTeX 'just' enacts that decision.

MWE Starting Point:

\documentclass{article}
\usepackage{multicol}
\usepackage{lipsum}

\title{Test Document}
\author{me}
\begin{document}
\maketitle
\begin{multicols}{2}
\lipsum[1]
Nam dui ligula, fringilla a, euismod
sodales, sollicitudin vel, wisi. Morbi
auctor lorem non justo. Nam lacus
libero, pretium at, lobortis vitae, ul-
tricies et, tellus. Donec aliquet, tortor
sed accumsan bibendum, erat ligula
aliquet magna, vitae ornare odio metus
a mi. Morbi ac orci et nisl hendrerit
mollis. Suspendisse ut massa. Cras
nec ante. Pellentesque a nulla. Cum
sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus
mus. Aliquam tincidunt urna. Nulla
ullamcorper vestibulum turpis. Pellen-
tesque cursus luctus mauris.

\section*{Column broke on `dis'}
If I insert a manual break I get an indent on the next line because
it is a new paragraph (and the `dis line' might end up not justified,
if it otherwise had space added to cause justification --- it doesn't
seem to be the case this time). I want to be able to, say, somewhere
around `natoque' insert an instruction that says ``after this line is
complete, put a picture here''.

Or, I suppose, immediately between `dis' and `parturient' somehow say
``put the table \emph{right here}, no kidding around''. I think
wrapfig does this, but I haven't used it before, and I'm not certain of
the interactions between multicol and a wrapfig where the width is the
full linewidth.

\bigskip\noindent
\lipsum[3]
\lipsum[4]
\end{multicols}
\end{document}
  • 1
    I don't have a full answer, but maybe using \vadjust in the last line of the previous column could be a starting point. – LucaD Oct 9 '15 at 16:33
1

You can forcefully end the paragraph at "dis" while setting \parfillskip to 0pt (see Is there a tool that makes paragraphs into rectangles?), then insert your figure as a non-float using float's [H]ERE specification, and continue the paragraph using \noindent. Grouping of the \parfillskip setting will only affect the paragraph in question.

enter image description here

\documentclass{article}
\usepackage{multicol,float,graphicx}
\usepackage{lipsum}

\title{Test Document}
\author{me}

\begin{document}

\maketitle

\begin{multicols}{2}
\lipsum[1]
{\setlength{\parfillskip}{0pt}%
Nam dui ligula, fringilla a, euismod
sodales, sollicitudin vel, wisi. Morbi
auctor lorem non justo. Nam lacus
libero, pretium at, lobortis vitae, ul-
tricies et, tellus. Donec aliquet, tortor
sed accumsan bibendum, erat ligula
aliquet magna, vitae ornare odio metus
a mi. Morbi ac orci et nisl hendrerit
mollis. Suspendisse ut massa. Cras
nec ante. Pellentesque a nulla. Cum
sociis natoque penatibus et magnis dis}

\begin{figure}[H]
  \centering
  \includegraphics[width=\linewidth]{example-image}
  \caption{This is a figure caption.}
\end{figure}

\noindent
parturient montes, nascetur ridiculus
mus. Aliquam tincidunt urna. Nulla
ullamcorper vestibulum turpis. Pellen-
tesque cursus luctus mauris.

\section*{Column broke on `dis'}
If I insert a manual break I get an indent on the next line because
it is a new paragraph (and the `dis line' might end up not justified,
if it otherwise had space added to cause justification --- it doesn't
seem to be the case this time). I want to be able to, say, somewhere
around `natoque' insert an instruction that says ``after this line is
complete, put a picture here''.

Or, I suppose, immediately between `dis' and `parturient' somehow say
``put the table \emph{right here}, no kidding around''. I think
wrapfig does this, but I haven't used it before, and I'm not certain of
the interactions between multicol and a wrapfig where the width is the
full linewidth.

\bigskip\noindent
\lipsum[3]
\lipsum[4]
\end{multicols}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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