Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
3  
What do you mean by «Doesn't work»? I do get the arrow. EDIT: Ah, you edited. renewcommand is used to change the definition of a command, as the log says Error: \longto undefined., you only need to substitute \renewcommand with \newcommand. –  Manuel Jan 23 at 14:41
3  
\longto is not defined, so you have to \newcommand{\longto}{\longrightarrow} –  karlkoeller Jan 23 at 14:43
1  
@karlkoeller You should post your comment as an answer –  azetina Jan 23 at 14:44
2  
2  
\let\longto\longrightarrow –  Herbert Jan 23 at 14:50

2 Answers 2

up vote 11 down vote accepted

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?

share|improve this answer

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
share|improve this answer
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 at 15:36
    
sure, but a \@ifdefinable is overkill in this special case! –  Herbert Jan 23 at 15:49
1  
That's what \newcommand is for; why looking for complications? –  egreg Jan 23 at 15:50
    
It looks like that you never wrote a package ... –  Herbert Jan 23 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 at 16:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.