忽略下标放置的重叠宽度

忽略下标放置的重叠宽度

我有一个关系符号,其上方和下标都有参数。我希望每种参数的放置都独立于其他参数,特别是:

  • 当重叠部分大于关系符号时,下标不应向右移动;
  • 下标的长度不应对覆盖的水平位置产生影响。

以下是我的尝试:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{mathtools}
\usepackage{stix2}

\stackMath
\newcommand{\mystackon}[2]{\ThisStyle{\stackon[0.1ex]{\SavedStyle#1}{\SavedStyle#2}}}%

\newcommand{\oversetred}[2]{\mathrel{\vphantom{#1}}\mathrel{\mystackon{\mathord{#1}}{#2}}\mathrel{\vphantom{#1}}}% This ensures that the height of superscripts is unaffected by the overset. See https://tex.stackexchange.com/questions/643265/placing-symbol-over-relation-without-changing-where-superscripts-are-placed

% One of my use cases. Exact values are unimportant, only that \myover is wider than \mysymb, and that the solution should allow for other values
\newcommand{\mysymb}{\sqsubseteq}
\newcommand{\myover}{{\scriptscriptstyle \mathbfscr{K},\mathbfscr{P}}}
\newcommand{\mysub}{\rightsquigarrow}

\begin{document}
Attempts:\\\\
$A\oversetred{\mysymb}{\myover}_\mysub B$ : the $\mysub$ is too far from the $\mysymb$\\\\
$A\oversetred{\mysymb}{\mathclap{\myover}}_\mysub B$ : not enough space between $A$ and $\oversetred{\mysymb}{\myover}_\mysub$; the $\myover$ nearly goes over $A$\\\\
$A\oversetred{\mysymb_\mysub}{\myover} B$ : the $\myover$ is not centered properly\\\\
\end{document}

在此处输入图片描述

答案1

我建议创建以下宏\mystack

\def\mystack#1\over#2_#3{%
   \mathrel {%
      \setbox0=\hbox{$\scriptscriptstyle #1$}%
      \setbox1=\hbox{$#2$}%
      \ifdim\wd1>\wd0 \kern .5\wd1 \else \kern .5\wd0 \fi
      \vbox{
         \offinterlineskip
         \moveleft.5\wd0 \box0
         \kern.3ex
         \moveleft.5\wd1 \hbox{$#2_#3$}
}}}

% Usage:
$ A \mystack KPR \over \sqsubseteq_\rightsquigarrow B $

宏测量关系的上标(在 中\box0)和单独的关系(在 中\box1)。然后它在 之前附加正确的字距\vbox\vbox使用适当的\moveleft\box0\moveleft关系,包括其下标。

相关内容