4

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!!

azetina
  • 28,884
mle
  • 1,687
  • 3
  • 14
  • 21

2 Answers2

12

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}

See this post for more info: What do newcommand, renewcommand, and providecommand do, and how do they differ?

karlkoeller
  • 124,410
5

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
  • 1
    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! –  Jan 23 '14 at 15:49
  • 1
    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 ... –  Jan 23 '14 at 15:51
  • 3
    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
  • That is your point of view! And there is another one: I want definitively define my command called \box. Then I'll go my way. –  Jan 23 '14 at 20:57