# Aligning equality sign with overset text

I'm typing a logic definition within an align environment that uses \overset{def}{=} from the amsmath environment.

However, the new sign is aligned vertically based on the equality sign, and not on the entire sign. In other words, the word def is not considered in the alignment, which produces a result that I don't like.

How can I correctly vertically align the sign?

An MWE (the spacing around the sign is not an issue):

\documentclass{article}
\usepackage{amsmath}

\begin{document}
The definition of the satisfaction relation $M,s,g \models \phi$, which specifies that formula $\phi$ is true under valuation $g$ in state $s$ of model $M$, is given below.
\begin{align*}
M,s,g &\models x &\overset{def}{=} \qquad &s = g(x)\\
M,s,g &\models n &\overset{def}{=} \qquad &V(n) = {s}\\
M,s,g &\models p &\overset{def}{=} \qquad &s \ \epsilon \ V(p)\\
\end{align*}

\end{document}


Illustrative picture: The equality signs are aligned vertically as per the red line. However, the center of the new equality sign (\overset{def}{=}) is at the green line. The new sign should move down until the green line overlaps with the red line (approximately anyway). Then the vertical alignment would be correct.

• Added a picture to illustrate the problem. – Mythio May 17 '13 at 12:18
• I see no reason why the symbol should be moved down; on the other hand, I know that some supervisors have bizarre ideas about typography. – egreg May 17 '13 at 12:51

I would suggest that you put the def/equal sign in a column of its own: \documentclass{article}
\usepackage{amsmath}

\newcommand{\defeq}{\overset{\mathrm{def}}{=}}

\begin{document}
The definition of the satisfaction relation $$M,s,g \models \phi$$, which specifies that formula $$\phi$$ is true under valuation $$g$$ in state $$s$$ of model $$M$$, is given below.
\begin{align*}
M,s,g &\models x &\defeq&&s &= g(x)\\
M,s,g &\models n &\defeq&&s&= V(n)\\
M,s,g &\models p &\defeq&&s &\in V(p)\\
\end{align*}

\end{document}


• defined a command \defeq which typesets the def part in roman font.
• added alignment of right-hand column added at =, line 2 swapped to s=V(n) for symmetry
• $$...$$ used instead of $...$

If you really want the symbol to be vertically centered, then there is a standard TeX command \vcenter which centers material with respect to the axis of the formula (roughly the height of the center of x). The argument to \vcenter is material in vertical mode, so you need to box up the contents. The naive version of this is: \documentclass{article}
\usepackage{amsmath}

\newcommand{\defeq}{\vcenter{\hbox{$$\overset{\mathrm{def}}{=}$$}}}

\begin{document}

The definition of the satisfaction relation $$M,s,g \models \phi$$, which specifies that formula $$\phi$$ is true under valuation $$g$$ in state $$s$$ of model $$M$$, is given below.
\begin{align*}
M,s,g &\models x &\defeq&&s &= g(x)\\
M,s,g &\models n &\defeq&&s&= V(n)\\
M,s,g &\models p &\defeq&&s &\in V(p)\\
\end{align*}

\end{document}


You can add @daleif's smaller version of the font if you so wish, by putting \scriptscriptstyle before \mathrm.

A more sophisticated version of the command would be, as in How to capture the current math style?:

\usepackage{amsmath}
\usepackage{mathstyle}

\makeatletter
\newcommand{\defeq}{\vcenter{\hbox{$$\m@th\currentmathstyle \overset{\mathrm{def}}{=}$$}}}
\makeatother


which would resize in superscripts.

• Good pointers, but this still doesn't align the sign? – Mythio May 17 '13 at 12:12
• @Mythio I don't think the symbol should be moved vertically, it will look odd to a lot of people, besides I'd recommend changing Andrews macro a little \newcommand{\defeq}{\overset{\scriptscriptstyle\mathrm{def}}{=}} to make the def smaller. – daleif May 17 '13 at 12:27
• Thanks for the edit, I'll try some options and let my supervisor decide what to use. – Mythio May 17 '13 at 12:49