Latex floating and text wrapped image

87,843

Solution 1

wrapfig is the best i've found, however, you need to put the wrapfig code above the paragraph you want it to wrap into:

\usepackage{wrapfig}

\begin{wrapfigure} \includegraphics... \end{wrapfigure}
This is the paragraph of text you want the figure to "wrap" into... etc etc.

If you put the wrapfig code under the paragraph you want to wrap into, it will obviously wrap into the next paragraph, producing an undesirable result.

you also mention a 'column' which makes me think you are using a multi-column layout, which probably isn't going to work that well with wrapfig.

When asking a specific question about latex, you should include a minimal working example, that is, enough of your preamble and body code/text so that people can recreate your problem.

EDIT: Ah. i see what you mean. wrapfig can take an optional line height argument:

\begin{wrapfigure}[line-height]{r}{width} 

where line-height is a positive integer.

your solution would probably look like this:

\begin{wrapfigure}[10]{r}{2.5in}
\centering
\includegraphics[width=2in]{governator.jpg}
\end{wrapfigure}

EDIT #2: wrapfig/floatflt + enumerate, itemize = not working. the packages are incompatible with one another. For a "wrapfigure" effect with an environment, i.e., enumerate, itemize, etc etc., You should put the environment in a minipage and the graphic in in a minipage, then set the two minipages next to each other. something to the effect of (i put them in a tabular environment as well):

\begin{tabular}{l l}
\begin{minipage}{0.5\textwidth}
\begin{enumerate}
\item
\end{enumerate}
\end{minipage}
&
\begin{minipage}{0.5\textwidth}
\includegraphics...
\end{minipage}
\end{tabular}

Solution 2

I had the exact same problem. Wrapfig expects a paragraph below it, so give it an empty one!

\begin{wrapfigure}{I}{0.5\textwidth}
\includegraphics[...]{...}
\end{wrapfigure}
\paragraph{}
\vspace*{-\parskip}

This gives an empty paragraph to make wrapfig comfortable, and doesn't alter your content at all (I added a negative vspace* to account for the \parskip of the paragraph).

Solution 3

I did some experimenting and your example is failing because wrapfig is unable to cope with the \section commands and the list environment. If you just put a bunch of text around the wrapfig, it all works fine. If you have either \section or \begin{description}, wrapfig becomes hopelessly confused.

I recommend you do a bunch of \parshape commands by hand.

Solution 4

To make wrapfigure work correctly in the enumerate/itemize/description environment, you have to put it in a minipage. Make the width of the minipage the same as \linewidth, this is correctly calculated for the available space.

\begin{enumerate}
  \item First.\\
  Lots of text.
  \item Second.\\
  \begin{minipage}{\linewidth}
    \begin{wrapfigure}[3]{r}{0.4\textwidth}
      \begin{center}
        \includegraphics[width=\linewidth]{Picture}
      \end{center}
    \end{wrapfigure}
    Lots of text.
  \end{minipage}
\end{enumerate}

This should now work nicely without you having to do any more special tricks.

Share:
87,843
Daniel Huckstep
Author by

Daniel Huckstep

Software problem solver.

Updated on July 09, 2022

Comments

  • Daniel Huckstep
    Daniel Huckstep almost 2 years

    I have a LaTeX document with an image in it. There is a section, four subsections, the latter 3 having just some text, and the first having a description environment with some stuff.

    I want to have an image on the top right and have everything text wrap nicely around it.

    The wrapfig package takes an entire column away (so text below the images gets wrapped to a fixed width even without the image there) and pushes the description environment past the left margin, and the floatflt package puts the image exactly where I want it, but no text gets wrapped.

    I have the floatflt/wrapfig environment above the initial section (I get the best image placement this way) but moving it to various other places doesn't work either.

    Are their any other ways to wrap the text around the image?

    Some examples of fail can be seen here: http://drop.io/a3dbxte

  • Daniel Huckstep
    Daniel Huckstep almost 15 years
    When I say the wrapfig package takes an entire column, I mean it seems to allocate an entire column on the page, but I have no column layout at all. wrapfig, section, subsection, description, subsection, subsection, subsection That's it.
  • Daniel Huckstep
    Daniel Huckstep almost 15 years
    I uploaded some fail examples.
  • Mica
    Mica almost 15 years
    somehow i missed your list environment... wrapfig/floatflt + any environment = no working.
  • Mica
    Mica almost 15 years
    put two minipages side by side. or ditch the environment.
  • Daniel Huckstep
    Daniel Huckstep almost 15 years
    @Mica Write out an answer with a minipage example and I'll accept it. I already did it, but if you write it out I can accept it and give you the rep.
  • Mica
    Mica almost 15 years
    added some stuff. glad i could be of help.
  • jwpol
    jwpol over 3 years
    After 8 years I faced the same problem during poster preparation and it solved my issue. 4h looking for the solution. Thanks!!!
  • whiletrue
    whiletrue about 3 years
    The first sentence solved my problem. Thanks!