14

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?

4

1 Answer 1

14

\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:

7
  • What package is able to wrap text around more complex shapes, such as i.imgur.com/MsbsOVG.png or i.imgur.com/Apq8kdv.png or i.imgur.com/GxllBgA.png easier? I mean automatically wrapping around a shape without manually specifying coordinates for each line.
    – skan
    Commented Feb 7, 2017 at 19:26
  • 1
    @skan: For that you'll have to create the shape and introduce the line widths to TeX to be used within a \parshape macro; something similar to Very specific paragraph shape and Text wrap with shapepar (insert image between text). The latter example showcases the use of XFig to draw the shape and export it using fig2dev. This should work via cygwin on Windows.
    – Werner
    Commented Feb 7, 2017 at 19:49
  • I had already seen that threads, but I expected to find an easier or more automatic solution.
    – skan
    Commented Feb 7, 2017 at 20:43
  • @skan: Yes, automation is what everyone's after. TeX isn't the same as Word that provides a WYSIWIG GUI-style interface. You'll have to program the content, and that's why you need to do it that way. AFAIK, there exists no (La)TeX package that can do this automatically. Perhaps in other languages...
    – Werner
    Commented Feb 7, 2017 at 20:49
  • I was thinking more in software like Indesign
    – skan
    Commented Feb 8, 2017 at 0:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .