Why Does a Wrapfigure Disappear After a Section Heading?
At a glance
- 1. Start a paragraph
A section heading leaves LaTeX in a special state; wrapfigure needs to attach to the following paragraph.
- 2. Add a mode switch
Try placing \leavevmode immediately after the heading and before the wrapfigure environment.
- 3. Continue the paragraph
Put the flowing text directly after \end{wrapfigure}, without a blank line that starts a new paragraph.
- 4. Check placement limits
If it still fails, move the wrapfigure into the paragraph body or check for page, list, and width constraints.
A wrapfigure placed immediately after a \section heading may fail to appear or may not wrap the text as expected. The usual cause is that a section heading leaves LaTeX in a special state for the first paragraph, while the wrapfig package needs to associate its image with a paragraph.
Try \leavevmode between the heading and the environment. The example below is a complete document; it uses a framed blank box as a stand-in for an image, so it compiles without an external image file.
Minimal example
\documentclass{article}
\usepackage{wrapfig}
\begin{document}
\section{A section with a wrapped image}
\leavevmode
\begin{wrapfigure}{r}{0.42\textwidth}
\centering
\fbox{\rule{0pt}{1.3in}\rule{0.34\textwidth}{0pt}}
\caption{A placeholder image.}
\end{wrapfigure}
This paragraph begins beside the framed placeholder. Continue writing
naturally: the text will use the space to the left of the image while
it is tall, then return to the full text width below it. Keep enough
text in this paragraph for the wrapping to be visible. A short paragraph
may end before the image does, making the layout look unexpected.
\end{document}
The package needed for the wrapping is wrapfig. In a real document, load graphicx as well if you use \includegraphics, and replace the framed placeholder with something like \includegraphics[width=\linewidth]{image-file}. The r option puts the image on the right; use l for the left. The width argument sets the width reserved for the whole wrapped figure, including its caption and any padding.
Why \leavevmode can help
Sectioning commands such as \section do more than print a heading: they also control how the following paragraph begins. wrapfig adjusts the shape of a paragraph so text flows around the image. Starting horizontal mode explicitly with \leavevmode can help the environment attach to the paragraph after the heading.
Keep the text that should wrap close to the environment. In particular, put the paragraph text immediately after \end{wrapfigure}. A blank line there starts a new paragraph, which may no longer receive the intended wrapping. The same principle applies if you put a short sentence before the image: the wrap may begin partway through that paragraph, rather than at its start.
If the image still does not appear
First, check whether the image is actually missing or only misplaced. If a placeholder works but \includegraphics does not, check that the file exists, that its name and path are correct, and that your compiler supports its format. For example, pdfLaTeX generally accepts PDF, PNG, and JPEG images, but not EPS directly without conversion or an appropriate workflow.
Then check the surrounding layout. wrapfigure is not an ordinary floating figure: it is intended to sit beside a paragraph, and its placement is sensitive to nearby page breaks and paragraph structure. It can behave poorly at the top or bottom of a page, inside lists, or in narrow columns. If the image is taller than the remaining space on the page, LaTeX may move or lay out the content differently than you expect. Try moving the environment a little later, shortening the image, or giving LaTeX more text to wrap.
If \leavevmode does not resolve the issue, a reliable alternative is to begin the section with a few words of normal text and put the wrapfigure later in that paragraph. This avoids placing the environment directly at the boundary after the heading. For layouts that must be fixed precisely, use a regular figure and let it float, or place the image and text in a deliberate two-column layout instead of relying on text wrapping.
Common mistakes
- Putting the environment in a separate paragraph from the text. A blank line after the environment can start a new paragraph, leaving the intended text outside the wrap.
- Using
figureinsidewrapfigure. Thewrapfigureenvironment already provides the wrapped figure structure; put the image and caption directly inside it. - Making the reserved width too small. Ensure the image and caption fit within the wrapfigure width. For a graphic,
width=\linewidthscales it to the available width inside the environment. - Assuming the figure is a fixed-position float. The placement letters are preferences, and the surrounding page layout can affect where wrapping is possible.
- Diagnosing a layout problem as a MiKTeX problem. If the document compiles and the placeholder appears, the issue is likely placement or paragraph structure, not the distribution itself.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.