答案1
TeX 有一个\parshape
基元,它指定段落前的一些特殊行,然后为每一行指定一对(左边距,行宽)。最后一对用于所有后续行,因此
\documentclass{article}
\setlength\textwidth{6cm}
\begin{document}
\newlength\shortline
\shortline=\dimexpr\textwidth-2cm
\parshape 4
0pt \shortline
0pt \shortline
0pt \shortline
0pt \textwidth
One two three four five six seven.
Red blue green yellow white black.
One two three four five six seven.
Red blue green yellow white black.
One two three four five six seven.
Red blue green yellow white black.
\end{document}
生产
因此,基本上wrapfig
将图形设置在一个框中以找到要剪切的默认长度和要剪切的线数以产生上述内容,然后将图形放在空间中:
\documentclass{article}
\setlength\textwidth{6cm}
\newlength\shortline
\begin{document}
\shortline=\dimexpr\textwidth-2cm
\parshape 4
0pt \shortline
0pt \shortline
0pt \shortline
0pt \textwidth
\noindent\smash{\rlap{\hspace{\textwidth}\llap{%
\hspace{2mm}%
\rule[-.8cm]{1.8cm}{1cm}}}}%
\indent
One two three four five six seven.
Red blue green yellow white black.
One two three four five six seven.
Red blue green yellow white black.
One two three four five six seven.
Red blue green yellow white black.
\end{document}
制作
这个软件包的巧妙之处在于它可以检测您是否需要多个段落,如果需要,则为\parshape
后面的段落构建一个新的较短的段落。
\documentclass{article}
\setlength\textwidth{6cm}
\newlength\shortline
\begin{document}
\sloppy
\shortline=\dimexpr\textwidth-2cm
\parshape 4
0pt \shortline
0pt \shortline
0pt \shortline
0pt \textwidth
\noindent\smash{\rlap{\hspace{\textwidth}\llap{%
\hspace{2mm}%
\rule[-.8cm]{1.8cm}{1cm}}}}%
\indent
One two three four five six seven.
Red blue green
\parshape 2
0pt \shortline
0pt \textwidth
Yellow white black.
One two three four five six seven.
Red blue green yellow white black.
One two three four five six seven.
Red blue green yellow white black.
\end{document}