Math & Sciencesmashing upwards?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
wicko3
Posts: 4
Joined: Wed Jan 28, 2009 7:03 pm

smashing upwards?

Post by wicko3 »

Hi Guys,

I want to write some arrows that are labelled above and below. I'm using the \xrightarrow command, which when used like this:

Code: Select all

$x \xrightarrow[below]{above} y$
gives something like

Code: Select all

  above
x -----> y
  below
However, I want these to be set within a paragraph of text, not in equation mode, so i want to squash it vertically as much as I can. The best I've managed so far is to use an unwieldy combination of smashing and raising boxes, something like this:

Code: Select all

\newcommand{\progtran}[2][]{%
  \xrightarrow%
  [\smash{\raisebox{4pt}{$\scriptstyle{\mathbf{#1}}$}}]%
  {\smash{\raisebox{-2pt}{$\scriptstyle{#2}$}}}%
}
which yields results like this:
progtrans.tiff
progtrans.tiff (79.07 KiB) Viewed 3371 times
But I'm not very happy with it -- I'd really like the spacing between the lines to be just normal, not stretched at all. Is there some way that would smash the bit below the arrow upwards in some way, perhaps?

Cheers,

John

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Re: smashing upwards?

Post by Stefan Kottwitz »

Hi John,

perhaps use again \smash around \xrightarrow.

Stefan
LaTeX.org admin
wicko3
Posts: 4
Joined: Wed Jan 28, 2009 7:03 pm

Re: smashing upwards?

Post by wicko3 »

Bravo that man! Perfect solution. Thanks very much indeed!
Post Reply