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:rorl(right or left),ioro(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 as0.4\textwidthor5cm. With0pt, 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
- Putting a
wrapfigurenext to a section heading, a list, a displayed equation or the end of a page: the narrowed lines get out of step, and text can overlap the figure or a gap appears. Move it to a plain paragraph. - Using it inside a list (
itemize,enumerate): wrapfig does not work there. - A paragraph shorter than the figure: the next paragraphs continue around it; with very short paragraphs or a heading next, set the
linesargument by hand. - Two
wrapfigures too close together: the second can overlap the first. Leave enough text between them. - Writing
\includegraphics[width=\textwidth]inside: the picture is wider than its area. Use\linewidth.
In journal templates
- Wrapped figures are generally not accepted by journals, which place figures at full column or page width at production, and wrapfig is unreliable in two-column layouts. Keep it for theses, reports and posters.
Errors you may meet
- LaTeX Error: Environment <name> undefined\begin{…} names an environment no loaded package defines: load the package (amsmath for align), fix the spelling, or define it with \newtheorem.
- LaTeX Error: File `<name>' not foundLaTeX cannot find a file you asked for: an \input or image name that is misspelled or missing, or a package or class that is not installed.
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
- Two figures side by side in LaTeXPut two or three images side by side in LaTeX with subcaption (each with its own (a), (b) subcaption) or with minipage (each its own Figure number).
- Place a figure exactly here in LaTeX (stop it floating)Keep a LaTeX figure where you wrote it: [htbp] options, [H] from the float package, \FloatBarrier from placeins, and \clearpage to flush waiting figures.
- Subfigures (a), (b), (c) in LaTeX and how to reference themNumber panels (a), (b), (c) inside one figure with subcaption, refer to them as Figure 1a or just (a), and change the label style.
The examples on this page were compiled with pdfLaTeX to check that they work as shown. LaTeX quick reference · LaTeX errors explained