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.
- 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.
- Load the two packages. Keep
\usepackage[demo]{graphicx}for this first test and loadwrapfigafter it. The graphics manual documents the placeholder behavior. - 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.
- Set the container and image separately. The container is
0.34\textwidth; the image uses0.9\linewidthinside that container. Its explicit height makes the test rectangle easy to recognize. - 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.
- Replace the placeholder. Remove the
demooption, 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
- CTAN: wrapfig package record. Checked 2026-11-16.
- Donald Arseneau: The wrapfig package, version 3.6. Checked 2026-11-16.
- Overleaf: Wrapping text around figures. Checked 2026-11-16.
- Overleaf: How do I wrap text around a figure?. Checked 2026-11-16.
- LaTeX Project: Packages in the graphics bundle, 2026-05-17. Checked 2026-11-16.
- Overleaf: Positioning images and tables. Checked 2026-11-16.
- CTAN: wrapfig2 package record. Checked 2026-11-16.
- CTAN: floatflt package record. Checked 2026-11-16.
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.
| Control | Documented effect | Diagnostic distinction | Source URL |
|---|---|---|---|
| Placement letter | Lowercase places locally; uppercase permits floating | Changes placement rather than image dimensions | https://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf |
| Required wrapping width | Sets the wrapping container and caption width | Separate from the width of the included image | https://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf |
| First optional argument | Overrides the estimated number of narrowed text lines | A line count, not an image-height dimension | https://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf |
| Second optional argument | Sets overhang into the margin | Separate from the requested width of the included graphic | https://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf |
| graphicx width key | Scales the graphic to the specified width | Image scaling rather than wrapping placement | https://mirrors.ctan.org/macros/latex/required/graphics/grfguide.pdf |
| graphicx demo option | Uses a rectangle instead of an inserted image | Placeholder behavior rather than successful image-file inclusion | https://mirrors.ctan.org/macros/latex/required/graphics/grfguide.pdf |
| centering declaration | Centers the image without the center environment | Avoids additional space introduced by the center environment | https://www.overleaf.com/learn/latex/Wrapping_text_around_figures |
| wrapfig verbose option | Writes additional floating diagnostics to the log | Logging rather than an image-size setting | https://mirror.math.princeton.edu/pub/CTAN/macros/latex/contrib/wrapfig/wrapfig-doc.pdf |
Sources
- Donald Arseneau: The wrapfig package, v3.6 (accessed 2026-11-16)
- LaTeX Project: Packages in the graphics bundle (accessed 2026-11-16)
- Overleaf: Wrapping text around figures (accessed 2026-11-16)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







