I can wrap in ARTICLE, but not in EXAM. How to wrap in EXAM? (Question Plus-if you´re a LaTeX master-.- What´s the mosr suitable and easy package to do this kind of things?)
I can wrap a figure in an ARTICLE document
with this code
\documentclass[12pt]{article}
\usepackage{graphicx,wrapfig,lipsum}
\usepackage[onehalfspacing]{setspace}
\usepackage{mwe}
\begin{document}
%\begin{questions}
\begin{wrapfigure}{r}{.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a.png}
\caption{This is A}
\end{wrapfigure}
Hello, I want to wrap this figure in exam
\lipsum[2]\lipsum[1]
%\end{questions}
\end{document}
BUT I´d like wrap images in EXAM documents, and this code doesn´t give the wrapped figure:
\documentclass[12pt]{exam}
\usepackage{graphicx,wrapfig,lipsum}
\usepackage[onehalfspacing]{setspace}
\usepackage{mwe}
\begin{document}
\begin{questions}
\begin{wrapfigure}{r}{.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a.png}
\caption{This is A}
\end{wrapfigure}
\question Hello, I want to wrap this figure in exam
\lipsum[2]\lipsum[1]
\end{questions}
\end{document}
**
EDITED (2019/02/24) Afther trying Skillmon solution, I have a new problem with lists(enumerate) in the questions
**
With the code (only adding itemize in thq euestion with the figure)
\documentclass[12pt]{exam}
\usepackage{graphicx,wrapfig,lipsum}
\input{insbox}
\usepackage{capt-of}
\usepackage[onehalfspacing]{setspace}
\usepackage{mwe}
\usepackage{etoolbox}
\makeatletter
%% Stealing some code from exam:
\def\mypointshandling
{%>>>
\if@bonus
\def\padded@point@block{%
\begingroup
\@placepointstrue
\bonuspoint@block
\endgroup
}%
\else
\def\padded@point@block{%
\begingroup
\@placepointstrue
\point@block
\endgroup
}%
\fi
\if@pointsdropped
\else
\if@bonus
\if@bonusqformat
\ifx\ques@ref\@queslevel
\else
\setup@point@toks
\fi
\else
\setup@point@toks
\fi
\else
\if@qformat
\ifx\ques@ref\@queslevel
\else
\setup@point@toks
\fi
\else
\setup@point@toks
\fi
\fi
\fi
\global \MyIfPointsfalse
}%<<<
\newif\ifMyIfPoints
\protected\def\questionInsbox
{%
\@ifnextchar[\questionInsbox@a{\questionInsbox@a[]}%
}
\protected\long\def\questionInsbox@a[#1]#2#3%
{%
\@ifnextchar[{\questionInsbox@b{#1}{#2}{#3}}
{\questionInsbox@b{#1}{#2}{#3}[0]}
}
\long\def\questionInsbox@b#1#2#3[#4]%
{%
\apptocmd\@itemlabel{\hskip\leftmargin}{}{}%
\def\makelabel##1{\hss\llap{##1}}%
\if\relax\detokenize{#1}\relax
\question
\else
\global\MyIfPointstrue
\patchcmd\@readpoints{\global\@placepointstrue}{\relax}{}{}%
\question[#1]%
\patchcmd\@readpoints{\relax}{\global\@placepointstrue}{}{}%
\fi
\patchcmd\@itemlabel{\hskip\leftmargin}{}{}{}%
\let\makelabel\@mklab
\mbox{}%
\vspace*{-\baselineskip}%
\setlength{\leftskip}{\leftmargin}%
\InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#4]%
\ifMyIfPoints
\mypointshandling
\fi
\the\point@toks
\ignorespaces
}
\makeatother
\begin{document}
\begin{questions}
\question Jei you
\questionInsbox[5]{0}
{%
\parbox[t]{.3\linewidth}
{%
\centering
\includegraphics[width=\linewidth]{example-image-a.png}
\captionof{figure}{This is A}%
}%
}[1]
Hello, I want to wrap this figure in exam, and you should choose the rigth answer:
\begin{enumerate}
\item \lipsum[1]
\item \lipsum[1]
\end{enumerate}
\question Another
\end{questions}
\end{document}
The solution, not the best but... on the fly I have typed is:
\question See figure and answer, please:
\begin{enumerate}
\begin{multicols}{2}
\item answer 1
\item ans 2
\item ans 3
{\centering
\begingroup
\centering
\includegraphics[width=1.00\linewidth]{{example-image-a.png}
\vspace{-0.3cm}
\captionof{figure}{}
\label{fig:croquis-rectangulo-ecuacions.png}
\endgroup}
\end{multicols}
\item ans afeter fig
\end{enumerate}
EDIT (2019/02/25) after EDIT 3 of Skillmon I admire yout knowledge of LaTeX programming. It´s fantastic!!
The solution if perfect for normal text but when you use lists (enumerate, itemize,...) the problem is remaining. After reading the last comments (2019/02/24) of Skillmon, I decide to simulate the lists in normal text. With \ a) answer 1 answer 1 answer 1 answer 1 answer 1 answer 1 answer 1 answer 1 answer 1 answer 1 answer 1 answer 1\ b) answer 2 answer 2 answer 2 answer 2 answer 2 answer 2 answer 2 answer 2 answer 2 answer 2 answer 2 answer 2\
LaTeX is so beatifull, so complicated!!
Waiting for this option (I´m optimistic, yes!! :-) ) in exam class in the future... I´ll use your solutions sometimes.
Only fails in the bottom of page, as far as I can see, and when you use some \questionInsboxL[5]{2} with close to blank page between questions.
THANK YOU FOR ALL YOUR SOLUTIONS AND EFFORTS!
THANK YOU, SKILLMON






examand lists (and 40 lines are just a simple copy of some code ofexamto use it elsewhere). See my new edit for figures on the left and right. – Skillmon Feb 24 '19 at 08:24itemizeorenumerateis different. This solution is tailored to work inside ofquestionswith a\question. For a solution that works initemizeinstead, see the link I refer to in my answer. The situation with different types of lists is less than ideal and each type of list needs its own set of adaptations to make theinsboxsolution work. I originally planned to write a package which tries to tackle this, but up till now I didn't succeed in doing so (and in fact this question didn't contribute to my motivation) :) – Skillmon Feb 24 '19 at 11:57enumerate. I might come up with something. – Skillmon Feb 24 '19 at 11:59