Latex \in and \Z both cause Undefined Control Sequence error

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:
$$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.$$


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)

• Welcome to TeX.SE! It looks like you haven't defined the macro \Z; I assume it should be defined as \newcommand{\Z}{\mathbb{Z}}. Also, instead of $y$ \in \Z $: x = 2y$, write $y \in \Z : x = 2y$ -- get rid of two of the $ symbols. – Mico Aug 22 '16 at 19:55 2 Answers \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}  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}  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. • Thank you! I'm confused though: the symbols were listed here - the link is wrong? – Miryafa Aug 22 '16 at 20:05 • @Miryafa - The table you've linked to is dodgy. For sure, neither the LaTeX kernel nor the amssymb package define \N, \Z, \Q, \R, etc. – Mico Aug 22 '16 at 20:09 • @Miryafa See: The Comprehensive LaTeX Symbol List. – Heiko Oberdiek Aug 22 '16 at 20:24 • curious why you bothered to load amssymb when you override it with dsfont. \in is one of the "core" math symbols, so no extra package is needed. – barbara beeton Aug 22 '16 at 20:39 • @barbarabeeton The start of the preamble is just inherited from the question. Also packages mathtools, geometry, and the settings of \parindent and \parskip are not needed for the example. The preamble additions for defining \Z are separated by a blank line. – Heiko Oberdiek Aug 22 '16 at 20:44 Is this what you wanted? \documentclass{article} \usepackage{mathtools} \usepackage{amssymb} \usepackage[margin=0.5in]{geometry} \setlength{\parindent}{0em} \setlength{\parskip}{1em} \begin{document} ... Ex. Ifx$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{aligned} x^2 &= (2y)^2\\ \Leftrightarrow x^2 &= 4y^2\\ \Leftrightarrow x^2 &= 2(2y^2) \end{aligned}(2y^2)$is an Integer (because Integers are closed under multiplication), so$x^2\$ is Even.
\end{document}


• Yes, that looks good too! Thank you (I upvoted your answer, but don't yet have enough rep for it to show). – Miryafa Aug 22 '16 at 20:12