[Tex/LaTex] How to i shrink (or expand) the vertical spacing in \stackrel

math-modespacingstacking-symbols

I've seen the following command used a lot to make the triangle-equals operator that means "is defined as":

\newcommand{\defeq}{\stackrel{\triangle}{=}}

However, I don't like how far apart the triangle and the equals sign are, so I'd like to reduce the space between them. I tried using a raisebox, but it does not seem to be having any effect:

\newcommand{\defeq}{\stackrel{\raisebox{-10pt}{\(\scriptstyle\triangle\)}}{=}}

It also has no effect if I put different values in for the extend-above and extend-below arguments

Does anyone know how to manually adjust the vertical space in \stackrel, or why the above does not work?

Best Answer

\stackrel exploits the same TeX's internal mechanism used for setting limits over \sum:

\newcommand{\stackrel}[2]{\mathrel{\mathop{#2}\limits^{#1}}

Therefore lowering the "superscript" won't have any effect (raising would). In any case it's better to use \overset from amsmath. And, in this particular case, to use the predefined symbol.

How to solve your problem in other situations, without measuring?

Alignments are what we need: but array would leave too much space and we'd need measuring again. Here's a way out; I'll use the "triangle over equals" just by way of example: always use an already available symbol.

\newcommand{\defeq}{%
  \mathrel{\vbox{\offinterlineskip\ialign{%
    \hfil##\hfil\cr
    $\scriptscriptstyle\triangle$\cr
    %\noalign{\kern0ex}
    $=$\cr
}}}}

I've left a (commented) line where one could adjust the separation between the two parts; it's better to specify ex rather than pt units, so that the symbol can be used in various font sizes.

  1. We say that the symbol is a relation.

  2. We enclose the building into a \vbox, so that the baseline of the bottom element will be used for the whole thing.

  3. In the \vbox we suppress the usual interline skip mechanism (\offinterlineskip).

  4. We start an alignment; \ialign is just a way to use \halign with \tabskip set to zero.

  5. The alignment consists of one column, with centered items (\hfil#\hfil\cr, the # needs to be doubled because we're in a definition).

  6. The two rows, possibly adjusting the separation with a positive or negative kern.

Here are some examples

enter image description here