I want to write this:

I tried with $x_n \to_{n \to 0} 0$ but the $n \to 0$ doesn't go under the right arrow, it goes under but on the right, and I want it under but in the center, as in the picture above.
I want to write this:

I tried with $x_n \to_{n \to 0} 0$ but the $n \to 0$ doesn't go under the right arrow, it goes under but on the right, and I want it under but in the center, as in the picture above.
You can also use the function \xrightarrow:
$ x_n \xrightarrow[n \to 0]{} 0$

The user's guide of the amsmath package says :
\xleftarrowand\xrightarrowproduce arrows that extend automatically to accommodate unusually wide subscripts or superscripts. These commands take one optional argument (the subscript) and one mandatory argument (the superscript, possibly empty)"
\n<>arrow you have to add a complex re-definition because the final lenght is fixed.
– TheVal
Sep 16 '13 at 19:08
$x_n \xrightarrow[{\makebox[12pt][c]{$\scriptstyle n \to 0$}}]{} 0$.
– Gonzalo Medina
Sep 17 '13 at 02:15
You can use the function of \underset and \overset, in this case an arrow is simply defined with:
\underset{n\to 0}{\longrightarrow}
Which points the expression related to "n" under the second argument, here there are two versions depending on the size of the underset (using \scriptscriptstyle):
\documentclass{article}
%
\usepackage{amsmath}
%
\begin{document}
%
\[
X_n\underset{n\to 0}{\longrightarrow}0 \qquad%
X_n\underset{\scriptscriptstyle{n\to 0}}{\longrightarrow}0
\]
%
\end{document}
Which yields:
If you wanted to change the depth of the underset below the arrow (for example, to 1 pt), then this could be done:
\documentclass{article}
\usepackage{stackengine}
\stackMath
\begin{document}
\( X_n \mathrel{\stackunder[1pt]{\longrightarrow}{\scriptscriptstyle n \rightarrow 0}} 0 \)
\end{document}

Alternately, one could use something of Heiko's approach using \xrightarrow, but achieving a more snug fit like Fran's result, with the following:
\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\stackMath
\begin{document}
$ x_n \mathrel{\stackunder[-7.5pt]{\xrightarrow[%
\scriptscriptstyle\phantom{n \to 0}]{}}{\scriptscriptstyle n \to 0\,}} 0$
\end{document}

Finally, one could create the long arrow manually, and stack the underset below it:
\documentclass{article}
\usepackage{stackengine}
\stackMath
\begin{document}
\( X_n \mathrel{\stackunder[-1pt]{-\mkern-5mu-\mkern-10mu\longrightarrow}{%
\scriptscriptstyle n \rightarrow 0}} 0 \)
\end{document}

The one thing all three solutions have in common is they use stackengine to underset the subscript, which gives flexibility on the vertical location of the underset.
[Thanks to Qrrbrbirlbel for reminding me I forgot the \mathrel]
\longrightarrow is wrong, see the amsmath solutions.
– Qrrbrbirlbel
Sep 16 '13 at 18:28
$X_{n}\;_{\mathrel{\stackunder[-5.5pt]{\overrightarrow{\phantom{HHs}}}{_{n\to0}}}}\;0$ that is almost identical to $ x_n \xrightarrow[n \to 0]{} 0$
– Fran
Sep 17 '13 at 19:48
\xrightarrow formulation is just wasting extra keystrokes.
– Steven B. Segletes
Sep 17 '13 at 20:35
\stackunder to mimic \xrightarrow spacing (too much for my taste) was just to obtain the reference of -5.5pt, so anyone can imagine how close/far must be the setting of this value to fit their preferences.
– Fran
Sep 17 '13 at 22:37
Here's a plain version:
$$ X_n \mathrel{\mathop{\kern0pt\longrightarrow}\limits_{n\to0}} 0 $$ \bye
which could be shortened like \buildrel with \def\relop#1#2{\mathrel{\mathop{\kern0pt #1}\limits_{#2}}} to be X_n \relop\longrightarrow{n\to0} 0.


$X_{n\overrightarrow{_{\;\;n\to0\;\;\;}}}0$
This is not as elegant as \xrightarrow, but like this command (and unlike \undersetmethod) the long arrow could longer (required for some wider than n \to 0). The difference with \xrightarrow is that (a) do not need the amsmath package, (b) long arrow could be also as shorter as the text under it, (c) a smaller arrowhead (d) produce a more compact formula. Bug or feature, depending of what you want. But in case of be regarded as a bug, the horizontal spacing can be solved adding some more spaces. The vertical spacing cab be solved following the Steven's answer. In this MWE the second formula have exactly the same horizontal spacing that using \xarrow.
\documentclass{article}
\begin{document}
$X_{n\overrightarrow{_{\;\;n\to0\;\;\;}}}0$
$X_{n\;\,\overrightarrow{_{\;n\to0\;\;\,}}}\;0$
\end{document}