1

My tex code is shown below.

\documentclass[10pt]{article}
\usepackage{amsmath}
\newcommand{\defeq}{\overset{\text{\tiny def}}{=}}
\begin{document}
$P\defeq A$
\end{document}

enter image description here

I intend to move the \defeq sign in red rectangle into the green one. Or, in other words, i want the \defeq sign being center aligned in LaTeX character box. Can you tell me how to do this?

  • Can't you find your happiness at tex.stackexchange.com/q/35404/34551 or tex.stackexchange.com/q/114758/34551 ? Have you tried for instance \newcommand{\defeq}{\vcenter{\hbox{\( \overset{\mathrm{def}}{=} \)}}}? – Clément Feb 8 '17 at 5:55
  • @Clément - None of the answers to the two posting you provided links to appear to address the OP's objective to shift the entire def-eq block down by a certain amount. Using \vcenter will place the def-eq block a bit too low for the OP's taste. – Mico Feb 8 '17 at 6:07
2

You can use some low level commands:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\defeq}{\mathrel{\aban@defeq}}
\newcommand{\aban@defeq}{%
  \vbox{\offinterlineskip\check@mathfonts
    \ialign{\hfil##\hfil\cr
      \fontsize{\ssf@size}{\z@}\normalfont def\cr
      \noalign{\kern1\p@}
      $\m@th=$\cr
      \noalign{\kern-.5\fontdimen22\textfont2}
    }%
  }%
}
\makeatother

\begin{document}

\[
A=B\defeq P
\]

\end{document}

The spacing between “def” and “=” is set to one point, adapt it to your liking. The “=” is lowered by half the height of the math axis, which is available as \fontdimen22\textfont2.

enter image description here

Personally, I don't like such a symbol. If I were forced to use something like “it is defined to be”, I'd probably choose \coloneq, which is asymmetric. But I've never felt the mathematical need for such a symbol.

2

Here's a solution that employs the LaTeX command \raisebox.

enter image description here

\documentclass[10pt]{article}
\usepackage{amsmath}
\newcommand{\defeq}{\overset{\text{\tiny def}}{=}}
\newcommand{\ldefeq}{\mathrel{\raisebox{-0.3ex}{$\defeq$}}}
\begin{document}
$P\defeq A$, $P\ldefeq A$
\end{document}
  • The argument of \lower -- 0.3ex in the code shown above -- may need to be adjusted slightly depending on the math font that's used by your document. 0.3ex seems about right for Computer Modern (the math font shown in your screenshot) and Latin Modern; for the newtxmath, newpxmath, and euler math fonts, 0.29ex is about right; for the mtpro2 font package, 0.28ex seems like the way to go. – Mico Feb 8 '17 at 6:26
  • Thanks. i wonder if there is a way to replace 0.3ex with a command? – aban Feb 8 '17 at 6:54
  • \raisebox has been in LaTeX from day one. – egreg Feb 8 '17 at 9:40
  • @egreg - Thanks for this. For some reason, I had been under the mistaken impression that \raisebox was part of the graphicx package. I will update the code to use the "native" LaTeX command. – Mico Feb 8 '17 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.