# How to use figure inside a exercise environment?

Trying to use figure inside an Exercise environment (exercise.sty) gives me "LaTeX Error: Not in outer par mode."

Example:

\documentclass{article}

\usepackage[]{exercise}
\begin{document}

\begin{Exercise}[title={foo}, label=ex1]
A tough question.
\end{Exercise}

\begin{figure}[htp]
\centering
\includegraphics[totalheight=0.2\textheight]{couetteFlowFig1.png}
\label{fig:ex1}
\end{figure}

\end{document}

I see in Is it possible to use the figure environment with the standalone package? that there was a similar problem with a different package, and that limitation in the package was eventually handled. It appears the same limitation exists in the exercise environment. Is there a work around that allows for inclusion of a figure with that package, or a different way of including a figure when using this package?

-

There is no requirement to place an image (using \includegraphics, say) inside a figure environment. The figure environment is merely a floating placeholder. So, you can just put your image inside a center environment to centre it on the page, and even add a caption using \captionof from the caption package.

\documentclass{article}
\usepackage{caption}% http://ctan.org/pkg/caption
\usepackage{exercise}% http://ctan.org/pkg/exercise
\begin{document}

\begin{Exercise}[title={foo}, label=ex1]
A tough question.
\end{Exercise}

\begin{center}
%\includegraphics[totalheight=0.2\textheight]{couetteFlowFig1.png}
\rule{150pt}{100pt} \par
\captionof{figure}{This is a figure caption.}
\label{fig:ex1}
\end{center}