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.

Is there a similar command to \overbrace{foo}^{bar} but instead of braces, an arrow pointing up/down?

EDIT: Here's a little demonstration of how I'd expect something like this to work:

alt text

And possible syntax would be \overarrow{a=b}^{\text{theorem X}}

share|improve this question
1  
How would you place the arrow? The point of the overbrace is that its width adapts to the formula, while a vertical arrow is rather thin in the horizontal direction. Not much you can do about that. –  Harald Hanche-Olsen Jan 11 '11 at 15:10
    
@Harald: see my edit. –  daniel.jackson Jan 11 '11 at 15:18
    
Do you really want the arrow centered over "a=b"? That would become very strange if you do it over "i=m" since those letters definitely have different widths. Maybe it's better to put it just over the "=". –  Hendrik Vogt Jan 11 '11 at 15:26
    
@Hendrik: yes, what you said makes more sense. –  daniel.jackson Jan 11 '11 at 15:34
add comment

2 Answers 2

up vote 4 down vote accepted

Here is a generalized approach, providing \overarrow[<relation>][<arrow>]{<stuff>}. By default <relation> is = and <arrow> is \uparrow (both arguments are optional). A complement to this is provided by \underarrow[<relation>][<arrow>]{<stuff>} for typesetting underneath <operator> (<arrow> has the default <downarrow> in \underarrow).

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{xparse}% http://ctan.org/pkg/xparse

\NewDocumentCommand{\overarrow}{O{=} O{\uparrow} m}{%
  \overset{\makebox[0pt]{\begin{tabular}{@{}c@{}}#3\\[0pt]\ensuremath{#2}\end{tabular}}}{#1}
}
\NewDocumentCommand{\underarrow}{O{=} O{\downarrow} m}{%
  \underset{\makebox[0pt]{\begin{tabular}{@{}c@{}}\ensuremath{#2}\\[0pt]#3\end{tabular}}}{#1}
}

\begin{document}
\begin{align*}
  \alpha &\overarrow{Theorem X}\beta & \alpha &\underarrow{Theorem X}\beta  \\
  \alpha &\overarrow[\approx]{Theorem Y}\beta & \alpha &\underarrow[\approx]{Theorem Y}\beta \\
  \alpha &\overarrow[>][\downarrow]{Theorem Z}\beta & \alpha &\underarrow[>][\uparrow]{Theorem Z}\beta
\end{align*}

\end{document}

One difference between this typesetting and that proposed by @Herbert is that \stackrel modifies the size of the upper component. Since \overarrow and \underarrow in this answer uses tabular to stack the items, no size adjustment is visible.

xparse provides the interface for mixing optional/mandatory arguments.

share|improve this answer
add comment
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\def\overUnderArrow{\@ifnextchar[\overUnderArrow@i{\overUnderArrow@i[]}}
\def\overUnderArrow@i[#1]#2#3{% #1 under #2 over #3 main argument
  \ifx\relax#1\relax\array[b]{c}\overset{\text{#2}}{\uparrow}\\#3\endarray
  \else\ifx\relax#2\relax
    \array[t]{c}#3\\\underset{\text{#1}}{\downarrow}\endarray
  \else
    \array{c}\overset{\text{#2}}{\uparrow}\\#3\\\underset{\text{#1}}{\downarrow}\endarray
  \fi\fi}
\makeatother
\begin{document}
\[
  \overUnderArrow[TheoremX]{TheoremX}{\alpha = \beta}
  \overUnderArrow{TheoremX}{\alpha = \beta}
  \overUnderArrow[TheoremX]{}{\alpha = \beta}
\]

\end{document}

enter image description here

The syntax is \overUnderArrow[below]{above}{main entry}. It is also possible to extend the definition for variable arrows direction.

share|improve this answer
    
is it possible to modify this to a down arrow and position everything beneath? also how can I add some padding around the arrow? it's too close sometimes i.imgur.com/N1MHu.png –  daniel.jackson Dec 9 '11 at 19:23
    
how should I know what and how you extracted something from my solution ... –  Herbert Dec 9 '11 at 19:25
    
I'm talking about your solution as it is shown here.. is it possible to alter it to do what I asked? –  daniel.jackson Dec 9 '11 at 20:31
    
I added a command for a down arrow, see answer –  Herbert Dec 9 '11 at 20:54
add comment

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.