![如何写出狄拉克斜线导数的这个变体?](https://linux22.com/image/473549/%E5%A6%82%E4%BD%95%E5%86%99%E5%87%BA%E7%8B%84%E6%8B%89%E5%85%8B%E6%96%9C%E7%BA%BF%E5%AF%BC%E6%95%B0%E7%9A%84%E8%BF%99%E4%B8%AA%E5%8F%98%E4%BD%93%EF%BC%9F.png)
答案1
\documentclass{article}
\newcommand{\varDirac}{\mathord{\mathchoice
{\ooalign{\hfil\raisebox{.4ex}{/}\hfil\cr$\bar\mathcal{D}$\cr}}
{\ooalign{\hfil\raisebox{.4ex}{/}\hfil\cr$\bar\mathcal{D}$\cr}}
{\ooalign{\hfil\raisebox{.25ex}{$\scriptstyle/$}\hfil\cr$\scriptstyle\bar\mathcal{D}$\cr}}
{\ooalign{\hfil\raisebox{.2ex}{$\scriptscriptstyle/$}\hfil\cr$\scriptscriptstyle\bar\mathcal{D}$\cr}}
}}
\begin{document}
$\varDirac$
\end{document}
答案2
这适用于 Computer Modern 字体。其他字体可能需要根据\mathcal{D}
斜线的相对大小进行调整。
\documentclass{article}
\makeatletter
\NewDocumentCommand{\vardirac}{}{{\mathpalette\vardirac@\relax}}
\newcommand{\vardirac@}[2]{%
\begingroup
\sbox\z@{$\m@th#1\bar{\mathcal{D}}$}%
\sbox\tw@{\raisebox{\dimeval{(\depth-\height+\ht\z@)/2}}{$\m@th#1/$}}%
\vphantom{\usebox\tw@}%
\ooalign{%
\hidewidth\box\tw@\hidewidth\cr
\box\z@\cr
}%
\endgroup
}
\makeatother
\begin{document}
$\vardirac$ $\scriptstyle\vardirac$
%to show the bounding box
\fboxsep=0pt\fboxrule=0.1pt
\fbox{$\vardirac$}
\end{document}
答案3
\usepackage{slashed}
$\slashed{\bar D}$
$\slashed{\overline D}$
$\slashed{\mathcal D}$
因为同时拥有 bar 和 mathcal,诡计是需要的。
\usepackage{slashed}% provides \slashed
\usepackage{mathtools}% provides \mathllap
\newcommand\slashedbar[1]{\slashed{#1}\mathllap{\bar{#1}}}
\newcommand\slashedoverline[1]{\slashed{#1}\mathllap{\overline{#1}}}
$\slashedbar{\mathcal D}$
$\slashedoverline{\mathcal D}$
\documentclass{article}
% See also https://tex.stackexchange.com/q/226181
\usepackage{slashed}% provides \slashed
\usepackage{mathtools}% provides \mathllap
\newcommand\slashedbar[1]{\slashed{#1}\mathllap{\bar{#1}}}
\newcommand\slashedoverline[1]{\slashed{#1}\mathllap{\overline{#1}}}
\begin{document}
$\slashed{\bar D}$
$\slashed{\overline D}$
$\slashed{\mathcal D}$
\verb"\slashed" doesn't work well with \verb"\bar"/\verb"\overline" in conjunction with \verb"\mathcal", so we need the trick with \verb"\mathllap".
$\slashedbar{\mathcal D}$
$\slashedoverline{\mathcal D}$
\end{document}