2

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}
\begin{equation}
  B_{\overset{\defeq}{AB}} \overset{\defeq}{AB}
\end{equation}
\end{document}

1 Answer 1

5

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.

enter image description here

\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}
\begin{equation}
  B_{\overset{\defeq}{AB}} \overset{\defeq}{AB}
\end{equation}
\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}}}}}}
3
  • The problem is that I also want to reduce the space between arrow and variable
    – user4811
    Apr 4, 2013 at 22:21
  • updated code to lower arrow Apr 4, 2013 at 22:52
  • Cool, this helps! Thx!!!
    – user4811
    Apr 4, 2013 at 23:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .