我有一个很长的align
公式,我不知道如何以最佳方式(看起来不错并且符合 LaTeX 规则)换行。目前我有
\begin{align*}
\mathrm{Var}(\alpha)&\approx (1+\pi^{2})\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Var}(\zeta^{*})+\frac{\pi^{2}\exp(-2\delta^{*}+2\zeta^{*})}{1+\pi^{2}}\cdot \mathrm{Var}(\pi)\\ &+ (1+\pi^{2})\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Var}(\delta^{*}) + \\
2&\times \left[ \pi\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Cov}(\pi,\zeta^{*}) - (1+\pi^{2})\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Cov}(\delta^{*},\zeta^{*}) - \pi\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Cov}(\delta^{*},\pi)\right]
\end{align*}
我试过
\begin{align*}
\mathrm{Var}(\alpha)&\approx (1+\pi^{2})\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Var}(\zeta^{*})+\frac{\pi^{2}\exp(-2\delta^{*}+2\zeta^{*})}{1+\pi^{2}}\cdot \mathrm{Var}(\pi)\\ &+ (1+\pi^{2})\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Var}(\delta^{*}) + \\
2&\times \left[ \pi\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Cov}(\pi,\zeta^{*}) - (1+\pi^{2})\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Cov}(\delta^{*},\zeta^{*}) \\ & - \pi\exp(-2\delta^{*}+2\zeta^{*})\cdot \mathrm{Cov}(\delta^{*},\pi)\right]
\end{align*}
但我收到错误信息:
! Extra }, or forgotten \right.
<template> }
$}\ifmeasuring@ \savefieldlength@ \fi \set@field \hfil \endtempl...
l.1533 \end{align*}
答案1
您可以做的一件事是使用以下命令\hphantom
:
\documentclass{article}
\usepackage{mathtools}
\DeclareMathOperator*\var{Var}
\DeclareMathOperator*\cov{Cov}
\begin{document}
\begin{align*}
\var(\alpha)
&\approx (1 + \pi^{2}) \exp(-2\delta^{*} + 2\zeta^{*}) \cdot \var(\zeta^{*})\\
&\hphantom{{}\approx} + \frac{\pi^{2} \exp(-2\delta^{*} + 2\zeta^{*})}{1 + \pi^{2}} \cdot \var(\pi)\\
&\hphantom{{}\approx} + (1 + \pi^{2}) \exp(-2\delta^{*} + 2\zeta^{*}) \cdot \var(\delta^{*})\\
&\hphantom{{}\approx} + 2 \times \bigl[\pi \exp(-2\delta^{*} + 2\zeta^{*}) \cdot \cov(\pi, \zeta^{*})\\
&\hphantom{{}\approx + 2 \times \bigl[} - (1 + \pi^{2}) \exp(-2\delta^{*} + 2\zeta^{*}) \cdot \cov(\delta^{*}, \zeta^{*})\\
&\hphantom{{}\approx + 2 \times \bigl[} - \pi \exp(-2\delta^{*} + 2\zeta^{*}) \cdot \cov(\delta^{*}, \pi)\bigr]
\end{align*}
\end{document}
关于芭芭拉的注释:egreg 解释了为什么需要\bigl
and 而\bigr
不是\left
and \right
。
评论
如果您想节省一些击键时间,可以使用以下命令:
\documentclass{article}
\usepackage{mathtools}
\DeclareMathOperator*\var{Var}
\DeclareMathOperator*\cov{Cov}
\begin{document}
\begin{align*}
\var(\alpha)
&\approx (1 + \pi^2) \exp(-2\delta^* + 2\zeta^*) \cdot \var(\zeta^*)\\
&\hphantom{{}\approx} + \frac{\pi^2 \exp(-2\delta^* + 2\zeta^*)}{1 + \pi^2} \cdot \var(\pi)\\
&\hphantom{{}\approx} + (1 + \pi^2) \exp(-2\delta^* + 2\zeta^*) \cdot \var(\delta^*)\\
&\hphantom{{}\approx} + 2 \times \bigl[\pi \exp(-2\delta^* + 2\zeta^*) \cdot \cov(\pi, \zeta^*)\\
&\hphantom{{}\approx + 2 \times \bigl[} - (1 + \pi^2) \exp(-2\delta^* + 2\zeta^*) \cdot \cov(\delta^*, \zeta^*)\\
&\hphantom{{}\approx + 2 \times \bigl[} - \pi \exp(-2\delta^* + 2\zeta^*) \cdot \cov(\delta^*, \pi)\bigr]
\end{align*}
\end{document}
答案2
您可以通过这种方式减少方程的大小和一些重复的输入:
\documentclass{article}
\usepackage{mathtools}
\DeclareMathOperator*\var{Var}
\DeclareMathOperator*\cov{Cov}
\begin{document}
\begin{align*}
\var(\alpha)
&\approx (1+\pi^{2})A\cdot \var(\zeta^{*})
+ \frac{\pi^{2}A}{1+\pi^{2}}\cdot \var(\pi)
+ (1+\pi^{2})A\cdot \var(\delta^{*})\\
&\hphantom{{}\approx} + 2 \times \bigl[ \pi A\cdot \cov(\pi,\zeta^{*})
- (1+\pi^{2})A\cdot \cov(\delta^{*},\zeta^{*})
- \pi A\cdot \cov(\delta^{*},\pi)\bigr]
\end{align*}
where
\[
A = \exp(-2\delta^{*}+2\zeta^{*})
\]
\end{document}