将 \overline 与“斜体”字体对齐,但以 upshape 开头

将 \overline 与“斜体”字体对齐,但以 upshape 开头

我想写一个顶部有横线的 X。X 应该是直立的,但在标题中应该是斜体。横线应该在正确的位置。所以我的问题是将 \overline 对齐为“斜体”字体我开始玩jfbu 的解决方案但无法使原始的 upshape 位置发挥作用。

在此处输入图片描述

\documentclass{article}

\usepackage{xspace}

\newbox\usefulbox

\makeatletter
\def\getslant #1{\strip@pt\fontdimen1 #1}

\def\skoverline #1{\mathchoice
 {{\setbox\usefulbox=\hbox{$\m@th\displaystyle #1$}%
    \dimen@ \getslant\the\textfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \kern\dimen@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
 {{\setbox\usefulbox=\hbox{$\m@th\textstyle #1$}%
    \dimen@ \getslant\the\textfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \kern\dimen@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
 {{\setbox\usefulbox=\hbox{$\m@th\scriptstyle #1$}%
    \dimen@ \getslant\the\scriptfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \kern\dimen@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
 {{\setbox\usefulbox=\hbox{$\m@th\scriptscriptstyle #1$}%
    \dimen@ \getslant\the\scriptscriptfont\symletters \ht\usefulbox
    \divide\dimen@ \tw@ 
    \kern\dimen@ 
    \overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}%
 {}}
\makeatother


\newcommand{\xbar}{$\skoverline{X}$\xspace}
\newcommand{\xbarup}{\mbox{$\overline{\mbox{X}}$}\xspace}

\newcommand{\xbarupsk}{\mbox{$\skoverline{\mbox{X}}$}\xspace}


\begin{document}\thispagestyle{empty}

\xbar-Theory
\emph{\xbar-Theory} (correct)

\xbarup-Theory (correct)
\emph{\xbarup-Theory}

\xbarupsk-Theory
\emph{\xbarupsk-Theory}





\end{document}

相关内容