3

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}

MWE

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: with InsertBoxR. Undesirable is the line break and the caption seems to go over unwrapped text.

Wrapfig looks like this (if we workaround the list/acro problem.with Wrapfig. Nice space above picture for aesthetics, no wrapping problems

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

  • wrapfig does not support following list environments, possibly \ac is some kind of a list-like environment. I used the following (ugly) workaround just for debugging (it works): \newcommand{\longForm}{Johannes Bosscha Jr} \newcommand{\shortForm}{Bosscha} \DeclareAcronym{bosscha}{short = {\shortForm}, long = {\longForm\acdot},} and instead of \ac{bosscha} ... I used: \longForm{} (\shortForm), 17 years of age, \lipsum – lAtExFaN Jun 24 '17 at 16:07
3

\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.

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

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} 

enter image description here

| improve this answer | |
  • 1
    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
2

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.