[Tex/LaTex] Advanced Wrapfig

wrapfigure

Consider the following code and output.

\documentclass{article}
    \usepackage{lipsum}
    \usepackage{graphicx}
    \usepackage{wrapfig}

\begin{document}
    \begin{wrapfigure}{o}{0.5\textwidth}
        \centering
        \includegraphics[width=2in]{image.png}
    \end{wrapfigure}
    \noindent\lipsum[1]
\end{document}

Output

How can I have the text follow the gradient of the triangle in the image?

Best Answer

\parshape can be used in the following setup:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{graphicx,wrapfig}% http://ctan.org/pkg/{graphicx,wrapfig}

\begin{document}
\begin{wrapfigure}{o}{0.5\textwidth}
  \centering
  \includegraphics[width=2in]{triangle.png}
\end{wrapfigure}
\noindent\lipsum[1]

\null\hfill\smash{% Place image with adjustment for height/depth
  \raisebox{\dimexpr-\height+\baselineskip}{%
    \includegraphics[width=2in]{triangle.png}}}%
\par\vspace*{\dimexpr-\baselineskip-\parskip}% Correct for following paragraph

% \parshape <num lines> <indent> <width> ...
\parshape 12 0pt 0.5\textwidth
0pt \dimexpr0.5\textwidth+\baselineskip\relax
0pt \dimexpr0.5\textwidth+0.75\baselineskip\relax
0pt \dimexpr0.5\textwidth+1.5\baselineskip\relax
0pt \dimexpr0.5\textwidth+2.25\baselineskip\relax
0pt \dimexpr0.5\textwidth+3.0\baselineskip\relax
0pt \dimexpr0.5\textwidth+3.75\baselineskip\relax
0pt \dimexpr0.5\textwidth+4.5\baselineskip\relax
0pt \dimexpr0.5\textwidth+5.25\baselineskip\relax
0pt \dimexpr0.5\textwidth+6.0\baselineskip\relax
0pt \dimexpr0.5\textwidth+6.75\baselineskip\relax
0pt \textwidth
\noindent\lipsum[1]

\end{document}

For a more programmatic way at dealing with this, you could use Xfig. For such an approach, see

or other, related posts: