增加分子和分母之间的间距

增加分子和分母之间的间距

我创建了两个分数(见下面的示例),但分母离除法线太近了。我能以某种方式改变这种情况吗?

\documentclass{article}
\usepackage{amsmath}

\begin{document}
    Combining two Gaussians with mean $\mu_1, \mu_2$ and variance $\sigma_1^2, \sigma_2^2$ yields a new Gaussian with mean $\mu = \frac{\sigma_2^2 \mu_1 + \sigma_1^2 \mu_2}{\sigma_1^2 + \sigma_2^2}$ and variance $\sigma^2 = \frac{1}{\frac{1}{\sigma_1^2} + \frac{1}{\sigma_2^2}}$
\end{document}

答案1

您有两个主要选择:

  • 从 -notation 切换\frac{...}{...}到内联分数表示法

  • 切换到显示数学来排版\mu和的公式\sigma^2

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath} % for "\text" macro
\begin{document}

\noindent
1. OP's original version:

Combining two Gaussians with mean $\mu_1, \mu_2$ and variance $\sigma_1^2, \sigma_2^2$ yields a new Gaussian with mean $\mu = \frac{\sigma_2^2 \mu_1 + \sigma_1^2 \mu_2}{\sigma_1^2 + \sigma_2^2}$ and variance $\sigma^2 = \frac{1}{\frac{1}{\sigma_1^2} + \frac{1}{\sigma_2^2}}$.

\medskip\noindent
2. Partial switch to inline-math notation

Combining two Gaussians with mean $\mu_1, \mu_2$ and variance 
$\sigma_1^2, \sigma_2^2$ yields a new Gaussian with mean 
$\mu = \frac{\sigma_2^2 \mu_1 + \sigma_1^2 \mu_2}{\sigma_1^2 + \sigma_2^2}$ 
and variance $\sigma^2 = \frac{1}{1/\sigma_1^2 + 1/\sigma_2^2}$.

\medskip\noindent
3. Full switch to inline math notation

Combining two Gaussians with means $\mu_1$ and $\mu_2$ and 
variances $\sigma_1^2$ and $\sigma_2^2$ yields a new Gaussian 
with mean $\mu = (\sigma_2^2 \mu_1 + \sigma_1^2 \mu_2)/(\sigma_1^2 + 
\sigma_2^2)$ and variance $\sigma^2 = 1/(1/\sigma_1^2 + 1/\sigma_2^2)$.

\medskip\noindent
4. Switch to display math

Combining two Gaussians with means $\mu_1$ and $\mu_2$ and 
variances $\sigma_1^2$ and $\sigma_2^2$ yields a new Gaussian 
with mean $\mu$ and variance $\sigma^2$ given by
\[
\mu=\frac{\sigma_2^2 \mu_1 + \sigma_1^2 \mu_2}{\sigma_1^2 + \sigma_2^2} 
\quad\text{and}\quad 
\sigma^2 = \frac{1}{1/\sigma_1^2 + 1/\sigma_2^2}\,.
\]

\end{document} 

答案2

在这里,我保留了分数的原始值\textstyle,但在每个分数的分子和分母的上方和下方添加了一个(默认)1pt 缓冲区,可以使用可选参数进行更改。我称之为\qfrac[]{}{}。MWE 显示前后值。

\documentclass{article}
\usepackage{stackengine,scalerel}
\stackMath
\newcommand\qfrac[3][1pt]{\frac{%
  \ThisStyle{\addstackgap[#1]{\SavedStyle#2}}}{%
  \ThisStyle{\addstackgap[#1]{\SavedStyle#3}}%
}}
\usepackage{amsmath}

\begin{document}
    Combining two Gaussians with mean $\mu_1, \mu_2$ and variance $\sigma_1^2, 
  \sigma_2^2$ yields a new Gaussian with mean $\mu = \frac{\sigma_2^2 \mu_1 + 
  \sigma_1^2 \mu_2}{\sigma_1^2 + \sigma_2^2}$ and variance $\sigma^2 = 
  \frac{1}{\frac{1}{\sigma_1^2} + \frac{1}{\sigma_2^2}}$

   Combining two Gaussians with mean $\mu_1, \mu_2$ and variance $\sigma_1^2, 
  \sigma_2^2$ yields a new Gaussian with mean $\mu = \qfrac{\sigma_2^2 \mu_1 + 
  \sigma_1^2 \mu_2}{\sigma_1^2 + \sigma_2^2}$ and variance $\sigma^2 = 
  \qfrac[.5pt]{1}{\qfrac{1}{\sigma_1^2} + \qfrac{1}{\sigma_2^2}}$
\end{document}

在此处输入图片描述

答案3

或者,使用 \raisebox :

\documentclass{article}
\usepackage{amsmath}
\begin{document}
   Combining two Gaussians with mean $\mu_1, \mu_2$ and variance $\sigma_1^2, \sigma_2^2$ yields a new Gaussian with mean $\mu = \frac{\raisebox{.2in}{$\sigma_2^2 \mu_1 + \sigma_1^2 \mu_2$}}{\raisebox{-.2in}{$\sigma_1^2 + \sigma_2^2$}}$ and variance $\sigma^2 = \frac{\raisebox{.2in}{$1$}}{\raisebox{-.2in}{$\frac{1}{\sigma_1^2} + \frac{1}{\sigma_2^2}$}}$
\end{document}

结果

相关内容