# why this \newcommand doesn't work in \align environment?


     \documentclass[A4,12pt]{article}
\usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{abraces}
\usepackage{upgreek}
\usepackage{mathrsfs}
\usepackage{dsfont}
\usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
\usepackage{dsfont,float}
\usepackage{color}
\newcommand{\rbel}{
\mbox{\;\rightarrow_{\hspace*{-0.3cm}{\small n}}\;~}
}
\begin{document}
\begin{align}
\dfrac{1}{\theta_n^2} \rbel 0
\end{align}
\end{document}


That gives these messages

"Missing } inserted. \end{align}"
"Missing \cr inserted. \end{align}"
"Missing inserted. \end{align}" "Extra }, or forgotten. \end{align}"

• Your \rbel-command contains an \mbox. Even in math-mode the content of \mboxes isn't in math-mode any more as \mboxes switch to text-mode... – Ulrich Diez Feb 9 at 16:18
• For avoiding linebreaks in math-mode usually nesting things in curly-brace-groups is sufficient. I.e., just do without the \mbox: \newcommand{\rbel}{{\;\rightarrow_{\hspace*{-0.3cm}{\small n}}\;~}} – Ulrich Diez Feb 9 at 16:26
• This is not causing your issue but with your preamble the dsfont package is loaded twice. – Ulrich Diez Feb 9 at 16:28
• There is also \mathmbox from mathtools. – John Kormylo Feb 9 at 16:43

It seems you want an arrow with “n” underneath:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}

\newcommand{\rbel}{\xrightarrow[n]{}}

\begin{document}

$\theta_n>1, \quad \dfrac{1}{\theta_n^2} \rbel 0$

\end{document}


The error is because you're exiting from math mode when in \mbox.

I removed all the unnecessary package; please, take note that the option for A4 paper is called a4paper, not A4.

It works if the \mbox is replaced by ensuremath. Furthermore the code causes some warnings. A4 is no valid option for the article class and \small is ignored in math mode.

\documentclass[12pt]{article}
\usepackage{amsmath,amsfonts,amscd,amssymb,amsthm,amsbsy}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{abraces}
\usepackage{upgreek}
\usepackage{mathrsfs}
\usepackage{dsfont}
\usepackage[hang,small,labelfont=bf,up,textfont=it,up]{caption}
\usepackage{dsfont,float}
\usepackage{color}
\newcommand{\rbel}{
\ensuremath{\;\rightarrow_{\hspace*{-0.3cm}{n}}\;~}
}
\begin{document}
\begin{align}