\documentclass{article}
\usepackage{amsmath}
\usepackage{fancyhdr}
\usepackage{amssymb}
\pagestyle{fancy}
\rhead{Homework for Stats Chapter 4\textbackslash Lab}
\cfoot{Page \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\section{4.4 Excercises}
\begin{enumerate}
\item For each experiment, list the sample space and the probabilities
for each outcome. Compute the expected number of heads in each case.
\begin{enumerate}
\item Two independent tosses of a fair coin\\
\{(HH),(HT),(TH),(TT)\}\\
$\mathbb{P}(HH)=\frac{1}{4} \mathbb{P}(HT)
=\frac{1}{4}\mathbb{P}(TH)=\frac{1}{4}\mathbb{P}(TT)
=\frac{1}{4}$\\
\begin{align}
\mathbb{E}\left ( H\right )=\sum _{i=0}H_i\cdot p_i & =2\cdot\frac{1}{4}+1\cdot\frac{1}{4}+1\cdot\frac{1}{4}+0\cdot\frac{1}{4}\\
& =\frac{1}{2}+\frac{1}{4}+\frac{1}{4}\\
& =1\\
\end{align}
\end{enumerate}
\end{enumerate}
\end{document}
看不出我哪里搞错了。我关闭了所有内容。“段落在 \align 完成之前结束。
答案1
您的对齐环境中有一个空行。我对您的代码做了一些修改:将内联\frac
(我认为太小)替换为包\mfrac
中的(=中等大小的分数,~80% 的显示样式分数)nccmath
,删除另一个空行,并且我认为对齐的每一行都不需要编号,我擅自将其替换为aligned
嵌套的环境equation
。
\documentclass{article}
\usepackage{amsmath}
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage{nccmath}
\pagestyle{fancy}
\fancyhf{}
\rhead{Homework for Stats Chapter 4\textbackslash Lab}
\cfoot{Page \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\section{4.4 Exercises}
\begin{enumerate}
\item For each experiment, list the sample space and the probabilities
for each outcome. Compute the expected number of heads in each case.
\begin{enumerate}
\item Two independent tosses of a fair coin\\
\{(HH),(HT),(TH),(TT)\}\\
$\mathbb{P}(HH)=\mfrac{1}{4} \mathbb{P}(HT)
=\mfrac{1}{4}\mathbb{P}(TH)=\mfrac{1}{4}\mathbb{P}(TT)
=\mfrac{1}{4}$
\begin{equation}
\begin{aligned}
\mathbb{E}\left ( H\right )=∑ _{i=0}^4H_i · p_i & =2 · \frac{1}{4}+1 · \frac{1}{4}+1 · \frac{1}{4}+0 · \frac{1}{4}\\
& =\frac{1}{2}+\frac{1}{4}+\frac{1}{4}\\
& =1
\end{aligned}
\end{equation}
\end{enumerate}
\end{enumerate}
\end{document}
答案2
我认为您不应该在环境中的最后一行末尾添加换行符。请尝试删除最后一个\\
。