I appear to have come across a bug using wrapfig
. If I use a wrapfig
environment immediately before a \section{...}
command, then I get some bad behaviour, which appears to go away if I add some text after the wrapfig
environment.
\documentclass[12pt,a4paper]{article}
\usepackage{todonotes}
\usepackage{lipsum}
\usepackage{wrapfig}
\usepackage{fullpage}
\begin{document}
\lipsum[1]
\begin{wrapfigure}{r}{0.6\textwidth}
\missingfigure{}
\caption{a figure}
\end{wrapfigure}
%This text fixes it.
\section*{Lorem}
\lipsum[2-3]
\end{document}
Note the extra space in the final paragraph. If however I uncomment "This text fixes it", I get
I did a (brief) search and found nothing about this. What's going on?
Best Answer
The documentation of
wrapfig
tells you not to place awrapfigure
immediately before a list environment. The problem with\section
is, however, the same: bothwrapfigure
and\section
set\everypar
, which means “fail”.Just add
wrapfigure
after the section title.