我想要在變數之上有一個自訂符號。問題是,如果變數大小發生更改,符號大小始終保持不變。在帶有分數等的更複雜的公式中,看起來很糟糕。
這裡有一個例子。為了減少垂直空間,我使用了程式碼如何縮小(或擴大) \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
裝箱會停止下標中的大小變化,您可以用來\mathchoice
選擇不同的大小,但在這裡我認為您可以刪除 vbox,\ialign
因為您只有一行,所以它沒有對齊任何內容。
\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}
或更接近:
\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}}}}}}