[Tex/LaTex] Wrapping images in text without inducing ugly justified text

graphicswrapfigure

I am trying to put a small image inside a paragraph. I don't care where it goes in the paragraph as long as it is on the right and text flows around it. I don't want it before or after the text.

http://i45.tinypic.com/ot3gab.png

This is what I have so far, but it results in an ugly justification of the text above the image. For some reason I am telling it to start a new paragraph with the wrapped text when that's not what I want.

A's height measures 4.0 feet. With only the Y mutation present, A's height measures 4.6 feet.
\begin{wrapfigure}{r}{0.5\textwidth}
\centering
\includegraphics[width=0.4\textwidth]{epistasisExample.png}
\caption{2-way Epistasis Example}
\label{fig:EpistasisEG}
\end{wrapfigure}
Each mutations affects the observed height: X reduces it by 0.5 feet, and Y increases it by

Best Answer

It's unfortunate, but wrapfig is not quite designed for what you want. From the package documentation:

if you want placement in the middle of a paragraph, you must put the environment between two words where there is a natural line break.

Thus, you first have to find the natural line break by leaving away the wrapfigure, as I did for the code below.

output

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\begin{document}
A's height measures 4.0 feet. With only the Y mutation present, A's height measures 4.6 feet.
Each mutations affects the observed height: X reduces it by
\begin{wrapfigure}{r}{0.5\textwidth}
\centering
\includegraphics[width=0.4\textwidth]{epistasisExample.png}
\caption{2-way Epistasis Example}
\label{fig:EpistasisEG}
\end{wrapfigure}
0.5 feet, and Y increases it by
whatever and some more text to show wrapping.
\end{document}
Related Question