texblog

Wrap text around figures and tables

Latex provides the wrapfig package which lets you wrap text around figures. In not only saves place, but also embeds the figure nicely into your text.

Add the wrapfig package in your preamble:

\usepackage{wrapfig}

And place the figure where you want to have it:

\begin{wrapfigure}[1]{2}[3]{4}
...
\end{wrapfigure}

and similarly for tables:

\begin{wraptable}[1]{2}[3]{4}
...
\end{wraptable}
  1. Number of lines (optional)
  2. “r” for right and “l” for left figure placement.
  3. Overhang (optional)
  4. Width to be reserved.

Example:

\documentclass[11pt]{article}
\usepackage{wrapfig, blindtext}

\begin{document}
\section{Example: Wrapping text around figure}
\begin{wrapfigure}{r}{0.5\linewidth}
\centering
\rule{0.9\linewidth}{0.75\linewidth}
\caption{Dummy figure.}
\label{fig:myfig}
\end{wrapfigure}
\blindtext
\end{document}

By default, the length \linewidth is equal to the width of the text area. Setting the figure width to 0.5\linewidth changes \linewidth to that value within the floating environment. Therefore, the first \linewidth command have a different value than the next two.

To reduce vertical space on top of the figure, between the figure and the caption as well as below the caption, use the following trick:

\vspace{-10pt}

Finally, the wrapfig package also allows embedding a figure/table into text that is structured into multiple columns, with the figure stretching over several columns (see documentation for details).

Exit mobile version