下面的代码产生了这个效果:
我想让第二行顶部对齐,这样$\frac{\partial^2g}{(\partial n^1_\mu)^2}$
和$\frac{\partial^2 g}{(\partial n^1_\sigma)^2}$
就在同一水平。我该如何实现呢?
\usepackage{array}
\newcommand{\xm}{\overline{\mathbf{x}}}
\begin{document}
\setlength{\arraycolsep}{20pt}
\[
\begin{array}{l r}
\displaystyle
\frac{\partial g}{\partial n_\mu^1} = \partial_1f(\xm)\cdot \frac{-\gamma_1}{\sigma_1 + n_\sigma^1}
&
\displaystyle
\frac{\partial g}{\partial n^1_\sigma} = \partial_1f(\xm) \cdot \left( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \right)
\\[20pt]
\displaystyle
\frac{\partial^2 g}{(\partial n^1_\mu)^2} = \partial^2_1f(\xm)\left( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \right)^2
&
\begin{split}
\frac{\partial^2 g}{(\partial n_\sigma^1)^2} = \partial_1 f(\xm) \cdot 2 \left( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^3} \right)
\\
{} + \partial_1^2 f(\xm)\left( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \right)^2
\end{split}
\\[20pt]
\begin{split}
\frac{\partial^2 g}{\partial n_\mu^1 \partial n_\sigma^1} = \partial_1f(\xm)\cdot \frac{-\gamma_1}{(\sigma_1 + n_\sigma^1)^2}
\\
{} + \partial_1^2 f(\xm) \left( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \right)
\\
{} \cdot \left( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \right)
\end{split}
\end{array}
\]
\end{document}
答案1
我建议使用alignat*
环境代替,array
因为您可以完全控制列之间的间距。我用 替换了 split
,aligned
它可以为垂直位置接受一个可选参数:(t, c
默认值)和b
。
另外,我加载了esdiff
简化的偏导数输入,并使用了命令\widebar
(mathabx
不加载所有 mathabx 字体),因为我认为它看起来比 更好\overline
。最后,该mleftright
包为大分隔符提供了更好的间距。
\documentclass{article}
\usepackage{mathtools, mleftright}
\usepackage{esdiff}
\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<-6> mathx5 <6-7> mathx6 <7-8> mathx7
<8-9> mathx8 <9-10> mathx9
<10-12> mathx10 <12-> mathx12
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}
\newcommand{\xm}{\widebar{\mathbf{x}}}
\begin{document}
\begin{alignat*}{2}
\diffp{ g}{{n_\mu^1}} & = \partial_1f(\xm)\cdot \frac{-\gamma_1}{\sigma_1 + n_\sigma^1}
&
\diffp{g}{{n^1_\sigma}} & = \partial_1f(\xm) \cdot \mleft( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \mright)
\\[1ex]
\diffp[2]{g}{(n^1_\mu\smash{)}}
& = \partial^2_1f(\xm)\left( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \right)^2
&
\diffp[2]{g}{(n_\sigma^1\smash{)}} & = \begin{aligned}[t] & \partial_1 f(\xm) \cdot 2 \mleft( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^3} \mright)
\\
\mathllap{{} +{}} & \partial_1^2 f(\xm)\mleft( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \mright)^{\mkern-5mu 2}
\end{aligned}
\\[1ex]
\diffp{g}{{n_\mu^1}{n_\sigma^1}} & =
\begin{aligned}[t] & \partial_1f(\xm)\cdot \frac{-\gamma_1}{(\sigma_1 + n_\sigma^1)^2} \\
\mathllap{{} + {}}& \partial_1^2 f(\xm) \left( -\gamma_1 \frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \right)
\\
\mathllap{{} \cdot} &\mleft( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \mright)
\end{aligned}
\end{alignat*}
\end{document}
答案2
你很幸运,最后一个方程(未拆分)与顶线一样宽。所以我建议gather
一切都使用前两对aligned
(使用嵌套aligned
来拆分第四个方程)。
\documentclass{article}
\usepackage{amsmath}
\newcommand{\xm}{\overline{\mathbf{x}}}
\begin{document}
\begin{gather*}
\begin{aligned}
\frac{\partial g}{\partial n_\mu^1}
&=\partial_1f(\xm)\cdot \frac{-\gamma_1}{\sigma_1 + n_\sigma^1}
&
\frac{\partial g}{\partial n^1_\sigma}
&=\partial_1f(\xm) \cdot \biggl( -\gamma_1 \frac{x_1
- \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \biggr)
\\[2ex]
\frac{\partial^2 g}{(\partial n^1_\mu)^2}
&= \partial^2_1f(\xm)\biggl( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \biggr)^{\!2}
&
\frac{\partial^2 g}{(\partial n_\sigma^1)^2}
&= \begin{aligned}[t]
&\partial_1 f(\xm) \cdot 2 \biggl( -\gamma_1 \frac{x_1 -
\mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^3} \biggr)
\\
&\quad + \partial_1^2 f(\xm)\biggl( -\gamma_1 \frac{x_1 -
\mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \biggr)^{\!2}
\end{aligned}
\end{aligned}
\\[2ex]
\frac{\partial^2 g}{\partial n_\mu^1 \partial n_\sigma^1}
= \partial_1f(\xm)\cdot \frac{-\gamma_1}{(\sigma_1 + n_\sigma^1)^2}
+ \partial_1^2 f(\xm) \biggl( -\gamma_1 \frac{x_1 -
\mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \biggr)
\cdot \biggl( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \biggr)
\end{gather*}
\end{document}
答案3
另一种看待这个问题的方式。第二行上的第二个方程将适合文本宽度,那么为什么不把它放在一行上呢?然后align*
可以使用一个简单的。
\documentclass{article}
\usepackage{amsmath}
\newcommand{\xm}{\overline{\mathbf{x}}}
\begin{document}
\begin{align*}
\frac{\partial g}{\partial n_\mu^1}
&= \partial_1f(\xm)\cdot \frac{-\gamma_1}{\sigma_1 + n_\sigma^1}
\qquad\qquad
\frac{\partial g}{\partial n^1_\sigma}
=\partial_1f(\xm) \cdot \biggl( -\gamma_1
\frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \biggr)\\[2\jot]
\frac{\partial^2 g}{(\partial n^1_\mu)^2}
&= \partial^2_1f(\xm)\biggl( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \biggr)^{\!2}\\[2\jot]
\frac{\partial^2 g}{(\partial n_\sigma^1)^2}
&= \partial_1 f(\xm) \cdot 2 \biggl( -\gamma_1
\frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^3} \biggr)
+ \partial_1^2 f(\xm)\biggl( -\gamma_1
\frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \biggr)^{\!2}
\\[2\jot]
\frac{\partial^2 g}{\partial n_\mu^1 \partial n_\sigma^1}
&= \partial_1f(\xm)\cdot \frac{-\gamma_1}{(\sigma_1 + n_\sigma^1)^2}
+ \partial_1^2 f(\xm) \biggl( -\gamma_1
\frac{x_1 - \mu_1 - n_\mu^1}{(\sigma_1 + n_\sigma^1)^2} \biggr)
\cdot \biggl( \frac{-\gamma_1}{\sigma_1 + n_\sigma^1} \biggr)
\end{align*}
\end{document}
这会将固定大小应用于括号(\bigg
通常是这种分数的不错选择)。它还使用维度的倍数\jot
来指定线分隔;1\jot
是的默认分隔align
,实际上,使用像这样布置的方程式,并不需要额外的分隔。
答案4
这是另一种方法。通过将重复元素\sigma_1+n_{\sigma}^1
和替换x_1 - \mu_1 - n_\mu^1
为,例如\xi
和,可以完全避免子公式中的换行符\phi
。然后,使用array
环境将五个子公式排版为 3 行而不是 6 行。
请尽量保持大括号的大小一致;我建议始终使用\Bigl(
and 。Bigr(
正如@Bernard 在他的回答中所做的那样,我建议加载esdiff
包并使用\diffp
宏来简化偏微分项的排版。
\documentclass{article}
\usepackage{esdiff} % for \diffp macro
\usepackage{array} % for \newcolumntype macro
\newcolumntype{L}{>{\displaystyle}l} % automatic display-style math mode
\newcolumntype{R}{>{\displaystyle}r}
\newcolumntype{C}{>{{}}c<{{}}} % for columns with "=" symbols
\newcommand{\xm}{\bar{\mathbf{x}}}
\begin{document}
Put $\xi=\sigma_1+n_{\sigma}^1$ and $\phi=x_1 - \mu_1 - n_\mu^1$. Then
\[
\setlength\arraycolsep{0pt}
\begin{array}{RCL @{\qquad} RCL}
\diffp{g}{{n_\mu^1}}
&=& \partial_1f(\xm) \Bigl(\frac{-\gamma^{}_1}{\xi} \Bigr)
& \diffp{g}{{n^1_\sigma}}
&=& \partial_1f(\xm) \Bigl( \frac{-\gamma^{}_1\phi}{\xi^2} \Bigr)
\\[3ex]
\diffp[2]{g}{(n^1_\mu)}
&=& \partial^2_1f(\xm)\Bigl( \frac{-\gamma^{}_1}{\xi} \Bigr)^{\!2}
& \diffp[2]{g}{(n_\sigma^1)}
&=& \partial_1 f(\xm) \cdot 2 \Bigl( \frac{-\gamma^{}_1\phi}{\xi^3} \Bigr)
+ \partial_1^2 f(\xm) \Bigl( \frac{-\gamma^{}_1 \phi}{\xi^2} \Bigr)^{\!2}
\\[3ex]
\diffp{g}{{n_\mu^1}{n_\sigma^1}}
&=& \multicolumn{4}{L}{%
\partial_1f(\xm) \frac{-\gamma^{}_1}{\xi^2}
+ \partial_1^2 f(\xm) \Bigl( \frac{-\gamma^{}_1\phi}{\xi^2} \Bigr)
\Bigl( \frac{-\gamma^{}_1}{\xi} \Bigr)}
\end{array}
\]
\end{document}
附录:如果使用诸如\xi
和之类的缩写词\phi
不合适,我建议将五个偏导数表达式显示在五行上。这样,读者的眼睛就不必“搜索”跨行来获取每个偏导数的表达式。而且,五行仍然比原始解决方案少一行。
\documentclass{article}
\usepackage{amsmath} % for align* environment
\usepackage{esdiff} % for \diffp macro
\usepackage{kpfonts} % Palatino clone
\newcommand{\xm}{\bar{\mathbf{x}}}
\begin{document}
\begin{align*}
\diffp{g}{{n_\mu^1}}
&= \partial_1 f(\xm) \biggl(\frac{-\gamma_1}{\sigma_1+n_{\sigma}^1} \biggr)
\\
\diffp{g}{{n^1_\sigma}}
&= \partial_1 f(\xm) \biggl( \frac{-\gamma_1(x_1 - \mu_1 - n_\mu^1)}{(\sigma_1+n_{\sigma}^1)^2} \biggr)
\\
\diffp[2]{g}{(n^1_\mu)}
&= \partial^2_1f(\xm)\biggl( \frac{-\gamma_1}{\sigma_1+n_{\sigma}^1} \biggr)^{\!2}
\\
\diffp[2]{g}{(n_\sigma^1)}
&= \partial_1 f(\xm) \cdot 2 \biggl( \frac{-\gamma_1(x_1 - \mu_1 - n_\mu^1)}{(\sigma_1+n_{\sigma}^1)^3} \biggr)
+\partial_1^2 f(\xm) \biggl( \frac{-\gamma_1 (x_1 - \mu_1 - n_\mu^1)}{(\sigma_1+n_{\sigma}^1)^2} \biggr)^{\!2}
\\
\diffp{g}{{n_\mu^1}{n_\sigma^1}}
&= \partial_1f(\xm) \biggl( \frac{-\gamma_1}{(\sigma_1+n_{\sigma}^1)^2} \biggr)
+\partial_1^2 f(\xm) \biggl( \frac{-\gamma_1(x_1 - \mu_1 - n_\mu^1)}{(\sigma_1+n_{\sigma}^1)^2} \biggr)
\biggl( \frac{-\gamma_1}{\sigma_1+n_{\sigma}^1} \biggr)
\end{align*}
\end{document}