# What does “rel” in \mathrel and \stackrel stands for?

Most latex tags have straightforward meanings, for instance,

\sqrt stands for/comes from "square root"

\equiv stands for/comes from "equivalent to"

What does "rel" in \mathrel and \stackrel stands for?

• Probably "relation". – Jan Aug 25 at 8:32
• Welcome to TeX.SE. – Mico Aug 25 at 8:37

The meaning of rel in mathrel quickly becomes fairly obvious if one considers the entire list of 13 types of math atoms; see also p. 158 of the TeXbook:

mathord, 'ord' for short -- something like 'x' and 'y'
mathop, 'op' for short -- large operators, e.g., \sum and \prod
bin   -- binary operation atoms, e.g., '+' and '-'
rel   -- relation operation atoms, e.g, '=', '<', and '>'
open  -- opening atom, e.g,, '(' and '['
close -- closing atom, e.g., ')' and ']'
punct -- punctuation atom, e.g., ','
inner -- (leading ex.: anything between '\left' and '\right')
over  -- overline atom, as in '\overline{x}'
under -- underline atome, as in '\underline{x}'
acc   -- accent atoms, as in '\hat{x}' and '\tilde{x}'
vcent -- (argument of \vcenter directives)


One area where the status of the math atoms matters is in the spacing around binary and relational operators. E.g., if you examine at the typeset output of a+b and a=b, you'll notice that the spacing around the + and = symbols is not the same; the space around the latter symbol is slightly greater. This difference embodies typographic rules developed over decades (centuries?) of fine math typesetting.

The \mathrel directive, which is a "TeX primitive" command, serves to change the math status of its argument to, you guessed it, mathrel. For example, writing \mathrel{+} or \mathrel+ changes the math status of + from bin (which is the default in most (all??) TeX systems) to rel. Aside: This is just an example; I am not suggesting that anyone would actually want to run this instruction. A more realistic example: Suppose that you want to denote the open interval from -a to b with ]-a,b[. Writing the open interval directly in this way would, however, cause incorrect spacing between ] (remember that its default math status is close) and the - symbol. To get the correct spacing between ] and the unary - symbol, you could write \mathopen{]}-a,b\mathclose{[}, overriding the default math status values of [ and ]. Better still, load the mathtools package and use its \DeclarePairedDelimiter macro to define a macro called, say, \openint with variable-sized delimiters.

Then there is \stackrel: It's a LaTeX macro that allows placing superscript terms above some object (often, butn not necessarily, an = symbol), making the math status of the combined object mathrel; e.g,, \stackrel{!}{=} places | above =, and the status of the combined object is mathrel. There is also a package called stackrel, which extends the functionality of \stackrel in two ways. First, it allows placing subscript terms below a main object, while setting the status of the combined object to mathrel. E.g., B \stackrel[x]{!}{=} C places x below and ! above the = symbol, and the math status of the combined object is set to mathrel. Second, it provides an additional macro called \stackbin, which allows placing subscript and superscript terms alongside a main object and setting the math status of the combined object to mathbin.

• The explanation of \stackrel and \stackbin is incorrect. They actually make rel or bin atoms out of their arguments, which can be anything. – egreg Aug 25 at 12:34
• @egreg - Good catch! (I guess I was assuming implicitly that the "main" argument of \stackrel and \stackbin would naturally have default math status of rel and bin, resp. However, as you point out, that assumption is invalid.) Better now? – Mico Aug 25 at 12:50
• Note that \mathrel is not a “macro” but a TeX primitive command (see the definition of ⟨math atom⟩ on p. 291 of The TeXbook). Note also that it is not necessary to sat \mathrel{+}, you can also say \mathrel+, and (contrary to what happens with macros) the two idioms have a subtly different meaning: in the latter case, the nucleus of the atom is the the symbol “+”, while in the former is a subsidary math list. This subtle difference is usually inconsequential, but becomes significant in some cases. – GuM Aug 25 at 20:51
• @GuM - Thanks for this! I must confess to not being too exact, at times, with the difference between a "TeX primitive" command and a "macro". Hence, thanks for setting the record straight, so to say. I will correct the body of the answer, as neededThanks also for mentioning that both \mathrel+ and \mathrel{+} are syntactically legal, with there being subtle (but at times significant) differences. – Mico Aug 25 at 21:15
• You are welcome! Meanwhile, I have (upvoted and) found a meaningful example: compare $\mathrel\sum$ with $\mathrel{\sum}$ (\showlists inside math mode will be illuminating). Edit: In display math mode, the difference is even more striking: $\mathrel\sum \neq \mathrel{\sum}$. – GuM Aug 25 at 22:31