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.

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 want to place text over arrows. The obvious choice is to use the amsmath command \xrightarrow{#1} However, sometimes the text above may be a single digit:

%Example 1

other times the text is slightly longer:

%Example 2

The problem I have is that the length of the arrow is scaled to the length of the text. So the arrow in example 1 is much shorter than the arrow in example 2.

Is there a way of making the arrows the same length? Should I use a different command altogether?

share|improve this question
up vote 17 down vote accepted

In such cases, the command \makebox comes handy. It puts the argument text into a box of customizable width. Even more useful in math mode is \mathmakebox provided by the mathtools package, because it's working better in math mode and respects the current math style.

So, we could start with \xrightarrow{\mathmakebox[3em]{1}}. But we can do better - let's write a macro for that, which produces an arrow of the same width like a text we specify. Here's such a complete example:



alt text

share|improve this answer

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.