如何使子方程居中?

如何使子方程居中?
\documentclass[12pt, a4paper]{article}
\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{amscd}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{amsbsy}
\usepackage{amsmath}
\usepackage{rotating}
\usepackage{soul}
\usepackage{natbib}
\usepackage{frcursive}
\usepackage{xcolor}
\usepackage{float}
\usepackage{blkarray}
\usepackage[font={color=gray,bf},figurename=Fig.,labelfont={it}]{caption}
\usepackage{vmargin}


\begin{document}

\begin{gather}
  \ Pr(X_{i,j} = x, Y_{i,j} = y ) =       
   \tau_{\lambda_1, \lambda_2}(x,y)
  \frac{\lambda_1^x exp(-\lambda_1)}{x!}\frac{\lambda_2^y exp(-\lambda_2)}{y!} 
\end{gather}

where

\begin{subequation}
  \tau_{\lambda_1, \lambda_2}(x,y) = \left\{\begin{array}{ c l }
    1-\lambda_1\lambda_2\rho & \quad  \textrm{if } x = y = 0 \\
   1+\lambda_1\rho & \quad \textrm{if } x = 0, y = 1 \\
   1+\lambda_2\rho & \quad \textrm{if } x=1, y=0 \\
   1 - \rho & \quad \textrm{if } x=1, y=1 \\
   1 & \quad \textrm{otherwise }
  \end{array}
\end{subequation}


\end{document}

我怎样才能使我的第二个方程居中?

在此处输入图片描述

答案1

正如他们所说,你做错了。编译当前的示例代码时,你会看到很多错误。这是一个更新版本,显示了更符合预期的输出:

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation}
  \Pr(X_{i,j} = x, Y_{i,j} = y ) =       
    \tau_{\lambda_1, \lambda_2}(x,y)
    \frac{\lambda_1^x \exp(-\lambda_1)}{x!}
    \frac{\lambda_2^y \exp(-\lambda_2)}{y!} 
\end{equation}
where
\begin{equation}
  \renewcommand{\arraystretch}{1.2}
  \tau_{\lambda_1, \lambda_2}(x,y) = 
    \left\{\begin{array}{ c @{\quad} l }
      1 - \lambda_1\lambda_2\rho & \text{if } x = y = 0    \\
        1 + \lambda_1\rho        & \text{if } x = 0, y = 1 \\
        1 + \lambda_2\rho        & \text{if } x = 1, y = 0 \\
           1 - \rho              & \text{if } x = 1, y = 1 \\
              1                  & \text{otherwise}
  \end{array}
  \right.
\end{equation}

\end{document}

对于第二个方程,您可以考虑使用cases环境而不是手动构建的环境array。另外,如果您希望第二个方程中的每个元素都编号,则需要numcases(从numcases包裹)。

答案2

正如@Werner在他的回答中提到的,您可以考虑使用cases在包中定义amsmath或甚至更好的dcases在包中定义mathtools。 后者使cases内容Idisplay模式:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{equation}
  \Pr(X_{i,j} = x, Y_{i,j} = y ) =
    \tau_{\lambda_1, \lambda_2}(x,y)
    \frac{\lambda_1^x \exp(-\lambda_1)}{x!}
    \frac{\lambda_2^y \exp(-\lambda_2)}{y!}
\end{equation}
where
\[
  \tau_{\lambda_1, \lambda_2}(x,y) 
    = \begin{dcases}
        1 - \lambda_1\lambda_2\rho  & \text{if } x = y = 0    \\
        1 + \lambda_1\rho           & \text{if } x = 0, y = 1 \\
        1 + \lambda_2\rho           & \text{if } x = 1, y = 0 \\
           1 - \rho                 & \text{if } x = 1, y = 1 \\
              1                     & \text{otherwise}
  \end{dcases}
\]
\end{document}

在此处输入图片描述

相关内容