# Custom symbol on top of a variable which automatically gets scaled?

I want a custom symbol on top of a variable. The problem is that the symbol size always keeps the same if the variable size is changed. In a more sophisticated formula with fractions etc. that looks horrible.

Here an example. To reduce the vertical space I have used code from How can i shrink (or expand) the vertical spacing in \stackrel?.

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{tikz}

\newcommand{\defeq}{%
\mathrel{\vbox{\offinterlineskip\ialign{%
\hfil##\hfil\cr
$\text{\tikz{\draw[-, line width=0.2ex] (1.6ex,0.5ex) -- (1.6ex,-0.5ex); \begin{scope}[xshift=0ex] \draw[-, line width=0.2ex] (0,0) -- (1.4ex,0); \fill[black] (1.5ex,0) -- (1ex,0.5ex) -- (1ex,-0.5ex) -- cycle; \end{scope} }}$\cr
\noalign{\kern-0.4ex}
}}}}

\begin{document}
$$B_{\overset{\defeq}{AB}} \overset{\defeq}{AB}$$
\end{document}


The boxing stops the size changing in a subscript, you could use \mathchoice to select different sizes, but here I think you can just remove the vbox and \ialign as you only had one row so it wasn't aligning anything.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\newcommand{\defeq}{%
\mathrel{\text{\tikz{\draw[-, line width=0.2ex] (1.6ex,0.5ex) -- (1.6ex,-0.5ex); \begin{scope}[xshift=0ex] \draw[-, line width=0.2ex] (0,0) -- (1.4ex,0); \fill[black] (1.5ex,0) -- (1ex,0.5ex) -- (1ex,-0.5ex) -- cycle; \end{scope}}}}}

\begin{document}
$$B_{\overset{\defeq}{AB}} \overset{\defeq}{AB}$$
\end{document}


Or closer:

\newcommand{\defeq}{%
\mathrel{\text{%
\raisebox{-.4ex}[0pt][0pt]{\tikz{\draw[-, line width=0.2ex] (1.6ex,0.5ex) -- (1.6ex,-0.5ex); \begin{scope}[xshift=0ex] \draw[-, line width=0.2ex] (0,0) -- (1.4ex,0); \fill[black] (1.5ex,0) -- (1ex,0.5ex) -- (1ex,-0.5ex) -- cycle; \end{scope}}}}}}

• The problem is that I also want to reduce the space between arrow and variable Apr 4 '13 at 22:21
• updated code to lower arrow Apr 4 '13 at 22:52
• Cool, this helps! Thx!!! Apr 4 '13 at 23:33