答案1
Barbara Beeton 在评论中解释说,这种行为的目的是在多个分数彼此接近的排版情况下,通过设置分子和分母中文本的基线,使附近分数的各个基线对齐(即使它们可能包含各种不同类型的数学文本),从而给出好看的分数。这促使我创建了一个宏,试图击败 LaTeX 的自动垂直间距,以便由简单数字组成的分数(如 1/2)在横线上方和下方等距分布。仔细查看结果,它似乎使横线上方和下方的间距更接近相等,尽管仍然有一点差异;我不知道剩余的差异来自哪里,但你必须非常仔细地观察才能看到它[根据评论:可能是由于圆形“2”字形顶部的“超调”;可能无关紧要]
(经过编辑以提供改进版本)
\documentclass{article}
\usepackage{pgfmath, xparse}
\newlength{\MathStrutDepth}
\newlength{\MathStrutHeight}
\settoheight{\MathStrutHeight}{$\mathstrut$}
\settodepth{\MathStrutDepth}{$\mathstrut$}
\newlength{\NumeratorDepth}
\newlength{\DenominatorHeight}
\newlength{\DepthNegativeDifference}
\newlength{\HeightPositiveDifference}
\newlength{\NumeratorBaselineCorrection}
\newlength{\DenominatorBaselineCorrection}
\newlength{\AdditionalEVSFracVerticalSpacing}
\setlength{\AdditionalEVSFracVerticalSpacing}{0.05mm}
% Fraction with equal top-and-bottom vertical spacing around the bar.
% Suited only to simple fractions that do not appear near other fractions.
% When used alongside other fractions, numerator and denominator baselines
% might not be aligned, which might give ugly results.
\NewDocumentCommand\EVSFrac{omom}{%
\IfValueTF{#1}%
{\settodepth{\NumeratorDepth}{$#1$}}%
{\settodepth{\NumeratorDepth}{$#2$}}%
\IfValueTF{#3}%
{\settoheight{\DenominatorHeight}{$#3$}}%
{\settoheight{\DenominatorHeight}{$#4$}}%
\pgfmathsetlength%
{\DepthNegativeDifference}%
{\NumeratorDepth - \MathStrutDepth}%
\pgfmathsetlength%
{\HeightPositiveDifference}%
{\MathStrutHeight - \DenominatorHeight}%
\pgfmathsetlength%
{\NumeratorBaselineCorrection}%
{\AdditionalEVSFracVerticalSpacing + \DepthNegativeDifference + \HeightPositiveDifference}%
\pgfmathsetlength%
{\DenominatorBaselineCorrection}%
{-\AdditionalEVSFracVerticalSpacing}%
\def\Numerator{\raisebox{\NumeratorBaselineCorrection}{$#2$}}%
\def\Denominator{\raisebox{\DenominatorBaselineCorrection}{$#4$}}%
\frac{\Numerator}{\Denominator}%
}
\begin{document}
\[\EVSFrac{1}{2}\]
\end{document}