0

Good day!!. Here I faced challenges when using wrap figure insid the list. Please suggest me how to fix this.

MWE:

\documentclass{book}

\usepackage{wrapfig}
\usepackage[no-math]{fontspec}
\usepackage{graphicx,epstopdf}

\begin{document}


\begin{enumerate}
\item How much energy does the electron gain as it moves from the negative plate to the positive plate?

\begin{wrapfigure}[12]{r}{12pc}%
\caption{This is a sample Caption}
\includegraphics{c01f002}
\end{wrapfigure}

\item How much energy does the electron gain as it moves from the negative plate to the positive plate?

\item How fast will the electron be travelling when it hits the positive plate, if it left the negative plate with zero velocity?

\item How much energy does the electron gain as it moves from the negative plate to the positive plate?

\item How fast will the electron be travelling when it hits the positive plate, if it left the negative plate with zero velocity?

\item How much energy does the electron gain as it moves from the negative plate to the positive plate?

\item How fast will the electron be travelling when it hits the positive plate, if it left the negative plate with zero velocity?

\item How much energy does the electron gain as it moves from the negative plate to the positive plate?
\end{enumerate}

\end{document}
remco
  • 1,017

1 Answers1

3

Here is a solution with insbox plain TeX macro package and the resume and rightmargin keys from enumitem.

The general idea is to stop the list at the point where you want to insert the graphic file (and insert the image), resume the list with a right margin slightly larger than the width of the image, then stop the list again after the number of items necessary to place the image and its caption and finally end the list with the default parameters.

\documentclass[demo]{book}

\usepackage[no-math]{fontspec}
\usepackage{wrapfig}
 \usepackage{graphicx, epstopdf}
 \usepackage{enumitem}
\usepackage{caption}

\input{insbox.tex}

\begin{document}

%\InsertBoxR{2}{\includegraphics[width =12pc]{c01f002}}

\begin{enumerate}[after = \vspace*{-\topsep }]
\item How much energy does the electron gain as it moves from the negative plate to the positive plate?
\end{enumerate}
\InsertBoxR{1}{\parbox{12pc}{\includegraphics[width =12pc]{c01f002}\captionof{figure}{This is a sample Caption}}}
\begin{enumerate}[resume*, rightmargin=13pc, before = \vspace*{\dimexpr\itemsep- \topsep}, after = \vspace*{-\topsep }]
\item How much energy does the electron gain as it moves from the negative plate to the positive plate?

\item How fast will the electron be travelling when it hits the positive plate, if it left the negative plate with zero velocity?

\item How much energy does the electron gain as it moves from the negative plate to the positive plate?

\item How fast will the electron be travelling when it hits the positive plate, if it left the negative plate with zero velocity?
\end{enumerate}
%
\begin{enumerate}[resume*, before = \vspace*{\dimexpr\itemsep- \topsep-\baselineskip}]
\item How much energy does the electron gain as it moves from the negative plate to the positive plate?

\item How fast will the electron be travelling when it hits the positive plate, if it left the negative plate with zero velocity?

\item How much energy does the electron gain as it moves from the negative plate to the positive plate?
\end{enumerate}

\end{document} 

enter image description here

Bernard
  • 271,350