我希望在解决方案环境中绘制一个集合,但我的尝试导致了以下错误消息:
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}
和类似的事情,你会更快乐。