2

I'm doing a poster, using a the a0poster style, and I was trying to wrap a itemize list around a figure. I tried the wrapfigure package, but I gathered it doesn't work with itemize lists, so I tried floatflt, which is supposed to work fine with lists (provided you use \fltitem). My MWE is as follows:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{floatflt}
\usepackage{multicol}
\usepackage{lipsum}
\usepackage[margin=2cm]{geometry}

\setlength\parindent{0pt}

\begin{document}
\lipsum[1]
\begin{multicols}{2} 

\section{Introduction}
\lipsum[2-3]

\begin{floatingfigure}[r]{0.5\columnwidth}
\centering
\includegraphics[width=0.48\columnwidth]{universe.jpg}
\caption{very very very very very very very very very very very very very very very very long caption}
\label{fig:example}
\end{floatingfigure}

\begin{itemize}
    \fltitem{one very very very very very long text}
    \fltitem{two very very very very very long text}
    \fltitem{three very very very very very long text}
\end{itemize}
\lipsum[4-7]

\end{multicols}
\end{document}

which results in (notice the absence of image next to the list):

MWE render

Thanks for the help!

2

The following builds upon https://tex.stackexchange.com/a/417571/117050 but extends it a lot. It defines the macros:

  • \InsertListR[<correction>]{<skip>}{<contents>} with the arguments <correction> being a correction factor as used by insbox (use it to extend the amount of lines affected), <skip> being a number of lines to skip before the insertion and <contents> being a box which is to be inserted.
  • \wrapitem used to start the first item after which you use \InsertListR
  • \contitem another item after you used \InsertListR which should also be affected. It takes an optional argument specifying the number of affected lines (defaulting to a whooping 100)
  • \EndInsert to manually stop the effects of an \InsertListR or any of the other insbox macros. It also starts a new paragraph. If the indentation should be suppressed you can use the starred version.

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{duckuments}% funnier than lipsum
\usepackage[margin=2cm]{geometry}
\usepackage{capt-of}
\usepackage{enumitem}

\input{insbox.tex}
\usepackage{etoolbox}
\newcommand*\wrapitem
  {%
    \apptocmd\labelitemi{\hskip\leftmargin}{}{}% add a correction
    \item
    \patchcmd\labelitemi{\hskip\leftmargin}{}{}{}% remove the added hskip
  }
