用方程式将线居中,同时分别标记每条线

用方程式将线居中,同时分别标记每条线

考虑以下 MWE

\documentclass[12pt,a4paper]
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\begin{align}
\mathbb{P}(D_{1}\cap D_{2})=\mathbb{P}(D_{1})\mathbb{P}(D_{2}),\ \mathbb{P}(D_{2}\cap D_{3})=\mathbb{P}(D_{2})\mathbb{P}(D_{3}),\ \mathbb{P}(D_{1}\cap D_{3})=\mathbb{P}(D_{1})\mathbb{P}(D_{3})\label{eq:equation}\\
(D_{1}\cap D_{2}\cap D_{3})=\mathbb{P}(D_{1})\mathbb{P}(D_{2})\mathbb{P}(D_{3}\label{eq:moreequations}
\end{align}

方程

当我显示此图时,方程式的顶行不在单个方程式的底行上居中。如何才能实现这一点,而不会丢失标签?

当我切换到不同的方法(例如使用array来完成居中)时,我失去了分别标记所有线条的能力。

答案1

由于第一行太宽,我建议使用括号,以便清楚地表明数字指的是所有三种情况。

我建议使用个人命令,而不是重复\mathbb{P}

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\newcommand{\PP}{\mathbb{P}}

\begin{document}
\begin{gather}
\begin{cases}
  \PP(D_{1}\cap D_{2})=\PP(D_{1})\PP(D_{2}), \\
  \PP(D_{2}\cap D_{3})=\PP(D_{2})\PP(D_{3}), \\
  \PP(D_{1}\cap D_{3})=\PP(D_{1})\PP(D_{3})
\end{cases}
\label{eq:equation}\\
\PP(D_{1}\cap D_{2}\cap D_{3})=\PP(D_{1})\PP(D_{2})\PP(D_{3})
\label{eq:moreequations}
\end{gather}

\end{document}

在此处输入图片描述

答案2

align仅当需要指定对齐方式(使用&)时才应该使用未对齐的方程式gather,但这里第一行太宽(我猜,因为您没有给出页面宽度的指示)因此您可以使用split(或更好的gathered)将其分布在三行上,用一个数字。

在此处输入图片描述

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\begin{gather}
\mathbb{P}(D_{1}\cap D_{2})=\mathbb{P}(D_{1})\mathbb{P}(D_{2}),
\ \mathbb{P}(D_{2}\cap D_{3})=\mathbb{P}(D_{2})\mathbb{P}(D_{3}),
\ \mathbb{P}(D_{1}\cap D_{3})=\mathbb{P}(D_{1})\mathbb{P}(D_{3})\label{eq:equation}\\
(D_{1}\cap D_{2}\cap D_{3})=\mathbb{P}(D_{1})\mathbb{P}(D_{2})\mathbb{P}(D_{3}
\label{eq:moreequations}
\end{gather}

so
\begin{gather}
\begin{gathered}\mathbb{P}(D_{1}\cap D_{2})=\mathbb{P}(D_{1})\mathbb{P}(D_{2})\\
 \mathbb{P}(D_{2}\cap D_{3})=\mathbb{P}(D_{2})\mathbb{P}(D_{3})\\
 \mathbb{P}(D_{1}\cap D_{3})=\mathbb{P}(D_{1})\mathbb{P}(D_{3})
\end{gathered}\label{eq:equationb}\\
(D_{1}\cap D_{2}\cap D_{3})=\mathbb{P}(D_{1})\mathbb{P}(D_{2})\mathbb{P}(D_{3}
\label{eq:moreequationsb}
\end{gather}
\end{document}

答案3

我可以建议一下。

\documentclass[12pt,a4paper]{memoir}%your class was missing
\usepackage{amsmath,amsfonts,amssymb}

\usepackage[noabbrev]{cleveref}%for references, see below.

\DeclareMathOperator{\prob}{\mathbb{P}}% improves spacing and leads to a more consistent typography


\begin{document}
I would prefer the following layout, since it clearly shows what you refer to. 
\begin{align}
    \prob(D_{1}\cap D_{2})
        &=\prob(D_{1})\prob(D_{2}),\label{eq:equation1}\\ 
    \prob(D_{2}\cap D_{3})
        &=\prob(D_{2})\prob(D_{3}),\label{eq:equation2}\\\ 
    \prob(D_{1}\cap D_{3})
        &=\prob(D_{1})\prob(D_{3}),\label{eq:equation3}\\
    \prob(D_{1}\cap D_{2}\cap D_{3})
    &=\prob(D_{1})\prob(D_{2})\prob(D_{3}).\label{eq:moreequations}
\end{align}

Use \cref{eq:equation1,eq:equation2,eq:equation3}, \crefrange{eq:equation1}{eq:equation3}, \cref{eq:moreequations} or \eqref{eq:moreequations} for references.


An alternative: For any $1\leq i<j\leq 3$, we have
\begin{align}
    \prob(D_{i}\cap D_{j})
        &=\prob(D_{i})\prob(D_{j}),\label{eq:equation}\\ 
    \prob(D_{1}\cap D_{2}\cap D_{3}),
    &=\prob(D_{1})\prob(D_{2})\prob(D_{3}).\label{eq:moreequations2}
\end{align}
Another alternative probably would be: The events $D_1, D_2,$ and $D_3$ are statistically independent. 

\end{document}

您的代码中可能存在一些拼写错误。

在此处输入图片描述

相关内容