Skip to main content
v2026.11,986 entries · CC-BY 4.0

LaTeX wrapfigure: setup, examples and fixes

LaTeX wrapfigure setup with an isolated layout example, image sizing checks, placement controls and documented troubleshooting steps.

Written and maintained by CASRAI Editorial Board

Published

On this page

LaTeX wrapfigure places a narrow figure beside running text using the wrapfig package. Load the package, set the wrapping container’s width, and keep the image inside that width. The example below separates a layout test from image-file problems before you insert a manuscript figure.

What it is used for in research

A wrapped illustration can accompany an explanatory paragraph in a research report, thesis or manuscript. The purpose is to let prose continue alongside a small visual, rather than reserve an entire horizontal band for it. This is a layout option for a document whose template permits it; it does not establish a journal’s submission requirements.

Keep three operations separate: importing an image, numbering a figure, and shaping the surrounding paragraph. The graphicx package handles image inclusion. A caption supplies the figure’s caption and numbering. The wrapfigure environment controls the area alongside which text runs. For the image-import part, see the LaTeX graphicx image guide; this page concentrates on the surrounding text.

The package’s own manual warns that wrapped figures can appear out of sequence with regular figures. Consequently, a visually successful page still needs a numbering check. CTAN also classifies wrapfig as incompatible with tagged PDF. If tagged output is a deliverable, treat that compatibility flag as a separate requirement from making a page look correct.

Install or access

CTAN lists wrapfig in both TeX Live and MiKTeX. The package-loading command belongs in the document preamble, before \begin{document}. Image inclusion additionally needs graphicx:

\usepackage{graphicx}
\usepackage{wrapfig}

Package name and environment name differ: load wrapfig, then use wrapfigure. Overleaf’s official wrapping examples use that arrangement. Loading an unrelated graphics package does not replace the wrapping package; the image loader and the paragraph wrapper have different responsibilities.

The demonstration below temporarily loads graphicx with its documented demo option. That option substitutes a rectangle for an image, making the first layout test independent of a photograph, chart or file path. Do not leave it enabled when preparing the real manuscript: the rectangle is a diagnostic placeholder, not the research figure.

Step-by-step task

Start with an isolated example, inspect the paragraph layout, and then introduce the real image. The dimensions here are illustrative choices, not publisher specifications or universally suitable settings.

  1. Create a small document. Use the complete example below as a separate layout specimen. The paragraph describes an illustrative composite workflow; it reports no study or experimental finding.
  2. Load the two packages. Keep \usepackage[demo]{graphicx} for this first test and load wrapfig after it. The graphics manual documents the placeholder behavior.
  3. Put the wrapping environment before the prose. This example places it at a paragraph boundary. The following text is outside the environment; only the image, caption and label belong inside it.
  4. Set the container and image separately. The container is 0.34\textwidth; the image uses 0.9\linewidth inside that container. Its explicit height makes the test rectangle easy to recognize.
  5. Generate and inspect the PDF. Check the image, caption, adjacent lines and the point where full-width text resumes. Review the log as well as the page.
  6. Replace the placeholder. Remove the demo option, provide the actual image file, and use a width-only image command initially. Recheck the layout with the real caption and surrounding prose.
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}

\begin{document}

\begin{wrapfigure}{r}{0.34\textwidth}
  \centering
  \includegraphics[width=0.9\linewidth,height=30mm]{layout-placeholder}
  \caption{Illustrative layout placeholder.}
  \label{fig:layout}
\end{wrapfigure}
This illustrative workflow separates preparation of a figure
from preparation of the paragraph that explains it. The author
first checks the shape of the page using a placeholder. Next,
the author supplies the intended graphic and replaces the
temporary caption with an explanation of what the graphic shows.
The surrounding prose identifies the relevant features and
connects them to the argument in the report. During revision,
the author checks that the caption remains legible, that no
text overlaps the image, and that the paragraph returns to
its normal width after passing the figure. This passage is
sample layout text, not a description of an actual study.

The next paragraph continues the explanation after the specimen.
Its position provides another place to inspect the return to
ordinary paragraph formatting in the generated PDF.

\end{document}

For the production version, change the graphics package line to \usepackage{graphicx}. If the manuscript asset is named plot.pdf and is available in the document’s image search location, the replacement inclusion command is:

\includegraphics[width=0.9\linewidth]{plot.pdf}

Notice that the production command drops the demonstration’s fixed height. Setting width alone scales the graphic to that width; independently specifying width and height can change its proportions. A successful rectangle test therefore answers a limited question: whether this wrapping arrangement can be inspected independently of the actual asset. It does not certify the final figure’s readability.

Adjust placement without mixing syntaxes

The required placement argument accepts one letter. Use r for right or l for left; their uppercase counterparts allow floating. The i/o pairs refer to the inside and outside edges of a two-sided page. These are different from ordinary figure placement permissions such as [htbp].

For example, changing {r} to {R} permits the wrapped object to move. It does not resize the image. Changing the container width affects the amount of horizontal space available to text; it does not choose the page position. Make those changes separately so the resulting PDF tells you which setting caused the difference.

Output and how to read it

The example should produce a rectangle and caption on the right, with the following prose alongside them. Once the wrapping region is finished, subsequent text should occupy the normal paragraph width. Inspect the whole region, including the caption’s last line and the paragraph below the image.

Read width settings in their local context. The outer \textwidth expresses a fraction of the document’s text width. Inside the wrapping container, the image’s \linewidth refers to its available line width. The guide to LaTeX linewidth and local sizing explains why copying the same numeric fraction into different environments can produce different physical widths.

