这是我正在处理的一段文字:
this is written as $\mathbf{p} \underset{s}{\sim}\mathbf{\bar{p}}$, and associated with the equivalence class $E(\underset{s}{\sim},\mathbf{p})=\{ \mathbf{\bar{p}}\in\Omega :\mathbf{p} \underset{s}{\sim} \mathbf{\bar{p}} \}$
这会产生一行如下所示的文本(与这个问题无关,这在某些文本中以斜体表示为定义):
我想让 \sim 下面的 s 更靠近它,这样它就不会在括号下面突出太多。
答案1
基于以下的简单解决方案\raisebox
:
\documentclass{article}
\newcommand{\myunderset}[2]{\underset{\raisebox{0.67ex}{$\smash{\scriptstyle #1 }$}}{#2}}
\usepackage{mathtools, amssymb}
\usepackage{accents}
\begin{document}
\noindent This is written as $\mathbf{p} \myunderset{s}{\sim}\mathbf{\bar{p}}$, and associated with the equivalence class $E(\myunderset{s}{\sim},\mathbf{p})=\{ \mathbf{\bar{p}}\in\Omega :\mathbf{p} \underset{s}{\sim} \mathbf{\bar{p}} \} $
\end{document}
答案2
通过一些较低级别的编程:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\undersim}[1]{\mathrel{\mathpalette\under@sim{#1}}}
\newcommand{\under@sim}[2]{%
\vtop{\offinterlineskip
\halign{\hfil##\hfil\cr$\m@th#1\sim$\cr$\m@th\demote@style{#1}#2$\cr}%
}%
}
\newcommand{\demote@style}[1]{%
\ifx#1\displaystyle\scriptstyle\else
\ifx#1\textstyle\scriptstyle\else
\scriptscriptstyle\fi\fi
}
\makeatother
\begin{document}
This is written as $\mathbf{p} \undersim{s} \bar{\mathbf{p}}$
and associated with the equivalence class
\[
E(\undersim{s},\mathbf{p})=\{ \bar{\mathbf{p}}\in\Omega :
\mathbf{p} \undersim{s} \bar{\mathbf{p}} \}
\]
$\sim\undersim{t}\undersim{A}X_{\undersim{s}}$
\end{document}
我把所有\mathbf{\bar{p}}
内容改为\bar{\mathbf{p}}
,从语义上来说这更正确。
\undersim
在最后一行我展示了不同的例子,包括下标正确缩放的事实。