ソリューション環境内でのスケッチ

ソリューション環境内でのスケッチ

ソリューション環境内でセットをスケッチしたいのですが、試みると次のエラー メッセージが表示されます。

LaTeX Error: Float(s) lost.

これをどう修正すればい​​いでしょうか?ここに私のコードの一部を示します

  \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}

答え1

必要なfigureのは環境ではなく、次のものです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}

ここに画像の説明を入力してください

タイピング\mathbf{0}などを練習すれば、もっと幸せになれるでしょう。

関連情報