In this specimen, the image width is 0.9 × 0.34 = 0.306 of the surrounding text width. If you instead wrote width=0.9\textwidth inside the same container, you would request 90 percent of the page’s text width for an image whose container reserves only 34 percent. That mismatch explains the horizontal problem without changing the placement letter or line count. The arithmetic describes this example only; the final dimensions still depend on the document and the graphic. It also excludes the separate gap between the wrapping container and adjacent prose.

A useful review compares the placeholder and production versions at the same container width. If the placeholder fits but the real graphic becomes hard to read, look at the asset’s content and scaling before changing wrapping controls. If the caption or adjacent text changes after a revision, inspect that revised page rather than assuming the earlier placement still holds.

The downloadable data table below groups controls by the problem they address. It distinguishes horizontal image size, paragraph wrapping, whitespace and diagnostics. Use it to identify the appropriate control before editing several unrelated values at once; it is a reference to documented behavior, not a set of recommended dimensions.

Troubleshooting

Separate package and image problems

For an unrecognized wrapfigure environment, first check that \usepackage{wrapfig} is in the preamble and spelled correctly. For an image that does not appear, compare with the demo specimen: an enabled demo option intentionally displays a rectangle. Once that option is removed, the real asset must be supplied to the image loader.

Keep the original failing example while making the isolated specimen. Comparing them gives you a concrete difference to investigate: package loading, image inclusion or paragraph context. This workflow avoids treating every figure problem as a request for more negative vertical space.

Check horizontal overlap and excess whitespace

Keep the included image narrower than its wrapping container. Also distinguish blank space inside the image file from spacing introduced by LaTeX. Overleaf recommends \centering instead of a nested center environment to avoid that environment’s additional spacing. See the guide to center versus centering for the separate alignment task.

For an asset with unwanted borders, graphicx provides trim and clip. Its trim order is left, bottom, right, top. Cropping changes which part of the file is shown; enlarging the wrapping box changes how much space is reserved on the page. Choose between them by inspecting whether the unwanted area belongs to the file or the layout.

Check vertical wrapping and paragraph context

Begin with the automatic line estimate. The first optional argument overrides the number of shortened text lines; it is a count, not a height measurement. An override is appropriate to investigate when the visible wrapping region and the figure’s occupied height disagree. The final required argument remains the width.

Lists are a documented conflict, and placement near a page boundary needs particular care. Move the specimen into ordinary prose to isolate that context. The wrapping must also finish before an enclosing group, such as a minipage, ends. A package working in a simple article example does not establish that every enclosing environment in a manuscript class is compatible.

When movement is difficult to explain, replace the package-loading line with \usepackage[verbose]{wrapfig} to obtain the manual’s additional log diagnostics. Compare those messages with the placement letter and the remaining space on the page. Then review numbering alongside regular figures, since a good-looking wrap can still be out of numerical sequence.

Free alternatives

These are LaTeX layout approaches and packages rather than paid editing services. The two additional packages below are distributed under the LaTeX Project Public License according to their CTAN records. Choose according to the layout behavior you need; a replacement package should not be assumed to solve every class conflict.

Approach Documented behavior What to establish before switching
Ordinary figure environment Provides automatic positioning with a caption, as illustrated in Overleaf’s positioning documentation. Use when an independently placed figure is acceptable; it does not provide wrapfigure’s paragraph shape.
wrapfig2 CTAN describes a fork of wrapfig with support for the original environments; it requires a sufficiently recent LaTeX kernel. Check the fork’s current documentation and your installation before migrating an existing source file. CTAN flags tagged-PDF incompatibility.
floatflt CTAN documents text around figures or tables narrower than a page, with left/right or alternating placement. Review its own interface rather than copying wrapfigure arguments. CTAN also flags tagged-PDF incompatibility.

The alternatives table compares environment behavior, while the downloadable data table compares troubleshooting controls. They answer different decisions. In particular, neither another wrapping package nor a more precise width value should be presented as proof of tagged-PDF compatibility. If the output requirement changes, reassess that requirement explicitly before committing to the final layout.

Sources

Data: LaTeX wrapfigure diagnostic controls

An original compilation separating wrapping, image and logging controls, traced to the wrapfig manual, the LaTeX Project graphics manual and Overleaf documentation. Each row identifies the behavior controlled and the relevant diagnostic distinction.

LaTeX wrapfigure diagnostic controls
ControlDocumented effectDiagnostic distinctionSource URL
Placement letterLowercase places locally; uppercase permits floatingChanges placement rather than image dimensionshttps://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf
Required wrapping widthSets the wrapping container and caption widthSeparate from the width of the included imagehttps://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf
First optional argumentOverrides the estimated number of narrowed text linesA line count, not an image-height dimensionhttps://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf
Second optional argumentSets overhang into the marginSeparate from the requested width of the included graphichttps://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf
graphicx width keyScales the graphic to the specified widthImage scaling rather than wrapping placementhttps://mirrors.ctan.org/macros/latex/required/graphics/grfguide.pdf
graphicx demo optionUses a rectangle instead of an inserted imagePlaceholder behavior rather than successful image-file inclusionhttps://mirrors.ctan.org/macros/latex/required/graphics/grfguide.pdf
centering declarationCenters the image without the center environmentAvoids additional space introduced by the center environmenthttps://www.overleaf.com/learn/latex/Wrapping_text_around_figures
wrapfig verbose optionWrites additional floating diagnostics to the logLogging rather than an image-size settinghttps://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about LaTeX wrapfigure: setup, examples and fixes

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →