高级Wrapfig

高级Wrapfig

考虑以下代码和输出。

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

输出

如何让文本跟随图像中三角形的渐变?

答案1

\parshape可用于以下设置:

在此处输入图片描述

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

为了以更具编程性的方式处理这个问题,你可以使用图形。有关此方法,请参阅

或其他相关帖子:

相关内容