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.

  • 2
    As an alternative to the TeX solutions below, you can define a shortcut/macro in your editor. – Caramdir Dec 27 '10 at 0:40

alt text

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

The \lras with a trailing space.
  • 11
    Given the "I am very new to TeX" statement in the question, I'd rephrase this with \newcommand rather than \def. – Andrew Stacey 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.

  • 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
  • 1
    @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 $...$.


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


  • 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
  • 1
    @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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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