# Natbib breaking wrapfig

I am using natbib for citation and am encountering some problems with wrapfigures (or wraptables) which sit next to paragraphs starting with natbibs \citet or \citep (and probably other citation commands).

\documentclass{scrartcl}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{ABC,
year = {2006},
title = {{ABC}},
editor = {Parker, Peter}
}
\end{filecontents}

\usepackage[authoryear]{natbib}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}

\lipsum[3]

\begin{wrapfigure}{O}{5cm}
\rule{4.5cm}{4.5cm}
\end{wrapfigure}

\citet{ABC} %uncomment and everything's fine
\lipsum[3]

\par\lipsum[3]\par\lipsum[3]\par\lipsum[3]

\bibliographystyle{apalike}
\bibliography{\jobname}

\end{document}


As soon as the paragraph does not start with \cite... everythin works as expected but in this case the paragraph starting with \cite will not wrap around the figure - the following pars then unnecessarily do wrap around nothing.

The definition of \citet could be more robust, it starts a group too early.

It works if you use

\mbox{}\citet{ABC}


so it doesn't formally start the paragraph.

Alternatively you can redefine \citet in your preamble after loading natbib

\edef\citet{\noexpand\leavevmode
\noexpand\protect
\expandafter\noexpand\csname citet \endcsname}


Then the \mbox{} is not needed.