# wrapfig doesn't detect paragraph

Working with wrapfig I have encountered some strange behavior involving the use of commands (of acro package) to start a paragraph (Similar to this: lettrine and wrapfig). Wrapfig does not detect the start of the paragraph and even worse, it does not end.

Is there any way around this? Thanks.

A MWE

\documentclass[12pt]{memoir}

\usepackage{wrapfig}
\usepackage{acro}
\usepackage{lipsum}

\DeclareAcronym{bosscha}{   short =     {Bosscha},   long =      {Johannes Bosscha Jr\acdot}, }

\begin{document}

\begin{wrapfigure}{R}{0.4\textwidth}
\centering
\rule{3cm}{7cm}
\caption{V.S.M. van der Willigen}
\end{wrapfigure}

\ac{bosscha}, 17 years of age, \lipsum

\end{document}


## EDIT:

Using the solution in the answer with InsertBoxR I have encountered some problems with the layout.

Script: \InsertBoxR{0}{\begin{minipage}[t]{0.4\textwidth} \centering \includegraphics[width=0.95\textwidth]{./Figures/06vdWilligen} \captionof{figure}{\acl{willigen}} \end{minipage}}[2] Result:

Wrapfig looks like this (if we workaround the list/acro problem.

PS: I have encountered similar problems with wrapfig and the color package.


\ac at the start of a paragraph begins the paragraph inside a local group, which confuses wrapfig. Start the paragraph like Anton says, or \mbox{}\ac{bosscha} or leavevmode\ac{bosscha} or \indent\ac{bosscha}. The placement and wrapping will be correct.

Note that \ac does \leavevmode internally, but not at the beginning where it makes sense, but inside grouping.

• All these solutions seem to work. Thanks for (I think) correctly addressing the underlying problem! – Thagusta Apr 11 at 9:26

You can have an easy solution with the insbox plain TeX macro package: use the \InsertBoxR{no of unshortened lines}{inserted object}[corrective number].

The optional corrective number is the number of additional shorter lines, in case TeX doesn't compute the correct number.

You can't use a floating environment in the second argument of this macro, so simply insert your graphic, and use the \captionof command from caption:

\documentclass[12pt]{memoir}
\usepackage{caption}
\usepackage{acro}
\usepackage{lipsum}
\input{insbox}
\DeclareAcronym{bosscha}{ short = {Bosscha}, long = {Johannes Bosscha Jr\acdot}, }

\makeatletter
\@InsertBoxMargin=8pt %% default is 2 mm
\makeatother

\begin{document}

\setcounter{chapter}{3}
\InsertBoxR{0}{\begin{minipage}[t]{0.4\textwidth}
\captionsetup{format=hang, justification=raggedright, font=small}
\centering \rule{3cm}{7cm}
\captionof{figure}{V.S.M. van der Willigen}
\end{minipage}}[2]

\ac{bosscha}, 17 years of age, \lipsum

\end{document}


• This works, although it is difficult to obtain the same layout as wrapfig (the rest of my document depends on it..) Thanks. – Thagusta Jun 25 '17 at 9:29
• Could you explain the difference with what wrapfig should yield? – Bernard Jun 25 '17 at 9:48

Try to write \mbox{\ac{bosscha}} instead of \ac{bosscha}.