答案1
您可以使用\mathpalette
普通的 TeX 宏:
\def\abcd#1#2{\left[\mathpalette\abcdA{#1}\mkern-6mu{\setminus}#2\right]}
\def\abcdA#1#2{\lower.4em\hbox{$#1#2$}}
此外,\setminus
使用 重新输入为 Ord {\setminus}
,因此您无需用负字距补偿其后的空格。并且第一个负字距以单位表示,mu
以便也适用于脚本大小。
答案2
您无需猜测降低的量。必须使用\mathpalette
才能使用正确的字体大小。请参阅\mathpalette 的奥秘
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\abcd}[2]{\left[\mathpalette\abcd@{#1}\backslash#2\right]}
\newcommand{\abcd@}[2]{%
% #1 = math style
% #2 = text to be lowered
\raisebox{%
% we make it so that the top of the
% lowered part is at the formula axis
\dimexpr-\height+\abcd@fontdimen{#1}%
}{%
% we don't want that \scriptspace kicks in
\scriptspace=\z@
% the part to be lowered
$\m@th#1#2$%
}%
}
\newcommand{\abcd@fontdimen}[1]{%
% the height of the formula axis is \fontdimen22 <math font of family 2>
\fontdimen22
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi 2
}
\makeatother
\begin{document}
\[
\abcd{X_1}{X_2}\qquad\bigoplus_{\abcd{X_1}{X_2}}
\]
\[
\abcd{X}{Y}\qquad\bigoplus_{\abcd{X}{Y}}
\]
\end{document}