Wrap text around a figure in LaTeX (wrapfig)

Help centre › LaTeX › Figures · Packages: wrapfig, graphicx

Load \usepackage{wrapfig} and put \begin{wrapfigure}{r}{0.4\textwidth} … \end{wrapfigure} just before a paragraph; the figure goes at the right (l for left) and the next paragraph wraps around it. Inside, size the picture with \linewidth and add \caption and \label as in any figure.

A complete example

A whole document: paste it into an empty project and compile it.

\documentclass{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\begin{wrapfigure}{r}{0.4\textwidth}
  \centering
  \rule{0.9\linewidth}{0.7\linewidth}% \includegraphics[width=0.9\linewidth]{figures/cell}
  \caption{A cell under the microscope.}
  \label{fig:cell}
\end{wrapfigure}
As Figure~\ref{fig:cell} shows, \lipsum[2-3]
\end{document}

The arguments

\begin{wrapfigure}[lines]{placement}[overhang]{width}
  • placement: r or l (right or left), i or o (inner or outer edge in two-sided documents). Capital letters (R, L, I, O) allow the figure to float a little, to where it fits, instead of being exactly at this paragraph.
  • width: the width of the figure's area, such as 0.4\textwidth or 5cm. With 0pt, the natural width of the content is used.
  • lines (optional): how many lines of text are narrowed. Usually it is computed; set it when wrapfig gets the height wrong and leaves a gap or overlaps.
  • overhang (optional): how far the figure sticks into the margin, such as [0.5\width].

Where to put it

The wrapfigure must come just before a paragraph begins (after a blank line), not inside a paragraph. The paragraph that follows, and the next ones if needed, are narrowed beside it. The wraptable environment works the same way for tables.

A wrapped table

\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
\begin{wraptable}{l}{0.4\textwidth}
  \centering
  \begin{tabular}{lr}
    Site & Mean \\ \hline
    North & 4.2 \\
    South & 3.8 \\
  \end{tabular}
  \caption{Means by site.}\label{tab:sites}
\end{wraptable}
Table~\ref{tab:sites} lists the means. \lipsum[1-2]
\end{document}

Common mistakes

In journal templates

Errors you may meet

In Manulyx

Insert → Figure → Upload from computer… uploads an image into figures/ and inserts a figure for it; From project files uses an image already in the project. PDF, PNG and JPG work with pdfLaTeX.

Write in Manulyx for free · Journal templates

Related

The examples on this page were compiled with pdfLaTeX to check that they work as shown. LaTeX quick reference · LaTeX errors explained