11

I am trying to float a figure using wrapfigure within an exam document using minipage. If I don't use a minipage, then the exam questions do not wrap around the figure. When I use minipage as in the example below, everything wraps, but if the minipage (or the longer form with solutions included with \printanswers) is longer than one page, then the typesetting runs off the bottom.

My simple question is this: what's the correct way to include figures in an exam? My example questions block follows:

\documentclass{exam}
\usepackage{amsmath}
\usepackage{graphics}
\usepackage{wrapfig}
\begin{document}
\begin{questions}
\begin{minipage}{\linewidth}
\begin{wrapfigure}{r}{9cm}
\includegraphics[width=8cm]{./20x20grid-axes.png}
\end{wrapfigure}

\question Answer all parts below: 

\begin{parts}

\part[1] 1 + 1 = \answerline

\fullwidth{\begin{solution}\begin{align*} \boxed{ 2 } \end{align*}\end{solution}}

\part[1] 2 + 2 = \answerline

\fullwidth{\begin{solution}\begin{align*} \boxed{ 4 } \end{align*}\end{solution}}

\part[1] 3 + 3 = \answerline

\fullwidth{\begin{solution}\begin{align*} \boxed{ 6 } \end{align*}\end{solution}}

\end{parts}
\end{minipage}
\end{questions}
\end{document}
2
  • Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you.
    – doncherry
    Dec 3, 2012 at 19:45
  • Did I get the class and packages right? Otherwise please edit your question into a minimal working example (MWE).
    – Stephen
    Dec 3, 2012 at 19:54

1 Answer 1

5

One possibility would be to move the minipage inside the parts environment, and ending it as soon as enough material has been wrapped, as the following example illustrates:

\documentclass{exam}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{amsmath}

\begin{document}

\begin{questions}
\question Answer all parts below: 

\begin{parts}
\begin{minipage}{\linewidth} 
\begin{wrapfigure}{r}{9cm}
\hfill
\includegraphics[width=8cm]{./20x20grid-axes.png}
\end{wrapfigure}
\part[1] 1 + 1 = \answerline

\fullwidth{\begin{solution}\begin{align*} \boxed{ 2 } \end{align*}\end{solution}}

\part[1] 2 + 2 = \answerline

\fullwidth{\begin{solution}\begin{align*} \boxed{ 4 } \end{align*}\end{solution}}

\part[1] 3 + 3 = \answerline

\fullwidth{\begin{solution}\begin{align*} \boxed{ 4 } \end{align*}\end{solution}}
\end{minipage}

\part[1] 3 + 6 = \answerline

\fullwidth{\begin{solution}\begin{align*} \boxed{ 6 } \end{align*}\end{solution}}

\end{parts}
\end{questions}

\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .