答案1
对于您的类似问题,我的解决方案只需进行微小改动:
\input stmary
\catcode`@=11
\def\segment#1{%
\mathord{\vbox{\offinterlineskip\m@th
\ialign{##\cr
$\m@th\scriptscriptstyle{\mapstochar\relbar}
\leaderbar
{\relbar\mkern-1mu\mapsfromchar}$\cr
$\m@th#1$\cr
}%
}}%
}
\def\leaderbar{%
\mkern-7mu
\cleaders\hbox{$\scriptscriptstyle\mkern-2mu{\relbar}\mkern-2mu$}\hfill
\mkern-7mu
}
\catcode`@=12
$\segment{AB}$
\bye