答案1
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand*{\foo}[1]{{\mathpalette\@foo{#1}}}
\newcommand*{\@foo}[2]{%
\dimen@=\fontdimen8
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi3\relax
\hbox{%
\vbox{%
\hrule\@height\dimen@
\kern2\dimen@
\hbox{\m@th$#1#2$\kern\dimen@}%
}%
\vrule\@width\dimen@
}%
}
\makeatother
\begin{document}
\[
\foo{n} \quad
a^{\foo{n}} \quad
{\scriptstyle\foo{n}} \quad
{\scriptscriptstyle\foo{n}}
\]
\end{document}
划痕长度\dimen@
设置为当前数学样式中的分数规则宽度。选择该值作为规则宽度和右侧的水平间距,而垂直间距是该值的两倍。请根据需要选择值。