排列不连续的多行方程

排列不连续的多行方程

我有以下代码:

\documentclass[fleqn, 12pt]{article} 
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\begin{document}
\raggedright

From the model, 
\begin{align}
&E( Y_i - \bar{ Y } ) = E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ] \nonumber \\
&( \text{Since the first normal equation gives} \ \ Y_i  = \beta_0 + \beta_1 X_i \ \ \text{and} \ \ \bar{Y} = \beta_0 + \beta_1 \bar{X}) \nonumber \\
& \ \ \ \ \ \ \ \ \ \ \ \ \ \ = \beta_1( X_i - \bar{X} ) \nonumber
\end{align}

\end{document}

请注意

&E( Y_i - \bar{ Y } ) = E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ] \nonumber \\ 

& \ \ \ \ \ \ \ \ \ \ \ \ \ \ = \beta_1( X_i - \bar{X} ) \nonumber

以线分隔

&( \text{Since the first normal equation gives} \ \ Y_i  = \beta_0 + \beta_1 X_i \ \ \text{and} \ \ \bar{Y} = \beta_0 + \beta_1 \bar{X}) \nonumber \\

尽管如此,我希望

& \ \ \ \ \ \ \ \ \ \ \ \ \ \ = \beta_1( X_i - \bar{X} ) \nonumber

排队在 = 符号处第一行

&E( Y_i - \bar{ Y } ) = E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ] \nonumber \\ 

这就是为什么我把\ \ \ \ \ \ \ \ \ \ \ \ \ \

是否可以使用 以某种方式做到这一点&,同时保持中间的线不变?或者,也许有其他方法可以自动使它们对齐?

编辑:我必须&将中间线作为其自己的线的原因是,如果我将它放在与第一个等式相同的行上,那么它就会超出页边距。

谢谢。

答案1

像这样?

\documentclass[fleqn, 12pt]{article} 
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\begin{document}
\raggedright

From the model, 
\begin{align}
E( Y_i - \bar{ Y } ) &= E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ] \nonumber \\
\rlap{(Since the first normal equation gives $Y_i  = \beta_0 + \beta_1 X_i$ and $\bar{Y} = \beta_0 + \beta_1 \bar{X}$)} \phantom{E( Y_i - \bar{ Y } )} \nonumber \\
& = \beta_1( X_i - \bar{X} ) \nonumber
\end{align}
\end{document}

在此处输入图片描述

答案2

我会将说明文字放在\parbox第一个符号右侧材料的正下方=。这样,就可以立即看出说明文字与上一行的材料有关。

在此处输入图片描述

\documentclass[fleqn, 12pt]{article}
\usepackage{amsmath,amsfonts,amssymb}
\DeclareMathOperator{\E}{E} % <-- new (expectation operator)
\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}

\begin{document}
\raggedright

From the model,
\begin{align*}
\E( Y_i - \bar{Y} ) 
&= \E[(\beta_0+\beta_1 X_i) - (\beta_0-\beta_1\bar{X})]  \\
&\qquad\parbox[t]{0.5\textwidth}{(since the first normal equation gives 
$Y_i = \beta_0 + \beta_1 X_i$ and $\bar{Y} = \beta_0 + \beta_1\bar{X}$)}\\
&= \beta_1(X_i-\bar{X}) \,.
\end{align*}

\end{document}

答案3

我只想评论一下显示(使用“因为”而不是“自从”)。它更清晰,更符合标准数学实践的风格;相反,中间的注释会让人怀疑它指的是什么。

无论如何,您可以这样做;如果注释不适合一行,它将会换行,如第三个示例所示。

\documentclass[fleqn, 12pt]{article} 
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{graphicx}
\usepackage{parskip} % \parskip=\baselineskip is HUGE

\makeatletter
\newcommand{\devioustrick}[1]{%
  \ifmeasuring@\else
    \kern-\ifcase\expandafter1\maxcolumn@widths\fi
    \parbox{\dimexpr\linewidth-\mathindent\relax}{#1}%
  \fi
}
\makeatother

\begin{document}

From the model, 
\begin{align*}
E( Y_i - \bar{ Y } ) 
&= E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ] \\
&= \beta_1( X_i - \bar{X} )
\end{align*}
because the first normal equation gives 
$Y_i  = \beta_0 + \beta_1 X_i$ and 
$\bar{Y} = \beta_0 + \beta_1 \bar{X}$.

From the model, 
\begin{align*}
E( Y_i - \bar{ Y } ) 
={}& E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ] \\
&\devioustrick{
  (since the first normal equation gives
  $Y_i  = \beta_0 + \beta_1 X_i$ and
  $\bar{Y} = \beta_0 + \beta_1 \bar{X}$)
}\\
={}& \beta_1( X_i - \bar{X} )
\end{align*}

From the model, 
\begin{align*}
E( Y_i - \bar{ Y } ) 
={}& E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ] \\
&\devioustrick{
  (since the first normal equation gives
  $Y_i  = \beta_0 + \beta_1 X_i$ and
  $\bar{Y} = \beta_0 + \beta_1 \bar{X}$
  and since the definitive answer on life, the universe
  and everything is~$42$)
}\\
={}& \beta_1( X_i - \bar{X} )
\end{align*}

\end{document}

在此处输入图片描述

答案4

另一个解决方案是只使用\tag。这在语义上似乎是合适的,因为文本与前一个方程线有关。

From the model,
\begin{align*}
E( Y_i - \bar{ Y } ) &= E[ ( \beta_0 + \beta_1 X_i ) - ( \beta_0 - \beta_1 \bar{ X } ) ]
\tag{since the first normal equation gives $Y_i  = \beta_0 + \beta_1 X_i$ and $\bar{Y} = \beta_0 + \beta_1 \bar{X}$}\\
& = \beta_1( X_i - \bar{X} )
\end{align*}

相关内容