define new command: \renewcommand{\longto}{\longrightarrow}

I define this new command:

\documentclass[8pt,a4paper]{article}
\newcounter{conto}
\setcounter{conto}{\time}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{ dsfont }
\usepackage[mathscr]{euscript}
\renewcommand{\longto}{\longrightarrow}
\usepackage[a4paper,top=1cm,bottom=2cm,left=3cm,right=3cm]{geometry}
\begin{document}
\begin{flushleft}
$$a \longto +\infty$$
\end{flushleft}
\end{document}

but the command \renewcommand{\longto}{\longrightarrow} doesn't work!!

• \longto is not defined, so you have to \newcommand{\longto}{\longrightarrow} – karlkoeller Jan 23 '14 at 14:43
• @karlkoeller You should post your comment as an answer – azetina Jan 23 '14 at 14:44
• \let\longto\longrightarrow – user2478 Jan 23 '14 at 14:50

The command \longto is not defined, so you can not "renew" its meaning through \renewcommand, which can only be used to redefine existing commands.

To define a new command, as in your case, you have to use \newcommand, specifically:

\newcommand{\longto}{\longrightarrow}


If you want to be on the save side then use:

\providecommand\longto{}% does nothing, if already defined
\renewcommand\longto{\longrightarrow}% works now

or if you want the short way:

\let\longto\longrightarrow
• I can't recommend this. A package might define \longto and use it in some of its constructions; the macro would be redefined without any warning. – egreg Jan 23 '14 at 15:36
• sure, but a \@ifdefinable is overkill in this special case! – user2478 Jan 23 '14 at 15:49
• That's what \newcommand is for; why looking for complications? – egreg Jan 23 '14 at 15:50
• It looks like that you never wrote a package ... – user2478 Jan 23 '14 at 15:51
• This is for a document level definition, not for a package. The user level command for this is \newcommand that will inform the user in case the macro already has a definition; in this case suitable action can be taken. Try imagining what would happen if somebody follows your advice with \box instead of \longto. Your answer should start with “If you want to be on the unsafe side…”. – egreg Jan 23 '14 at 16:03