TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using $\longrightarrow{}$ at many places in my document. I should say around two to three times per page. I was wondering if there is a way to assign a shortcut (i.e. lra) and wherever I use lra it will put $\longrightarrow{}$.

So far I am getting by with Ctrl+C & Ctrl+V.

share|improve this question
As an alternative to the TeX solutions below, you can define a shortcut/macro in your editor. – Caramdir Dec 27 '10 at 0:40
up vote 7 down vote accepted

alt text

\def\lras{\ensuremath\longrightarrow\ }
The \lra without a trailing space.

The \lras with a trailing space.
share|improve this answer
Given the "I am very new to TeX" statement in the question, I'd rephrase this with \newcommand rather than \def. – Loop Space Dec 27 '10 at 19:48

Expanding on Frabjous's answer, I would do this:




This gives you a \lra command that is sensitive to the trailing space without defining two macros for it.

share|improve this answer
As such it works great. How to use this for shortcut $\xrightarrow[\text{Unicode text 1}]{\text{Unicode text 2}}$ – Aku Dec 28 '10 at 19:30
@Mark: What is the package xspace most commonly useful for? – night owl Jul 18 '11 at 17:49
@nightowl: The package xspace provides the command \xspace, which does or does not add a space depending on whether there's a punctuation sign right after it. Foo\xspace . will expand to Foo., Foo\xspace Bar will expand to Foo Bar. This comes in handy for new macros which will behave correctly no matter what follows. Here's an interesting question on xspace's behavior toward different punctuation signs: tex.stackexchange.com/questions/15252/… – doncherry Aug 20 '11 at 16:54

I'd do it like this:


Thanks to ensuremath, this will work both inside and outside of math mode -- with no need for $...$.

share|improve this answer

You can use let which allows you to copy the content of a command into a new command.


share|improve this answer
What is the benefit of using \let in this case versus \def? – Carl Morris Sep 25 '12 at 16:35
@CarlMorris It is slightly more efficient as it assigns a pointer to the existing definition. – Yiannis Lazarides Sep 25 '12 at 18:48
@YiannisLazarides, this doesn't work with environments, right?, e.g. \let\v\verbatim – PatrickT Feb 28 '14 at 7:26
@PatrickT Yes it will not work with environements or with LaTeX commands that take arguments etc.. – Yiannis Lazarides Feb 28 '14 at 13:47

Your Answer


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.