# Problem with declaring new command containing number [duplicate]

I am trying to declare a new command using the following string:

\newcommand{\to8}[1]{\xrightarrow{\mathmakebox[0.8cm]{#1}}}


but the compiler returns many errors. I just don't understand why if I write

\xrightarrow{\mathmakebox[0.8cm]{iiiii}}


in the math mode the compiler returns no error but the compile does not allow it when I want to define it as a new command?

## marked as duplicate by egreg macros StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Sep 25 '16 at 8:35

• Without knowing the answer how do I know it is the problem with the name? I thought it was the problem of the parameter 0.8cm.. – PhysicsMath Sep 25 '16 at 14:24

The definition of your macro is fine. The problem is that you cannot have numbers in the name of a macro, so if you change the name of your macro then all will be well:

Btw, rather than posting code snippets it is better to post a minimal working example. In particular, the code should compile, unless that's the problem. This makes it much easier for other people to trouble shoot your problem and hence help you. Here is a MWE for your (corrected) code:

\documentclass{article}
\usepackage{mathtools}
\newcommand{\toeight}[1]{\xrightarrow{\mathmakebox[0.8cm]{#1}}}

\begin{document}

$\toeight{f}$

\end{document}

• Got you Andrew! I will follow your advice in my future posts! Many thanks for both the answer and the advice! – PhysicsMath Sep 25 '16 at 14:25

Can't have a number as part of a command.

   \documentclass{article}

\usepackage{mathtools}

\newcommand{\toeight}[1]{\xrightarrow{\mathmakebox[0.8cm]{#1}}}
\begin{document}
$$\toeight{xxx}$$
\end{document}