![Latex \in 和 \Z 都会导致未定义的控制序列错误](https://linux22.com/image/339654/Latex%20%5Cin%20%E5%92%8C%20%5CZ%20%E9%83%BD%E4%BC%9A%E5%AF%BC%E8%87%B4%E6%9C%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E6%8E%A7%E5%88%B6%E5%BA%8F%E5%88%97%E9%94%99%E8%AF%AF.png)
我的代码如下:
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[margin=0.5in]{geometry}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\begin{document}
...
Ex. If $x$ is even, then $x^2$ is even.
Proof: Let $y$ \in \Z $: x = 2y$ (we know y exists from the definition of even). Then:
\begin{equation}
x^2 = (2y)^2
x^2 = 4y^2
x^2 = 2(2y^2)
(2y^2) is an Integer (because Integers are closed under multiplication), so x^2 is Even.
\end{equation}
但当我跑步时pdflatex file.tex
,我得到
! Undefined control sequence.
l.26 Proof: Let $y$ \in
\Z $: x = 2y$ (we know y exists from the defini...
?
我尝试将 放入部分\in \Z
中$...$
,并尝试更改$...$
为\(...\)
,但无济于事。这可能是什么原因造成的?我该如何修复?
(解释一下:我从此列表。看来这份名单并不完全准确)
答案1
\in
是数学模式符号,需要数学模式。
\Z
只是未定义。我的猜测是这样的:
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[margin=0.5in]{geometry}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\usepackage{dsfont}
\newcommand*{\Z}{\mathds{Z}}
\begin{document}
Ex. If $x$ is even, then $x^2$ is even.
Proof: Let $y \in \Z\colon x = 2y$
\end{document}
或者使用\mathbb
:
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[margin=0.5in]{geometry}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\newcommand*{\Z}{\mathbb{Z}}
\begin{document}
Ex. If $x$ is even, then $x^2$ is even.
Proof: Let $y \in \Z\colon x = 2y$
\end{document}
此外,环境equation
不适用于多个方程。请参阅包的文档amsmath
。它为方程系统提供了许多环境(align
、、gather
...)。
答案2
这就是你想要的吗?
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[margin=0.5in]{geometry}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\begin{document}
...
Ex. If $x$ is even, then $x^2$ is even.
Proof: Let $y\in Z : x = 2y$ (we know y exists from the definition of even). Then:
\begin{equation}
\begin{aligned}
x^2 &= (2y)^2\\
\Leftrightarrow x^2 &= 4y^2\\
\Leftrightarrow x^2 &= 2(2y^2)
\end{aligned}
\end{equation}
$(2y^2)$ is an Integer (because Integers are closed under multiplication), so $x^2$ is Even.
\end{document}