tags:

views:

1071

answers:

2

I've been struggling with this. I wanted to insert an image and have it 'near' the text that discusses it, but have the text on that page wrap/flow around the image.

The image I've converted into eps format. I initially tried to use the figure environment (\begin{figure}...), but that merely placed the image at the top or bottom of the page without any text beside it, leaving a large portion of the page empty.

I did some digging on the web and identified the 'wrapfig' package, it seemed a likely solution, but I get a series of errors, and the image appears at the end of the document.

The errors:


Package wrapfig Warning: wrapfigure used inside a conflicting environment on input line 297.
Package wrapfig Warning: Stationary wrapfigure forced to float on input line 303.
Package wrapfig Warning: Stationary wrapfigure forced to float on input line 306.

Which continues for several lines.

What's odd is that one occasion, after compiling, the image appeared exactly where I wanted it, and then on the next it didn't.

[Added a minute or so later] The latex code I have currently:

\begin{wrapfigure}{r}{0.2\textwidth}[h]
  \begin{center}
    \includegraphics[width=0.18\textwidth]{vec-perp.eps}
  \end{center}
  \caption{A}
\end{wrapfigure}
+4  A: 

wrapfigure does not need the [h] specifier.

you need to include the wrapfigure package in your preamble:

\usepackage{wrapfig}

then, put the wrapfigure call above the text you want to wrap into, like this:

\begin{wrapfigure}{r or l}{width/height} \centering \includegraphics[width/height]{graphic.filename} \caption{foo} \end{wrapfigure}

a real world example:

\begin{wrapfigure}{r}{1.5in}
\centering 
\includegraphics[width=1.5in]{smile.jpg}
\end{wrapfigure}
Mica
Good point about the [h]. You're right, all that that was doing was putting [h] in my document. :)
Iain
+1  A: 

I just went through my document, commenting it out in sections, hoping to find the environment it was complaining about...in the process, I unintentionally introduced a blank line that I didn't have before. Apparently, the environment it was complaining about was the environment before the figure. I didn't have a blank line between the previous part, which was an itemize environment.

So...this, for example, is 'broken':


    Ingredients for the Banana-Grape Bread Recipe
    \begin{itemize}
      \item Bananas
      \item Grapes
      \item Eggs
    \end{itemize}
    \begin{wrapfigure}{r}{0.2\textwidth}
      \centering
        \includegraphics[width=0.18\textwidth]{bangrape.eps}
      \caption{BananaGrape Bread}
    \end{wrapfigure}

And inserting a empty line:


    \end{itemize}

    \begin{wrapfigure}{r}{0.2\textwidth}

Clears up my problems. Along the way I learned all sorts of things, yay! On the other hand, I'm pretty sure I don't have a clear understanding of environments yet. Time to spend some time reading, I reckon.

Iain
Answering my own question isn't a faux pas, is it? It feels a little weird.
Iain
Perhaps the only bad thing about latex is the macro clashes, like the one you have encountered. Wrapfig and the enumerate/itemize environment do not work together at all.Answering your own question isn't terrible, but with the code snippet that you posted above, its unlikely that anyone would have been able to answer your question. LaTeX distributions (TeXLive, MikTeX, etc) are a lot like web browsers and CSS, in that some will interpret things slightly differently. If you ever get on any of the latex mailinglists, they will always tell you to provide a minimal working environment, and I...
Mica
... think that would be an excellent idea on SO as well. A minimal working environment is just enough code (including preamble) to illustrate the problem that you're having. It happens many times that while constructing a MWE, you will solve you own problem.
Mica
You're right, Mica, I should have provided more information. I'm not-quite-spanking-new to latex, so I don't have a good feel yet for what information to include when trying to ask a question. :)
Iain