Dibujar dentro de un entorno de solución

Dibujar dentro de un entorno de solución

Deseo esbozar un conjunto dentro de un entorno de solución, pero mis intentos generaron el siguiente mensaje de error:

LaTeX Error: Float(s) lost.

¿Cómo puedo solucionar esto? Aquí hay un fragmento de mi código.

  \documentclass[a4paper,11pt]{exam} % A4 paper and 11pt font size 

 \usepackage[english]{babel} % English language 
  \usepackage{tikz} % Tikz package for sketching 
  \usepackage{amsmath,amsfonts,amsthm,amssymb} %% American Mathematical Society packages

  \newcommand{\x}{\mathbf{x}}

\begin{document}

\begin{question}
 \question Let $\mathbf 0 = (0,0)$. Sketch the set $\{\x \in \mathbb R^2 d_m(\mathbf 0, x )\le 1\} $.
\begin{solution}
 \begin{figure}
 \centering
  \begin{tikzpicture} [scale =3]
  \draw[thick, ->] (-1.5,0) -- (1.5,0);
  \draw[thick, ->] (0,-1.5) -- (0,1.5)
  \draw (-1,-1) rectangle (1,1);
  \end{tikzpicture}
 \caption*{$d_m(\mathbb 0, \x) \le 1$
\end{figure}
\end{solution}
\end{questions}

Respuesta1

No quieres un figureentorno, sino un minipage:

\documentclass[a4paper,11pt]{exam} % A4 paper and 11pt font size 

\usepackage[english]{babel} % English language 
\usepackage{tikz} % Tikz package for sketching 
\usepackage{amsmath,amsfonts,amsthm,amssymb} %% American Mathematical Society packages

\newcommand{\x}{\mathbf{x}}

\printanswers

\begin{document}

\begin{questions}
\question 
  Let $\mathbf{0} = (0,0)$. Sketch the set 
  $\{\x \in \mathbb{R}^2 : d_m(\mathbf{0}, \x)\le 1\}$.

\begin{solution}

\begin{minipage}{\linewidth}
\centering
  \begin{tikzpicture} [scale =3]
  \draw[thick, ->] (-1.5,0) -- (1.5,0);
  \draw[thick, ->] (0,-1.5) -- (0,1.5);
  \draw (-1,-1) rectangle (1,1);
  \end{tikzpicture}
\end{minipage}
\end{solution}
\end{questions}

\end{document}

ingrese la descripción de la imagen aquí

Entrénate para escribir \mathbf{0}y cosas similares, serás más feliz.

información relacionada