1

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?

  • 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

2 Answers2

5

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:

enter image description here

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

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

   \documentclass{article}

\usepackage{mathtools}

\newcommand{\toeight}[1]{\xrightarrow{\mathmakebox[0.8cm]{#1}}}
\begin{document}
    \begin{equation}
    \toeight{xxx}
    \end{equation}
\end{document}
JPi
  • 13,595