![stackrel、垂直对齐和数学运算符](https://linux22.com/image/478472/stackrel%E3%80%81%E5%9E%82%E7%9B%B4%E5%AF%B9%E9%BD%90%E5%92%8C%E6%95%B0%E5%AD%A6%E8%BF%90%E7%AE%97%E7%AC%A6.png)
在以下 MnWE 中,宏\lhypbad
产生了良好的垂直对齐,但没有尊重数学运算符周围的空间<
。见下图。解决这个问题的最佳方法是什么?
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\newcommand\leqhyp{%
\stackrel{\text{hyp}}{\leq}%
}
\newcommand\lhyp{%
\stackrel{\text{hyp}}{<}%
}
\newcommand\lhypbad{%
\stackrel{\text{hyp}}{<\vphantom{\leq}}%
}
\begin{document}
$x \leqhyp 1 \lhyp y$
$x \leqhyp 1 \lhypbad y$
\end{document}
答案1
\leq
和的符号<
具有不同的高度。您可以使用 强制后者与前者的高度相同\vphantom
,但\mathrel
必须围绕该结构。{<}\vphantom{\leq}
还应使用 以避免产生虚假间距。
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\newcommand\leqhyp{%
\overset{\mathrm{hyp}}{\leq}%
}
\newcommand\lhyp{%
\mathrel{\overset{\mathrm{hyp}}{{<}\vphantom{\leq}}}%
}
\begin{document}
$x \leqhyp 1 \lhyp y$
\end{document}
一般来说,\overset
比 好\mathrel
。但在这种特殊情况下,\stackrel{\mathrm{hyp}}{{<}\vphantom{\leq}}
可以,因为\stackrel
总是会产生关系符号。
也\mathrm
应该优先于\text
这里,或者“hyp”这个词在定理中可以用斜体表示。