Skip to main content
added 9 characters in body
Source Link
David Carlisle
  • 837.9k
  • 74
  • 1.7k
  • 2.6k

TeX has a \parshape primitive that specifies numbera number of special lines before a paragraph then for each line, a pair of left(left margin, line width) pairs. The last pair is used on all following lines, so

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

Produces

enter image description here

So basically wrapfig sets the figure in a box to find the default length to cut and the number of lines to cut so as to produce the above, then it drops in the figure in the space:

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

Producing

enter image description here

The clever part of the package is detecting if you need more than one paragraph and if so constructing a new shorter \parshape for the later ones.

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

enter image description here

TeX has a \parshape primitive that specifies number of special lines before a paragraph then for each a pair of left margin, line width pairs. The last pair is used on all following lines, so

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

Produces

enter image description here

So basically wrapfig sets the figure in a box to find the default length to cut and the number of lines to cut so as to produce the above, then it drops in the figure in the space:

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

Producing

enter image description here

The clever part of the package is detecting if you need more than one paragraph and if so constructing a new shorter \parshape for the later ones.

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

enter image description here

TeX has a \parshape primitive that specifies a number of special lines before a paragraph then for each line, a pair of (left margin, line width) pairs. The last pair is used on all following lines, so

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

Produces

enter image description here

So basically wrapfig sets the figure in a box to find the default length to cut and the number of lines to cut so as to produce the above, then it drops in the figure in the space:

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

Producing

enter image description here

The clever part of the package is detecting if you need more than one paragraph and if so constructing a new shorter \parshape for the later ones.

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

enter image description here

added 1 character in body
Source Link
David Carlisle
  • 837.9k
  • 74
  • 1.7k
  • 2.6k

TeX has a \parshape primitive that specifies number of special lines before a paragraph then for each a pair of left margin, line width pairs. The last pair is used on all following lines, so

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

Produces

enter image description here

So bascallybasically wrapfig sets the figure in a box to find the default length to cut and the number of lines to cut so as to produce the above, then it drops in the figure in the space:

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

Producing

enter image description here

The clever part of the package is detecting if you need more than one paragraph and if so constructing a new shorter \parshape for the later ones.

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

enter image description here

TeX has a \parshape primitive that specifies number of special lines before a paragraph then for each a pair of left margin, line width pairs. The last pair is used on all following lines, so

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

Produces

enter image description here

So bascally wrapfig sets the figure in a box to find the default length to cut and the number of lines to cut so as to produce the above, then it drops in the figure in the space:

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

Producing

enter image description here

The clever part of the package is detecting if you need more than one paragraph and if so constructing a new shorter \parshape for the later ones.

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

enter image description here

TeX has a \parshape primitive that specifies number of special lines before a paragraph then for each a pair of left margin, line width pairs. The last pair is used on all following lines, so

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

Produces

enter image description here

So basically wrapfig sets the figure in a box to find the default length to cut and the number of lines to cut so as to produce the above, then it drops in the figure in the space:

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

Producing

enter image description here

The clever part of the package is detecting if you need more than one paragraph and if so constructing a new shorter \parshape for the later ones.

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

enter image description here

Source Link
David Carlisle
  • 837.9k
  • 74
  • 1.7k
  • 2.6k

TeX has a \parshape primitive that specifies number of special lines before a paragraph then for each a pair of left margin, line width pairs. The last pair is used on all following lines, so

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

Produces

enter image description here

So bascally wrapfig sets the figure in a box to find the default length to cut and the number of lines to cut so as to produce the above, then it drops in the figure in the space:

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

Producing

enter image description here

The clever part of the package is detecting if you need more than one paragraph and if so constructing a new shorter \parshape for the later ones.

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

enter image description here