\newsavebox\InsertListRbox
\newlength\InsertListPrevWidth
\makeatletter
\newcommand{\InsertListR}[3][]
  {%
    \mbox{}%
    \vspace*{-\baselineskip}%
    \setlength{\leftskip}{\leftmargin}%
    \setbox\InsertListRbox\hbox{#3}%
    \global\InsertListPrevWidth
      \dimexpr
        \wd\InsertListRbox+\@InsertBoxMargin
      \relax
    \InsertBoxR{#2}{\hskip-\leftmargin\box\InsertListRbox\hskip\leftmargin}[#1]%
  }%
\newcommand*\contitem[1][100]
  {%
    \item
      \ParShape=3
                {0}  0cm 0cm
                {#1} 0cm {\the\InsertListPrevWidth}
                1    0cm 0cm
  }
\newcommand*\EndInsert
  {
    \@restore@
    \@ifstar{\@afterindentfalse\@afterheading}{}%
  }
\makeatother

\begin{document}
\blindduck[1]
\begin{multicols}{0}
  \section{Introduction}
  \blindduck[-5]
  \begin{itemize}
    \wrapitem
    \InsertListR{0}
      {%
        \parbox{.48\columnwidth}
          {%
            \includegraphics[width=.48\columnwidth]{example-image-duck}%
            \captionof{figure}{foo}%
          }%
      }%
    one very very very very very long text
    \contitem two very very very very very long text
    \contitem three very very very very very long text
  \end{itemize}
  \EndInsert*
  \blindduck[1-5]
\end{multicols}
\end{document}

Results:

enter image description here

EDIT: More reasonable default for \contitem. By default this version does the same calculation insbox is doing to calculate the number of the affected lines. You can give the number explicitly if you're not satisfied with the results. It also changes the default value of \InsertListR to be a reasonable 0 (an empty default argument would be the same as 1, which won't be the expected behaviour from insbox).

Also for reasons I don't yet understand, the effect of \InsertListR is ended by the next new paragraph after the itemize environment. I therefore added a macro \MoreInsert which takes as its argument the number of lines which should be affected in the current paragraph (only in the current, another new paragraph ends its effect).

New code (in a complete MWE):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{duckuments}% funnier than lipsum
\usepackage[margin=2cm]{geometry}
\usepackage{capt-of}
\usepackage{enumitem}

\input{insbox.tex}
\usepackage{etoolbox}
\newcommand*\wrapitem
  {%
    \apptocmd\labelitemi{\hskip\leftmargin}{}{}% add a correction
    \item
    \patchcmd\labelitemi{\hskip\leftmargin}{}{}{}% remove the added hskip
  }
\newlength\InsertListPrevWidth
\makeatletter
\newcommand{\InsertListR}[3][0]
  {%
    \mbox{}%
    \vspace*{-\baselineskip}%
    \setlength{\leftskip}{\leftmargin}%
    \InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#1]%
    \global\InsertListPrevWidth\@framewidth
  }%
\newcommand*\contitem[1][\the\count1]
  {%
    \item
    \bgroup  % to keep some changes local
      % let's calculate parameters for \ParShape
      \def\reserved@a{#1}%
      \def\reserved@b{\the\count1}%
      \ifx\reserved@a\reserved@b
        % Below calculation is copied from \@@InsertBox of insbox
        \dimen0 = \@wherebottom
        \advance \dimen0 by -\pagetotal
        \divide \dimen0 by \baselineskip
        \count1 = \dimen0
        \advance \count1 by 1
        \advance \count1 by -\@numnormal
      \fi
      \MoreInsert{#1}%
    \egroup
  }
\newcommand*\EndInsert
  {%
    \@restore@
    \@ifstar{\@afterindentfalse\@afterheading}{}%
  }
\newcommand*\MoreInsert[1]
  {%
    \ParShape = 2
                {#1}   0cm   {\the\InsertListPrevWidth}
                1      0cm   0cm
  }
\makeatother

\begin{document}
\blindduck[1]
\begin{multicols}{0}
  \section{Introduction}
  \blindduck[-5]
  \begin{itemize}
    \wrapitem
    \InsertListR{0}
      {%
        \parbox{.48\columnwidth}
          {%
            \includegraphics[width=.48\columnwidth]{example-image-duck}%
            \captionof{figure}{foo}%
          }%
      }%
    one very very very very very long text
    \contitem two very very very very very long text
    \contitem three very very very very very long text
  \end{itemize}

  \MoreInsert{1}
  \blindduck[1-5]

  \blindduck[1-5]
\end{multicols}
\end{document}
  • That worked wonders, thank you very much! Quick add-on question, if I want to slightly increase the distance between the list on the left and the caption/figure, what should I change? – Rui Apóstolo Oct 3 '18 at 14:00
  • @RuiApóstolo include \makeatletter\@InsertBoxMargin=<length>\makeatother in your preamble after \input{insbox.tex}. Obviously <length> should be the width you want to use. Default of insbox is 2mm if I remember correctly. – Skillmon likes topanswers.xyz Oct 3 '18 at 15:37
  • Just to add (in case someone else needs it) the package \usepackage{caption} breaks this solution (especially the \MoreInsert command. I changed to \usepackage{capt-of} like @Skillmon has on their example and it works flawlessly. – Rui Apóstolo Oct 4 '18 at 15:41
  • @RuiApóstolo for me it works flawlessly with caption, generating identical output as with capt-of in my test cases. – Skillmon likes topanswers.xyz Oct 5 '18 at 7:28
  • Might have been my particular combination of packages then, I'm also using xcolor and contour on my figure captions. But as I said, with capt-of all works. – Rui Apóstolo Oct 5 '18 at 12:39

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.