[Tex/LaTex] “missing \begin{document}” when setting new command

compilation errorerrorsmacros

I'm trying to get this command into my LaTeX document but it causes the compiler to fail, saying "Missing \begin{document}":

\newcommand{\C*}{\mathbb{C} \setminus \lbrace 0 \rbrace}

I have also tried using \C0 instead of \C* thinking the asterisk might cause an issue, but to no change in the error message. The error message also says I can't use \mathbb{.} outside math mode, which I am not trying to do. Using \newcommand{\CC}{\mathbb{C}} is working fine in my document, I don't understand the difference to be honest and thus I can't figure out how to fix the issue.

Best Answer

Command names have to be letters or a single non letter you can not have a command \C* or \C0

After the first couple of expansions your input is more or less the same as this, which gives the same error.

\documentclass{article}


\newcommand{\C}{}{*}{\mathbb{C} \setminus \lbrace 0 \rbrace}

\begin{document}

\end{document}

So \C gets defined

 \newcommand{\C}{}

then it starts a paragraph of text with the symbol * which gives the missing document error as you can not typeset text before \begin{document}

{*}

Then if you scroll past that it tries to typeset

{\mathbb{C} \setminus \lbrace 0 \rbrace}

which gives an error because it is not in math mode.

Related Question