[Tex/LaTex] Error: Missing \begin{document}

errorsmacros

I wanted to make a command that outputs a number in math mode. This is how my file looks like:

\documentclass{scrartcl}

%\usepackage{epsdice}
%\newcommand{dice}[1]{\epsdice{#1}}

\newcommand{dice}[1]{\ensuremath{#1}}

\begin{document}
Lorem ipsum...
\end{document}

But when I compile this with XeTeX, I always get this error:

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.13 \newcommand{dice}[1]{\ensuremath{#1}}

I have not that much experience with TeX, I think the solution is quite easy.

Best Answer

You're just missing a backslash in the command definition, it should be

\newcommand{\dice}[1]{\ensuremath{#1}}