3

I am trying to wrap pictures around list environments. I've found this question: Wrapping itemize around figure using floatflt in multicol environment - figure doesn't show And the answer of this question is working almost perfectly.

One of the problems I've noticed is that if I am trying to make two points with \itempicture (from my code) in one list then something makes the second number point be further away from the text.

Can somebody point out why and help to fix this?

PS. I see that \end{enumerate}\vspace*{-\baselineskip}\begin{enumerate}[resume*] between itempictures actually solves this problem. But I'm genuinely interested what am I missing.

spa

MY MWE

\documentclass{article}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{graphicx}
\input{insbox.tex}
\usepackage{xargs}
\usepackage{etoolbox}
\usepackage{calc}
\usepackage[margin=1cm, footskip = 1 cm]{geometry}
\usepackage[font=footnotesize]{caption}
\usepackage{microtype}
\usepackage{threeparttable}
\usepackage{changepage}
\usepackage{printlen}   

\newcommand*\wrapitem{%
    \apptocmd\labelenumi{\hskip\leftmargin}{}{}% add a correction
    \item
    \patchcmd\labelenumi{\hskip\leftmargin}{}{}{}% remove the added hskip
}

\makeatletter
\newcommand{\InsertListR}[3][0]{%
    \mbox{}%
    \vspace*{-\baselineskip}%
    \setlength{\leftskip}{\leftmargin}%
    \InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#1]%
}%

\newcommand{\itempicture}[3][5]{    
    \wrapitem
    \InsertListR[#1]{0}{\begin{threeparttable}\begin{tabular}{c@{}}\captionsetup{type=figure}\includegraphics[width=#3\textwidth]{#2}\end{tabular}\captionof{figure}{}\label{#2}\end{threeparttable}}
}

\begin{document}
\begin{enumerate}
\itempicture[5]{example-image-a}{0.15}
\lipsum[1]
\itempicture[5]{example-image-a}{0.15}
\lipsum[1]
\end{enumerate}
\end{document}
2
  • What is in insbox.tex people cannot tat the mwe without it. Is it relevant?
    – daleif
    Jun 29 '19 at 15:46
  • @daleif it's a generic pack­age which is very useful when wrapping images and insbox often works better than other packages, because it's based on plain TeX. ctan.org/pkg/insbox And yes, it is the the most important part.
    – user98432
    Jun 29 '19 at 15:55

Your Answer

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