[Tex/LaTex] Latex \in and \Z both cause Undefined Control Sequence error

math-modesymbols

My code looks like this:

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

But when I run pdflatex file.tex, I get

! Undefined control sequence.
l.26 Proof: Let $y$ \in 
                            \Z $: x = 2y$ (we know y exists from the defini...

?

I tried putting the \in \Z in the $...$ section, and tried changing $...$ to \(...\), to no avail. What could be causing this and how can I fix it?

(To explain: I got the symbols from this list. It seems the list is not entirely accurate)

Best Answer

\in is a math mode symbol, which requires math mode.

\Z is just undefined. My guess is something like:

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

Result \mathds

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

Result \mathbb

Also environment equation is not intended for more than one equation. See documentation of package amsmath. It provides many environments (align, gather, ...) for equation systems.