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.

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?

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

\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

share|improve this answer
    
I've noticed (and taken the liberty of fixing) a minor type (missing final }) in your code. However, the resulting triangle above the equal sign is quite a bit larger than in the image you include. Is something missing? –  Mico Apr 6 '12 at 10:57
    
@Mico Thanks for the editing. I can see a clear difference between the first and second line from the final three. Try $\stackrel{\triangle}{=}\defeq to see it. –  egreg Apr 6 '12 at 11:00
    
Sorry for not being clear. The triangle generated by \defeq is indeed smaller than the one generated by \stackrel{\triangle}{=}. Nevertheless, it is also quite a bit larger than the one generated by \triangleq. In contrast, the image you posted seems to indicate that the triangles generated by the \defeq and triangleq commands should be of roughly the same size. I'm juxtaposing the three symbols by running $\stackrel{\triangle}{=} \defeq \triangleq$. –  Mico Apr 6 '12 at 12:19
    
@Mico I took this just as an example: one should clearly prefer the premade symbol; if a premade symbol is not available, then it can be built with this technique. I've spelled it out in the answer. –  egreg Apr 6 '12 at 12:23
    
@egreg Thanks for the comprehensive answer. A friend in my lab found the predefined symbol, but it didn't look good because the triangle was really small. I assumed that was why I had seen people define it themselves so much (that definition is actually in my department's thesis template). But, it turns out my friend was using the txfonts package, which is why it looked bad. Now you've gotten me curious to learn about how \ialign and \ooalign work. –  Brandon Apr 6 '12 at 15:59
show 1 more comment

You could simply use \triangleq from the amssymb package:

\documentclass{article}
\usepackage{amssymb}

\begin{document}

\[  a\triangleq b  \]

\end{document}

enter image description here

The MnSymbol package offers \triangleeq.

If you want to define your own symbol, then (assuming that you need a fixed sized symbol) you can do something like this:

\def\defeq{\mathrel{\ooalign{%
  \raisebox{1.3\height}{$\scriptscriptstyle\triangle$}\cr\hidewidth$=$\hidewidth\cr}}}

Here's a comparison between this symbol and the one offered by amssymb:

\documentclass{article}
\usepackage{amssymb}

\def\defeq{\mathrel{\ooalign{%
  \raisebox{1.3\height}{$\scriptscriptstyle\triangle$}\cr\hidewidth$=$\hidewidth\cr}}}

\begin{document}

\[ a \defeq b \quad a\triangleq b\]

\end{document}

enter image description here

Palaying with the length in the first argument of \raisebox you can now control the vertical space between the two symbols.

share|improve this answer
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.