2

At this comment Bernard claims that insbox does work in lists if we add some commands. Now I wonder which commands enable us to do this.

\documentclass[]{article}

\input{insbox.tex}
\usepackage{lipsum}
\usepackage{caption}

\begin{document}
\begin{itemize}
  \InsertBoxR{2}{\parbox{2cm}{\rule{2cm}{1cm}\captionof{figure}{foo}}}
  \item \lipsum[2]
\end{itemize}
\end{document}
4

Here is how I do it: I defines a \wrapitem command, which patches \item, and an \InsertListR command, patching \InsertBoxR, and which must follow immediately \wrapitem. The other items use the standard \item command.

It works fine as long as the inserted item does not overflow into the next item, and is adapted to the standard right-alignment of the labels. I guess it could be adapted to the left-aligned case (such as with the wide option), but I didn't do it. It also can be easily adapted to enumerate environments.

If the image overflows the next item, a work-around consists in splitting the itemize environment into several, playing with the resume*and before options of enumitem. I give an example in the following code:

\documentclass[]{article}
\usepackage[showframe]{geometry}
\usepackage[svgnames]{xcolor} 
\usepackage{enumitem}
\input{insbox.tex}
\usepackage{lipsum}
\usepackage{caption}
    \usepackage{etoolbox}

    \newcommand*{\wrapitem}{\apptocmd{\labelitemi}{\hskip\leftmargin}{}{}\item\apptocmd{\labelitemi}{\hskip-\leftmargin}{}{}}
    \newcommand{\InsertListR}[3][]{%
    \mbox{}\vspace*{-\baselineskip}\setlength{\leftskip}{\leftmargin}%
    \InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#1]%
    }%

\begin{document}

\begin{itemize}
  \wrapitem%
 \InsertListR{2}{~\parbox{2cm}{\color{WhiteSmoke}\rule{2cm}{1cm}\captionof{figure}{foo}}}%
 Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi
auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ul-
tricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula
aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hen-
drerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla.
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum
turpis. Pellentesque cursus luctus mauris.
\item \lipsum[3]
\end{itemize}

\begin{itemize}%[leftmargin =2cm]%
  \wrapitem%
 \InsertListR[7]{2}{~\parbox{2cm}{\color{Gold!50}\rule{2cm}{3cm}\captionof{figure}{foo}}}%
 \lipsum[2]
 \end{itemize}
%
 \begin{itemize}[resume*, rightmargin = 2.5cm]
\item%
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa ac quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo.
\end{itemize}
%
 \begin{itemize}[resume*, before=\leavevmode\vspace*{-\dimexpr\baselineskip+2\topsep+\partopsep}]
\item[]%
Maecenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia nulla vitae enim. Pellentesque tincidunt purus vel magna. Integer non enim. Praesent euismod nunc eu purus. Donec bibendum quam in tellus. Nullam cursus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum pellentesque felis eu massa.
\end{itemize}

\end{document} 

enter image description here

|improve this answer|||||
  • @Skillmon: I've posted a sample of what I can do – which is far from perfect… – Bernard Feb 27 '18 at 13:11
  • I built upon your sample here. It isn't thoroughly tested but extents your approach to work without the use of separate itemize environments. – Skillmon likes topanswers.xyz Oct 3 '18 at 17:28
  • @Skillmon: Thank you. I'll try to test, and report if there's any problem :-) – Bernard Oct 3 '18 at 18:38

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.