如何将我的方程式左对齐?

如何将我的方程式左对齐?

我想显示四个长度不同的方程。我希望它们像这样左对齐。在此处输入图片描述

但是我的代码给出了这个在此处输入图片描述

以下是我的代码:

$$\begin{aligned} p(a) &=p(a) p(a \rightarrow a)+p(b) p(b \rightarrow a)+p(c) p(c \rightarrow a)+p(d) p(d \rightarrow a) \\  
&={\scriptstyle \frac{1}{2} \frac{2}{3}+\frac{1}{4} \frac{1}{3}+\frac{1}{3}+\frac{1}{3}=\frac{1}{2}}
\end{aligned}$$
$$\begin{aligned} p(b) &=p(a) p(a \rightarrow b)+p(b) p(b \rightarrow b)+p(c) p(c \rightarrow b) \\ 
&={\scriptstyle\frac{1}{2} \frac{1}{6}+\frac{1}{4} \frac{1}{2}+\frac{1}{3} \frac{1}{3}=\frac{1}{4}} \end{aligned}$$
$$\begin{aligned} p(c) &=p(a) p(a \rightarrow c)+p(b) p(b \rightarrow c)+p(c) p(c \rightarrow c)+p(d) p(d \rightarrow c) \\ 
&={\scriptstyle\frac{1}{2} \frac{1}{12}+\frac{1}{4} \frac{1}{6}+\frac{1}{8} 0+\frac{1}{8}=\frac{1}{8}} \end{aligned}$$
$$\begin{aligned} p(d) &=p(a) p(a \rightarrow d)+p(c) p(c \rightarrow d)+p(d) p(d \rightarrow d) \\ 
&={\scriptstyle\frac{1}{2} \frac{1}{12}+\frac{1}{8} \frac{1}{3}+\frac{1}{8} \frac{1}{3}=\frac{1}{3}} \end{aligned}$$

谁能告诉我我该做什么?

答案1

这是一个建议

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
p(a)&=p(a) p(a \rightarrow a)+p(b) p(b \rightarrow a)+p(c) p(c \rightarrow a)+p(d) p(d \rightarrow a)\\
&\;={\scriptstyle \frac{1}{2} \frac{2}{3}+\frac{1}{4} \frac{1}{3}+\frac{1}{3}+\frac{1}{3}=\frac{1}{2}}\\
p(b)&=p(a) p(a \rightarrow b)+p(b) p(b \rightarrow b)+p(c) p(c \rightarrow b)\\
&\;={\scriptstyle\frac{1}{2} \frac{1}{6}+\frac{1}{4} \frac{1}{2}+\frac{1}{3} \frac{1}{3}=\frac{1}{4}}\\
p(c)&=p(a) p(a \rightarrow c)+p(b) p(b \rightarrow c)+p(c) p(c \rightarrow c)+p(d) p(d \rightarrow c)\\
&\;={\scriptstyle\frac{1}{2} \frac{1}{12}+\frac{1}{4} \frac{1}{6}+\frac{1}{8} 0+\frac{1}{8}=\frac{1}{8}}\\
p(d)&=p(a) p(a \rightarrow d)+p(c) p(c \rightarrow d)+p(d) p(d \rightarrow d)\\
&\;={\scriptstyle\frac{1}{2} \frac{1}{12}+\frac{1}{8} \frac{1}{3}+\frac{1}{8} \frac{1}{3}=\frac{1}{3}}
\end{align*}
\end{document}

在此处输入图片描述

为什么要用\scriptstyle?分数读起来太难了!改用\tfrac吧!

您应该删除\;&\;={\scriptstyle...以对齐=s。我更喜欢这种方式。


我强烈推荐这个

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
p(a)&=p(a) p(a \rightarrow a)+p(b) p(b \rightarrow a)+p(c) p(c \rightarrow a)+p(d) p(d \rightarrow a)\\
&=\tfrac{1}{2} \tfrac{2}{3}+\tfrac{1}{4} \tfrac{1}{3}+\tfrac{1}{3}+\tfrac{1}{3}=\tfrac{1}{2}\\
p(b)&=p(a) p(a \rightarrow b)+p(b) p(b \rightarrow b)+p(c) p(c \rightarrow b)\\
&=\tfrac{1}{2} \tfrac{1}{6}+\tfrac{1}{4} \tfrac{1}{2}+\tfrac{1}{3} \tfrac{1}{3}=\tfrac{1}{4}\\
p(c)&=p(a) p(a \rightarrow c)+p(b) p(b \rightarrow c)+p(c) p(c \rightarrow c)+p(d) p(d \rightarrow c)\\
&=\tfrac{1}{2} \tfrac{1}{12}+\tfrac{1}{4} \tfrac{1}{6}+\tfrac{1}{8} 0+\tfrac{1}{8}=\tfrac{1}{8}\\
p(d)&=p(a) p(a \rightarrow d)+p(c) p(c \rightarrow d)+p(d) p(d \rightarrow d)\\
&=\tfrac{1}{2} \tfrac{1}{12}+\tfrac{1}{8} \tfrac{1}{3}+\tfrac{1}{8} \tfrac{1}{3}=\tfrac{1}{3}
\end{align*}
\end{document}

在此处输入图片描述

答案2

我建议这种布局,使用环境fleqn,并且在我看来,中等大小的分数看起来最好,我还使用\medmath\mfrac命令,每个来自nccmath

\documentclass{article}
\usepackage{amsmath, nccmath}

\begin{document}

\begin{fleqn}
\begin{align*}
p(a)&=p(a) p(a \rightarrow a)+p(b) p(b \rightarrow a)+p(c) p(c \rightarrow a)+p(d) p(d \rightarrow a)\\
&\quad= \medmath{\frac{1}{2}\cdot \frac{2}{3}+\frac{1}{4}\cdot \frac{1}{3}+\frac{1}{3}+\frac{1}{3}}=\mfrac{1}{2} \\[1ex]
p(b)&=p(a) p(a \rightarrow b)+p(b) p(b \rightarrow b)+p(c) p(c \rightarrow b)\\
&\quad= \medmath{\frac{1}{2}\cdot \frac{1}{6}+\frac{1}{4}\cdot \frac{1}{2}+\frac{1}{3}\cdot \frac{1}{3}}=\mfrac{1}{4} \\[1ex]
p(c)&=p(a) p(a \rightarrow c)+p(b) p(b \rightarrow c)+p(c) p(c \rightarrow c)+p(d) p(d \rightarrow c)\\
&\quad= \medmath{\frac{1}{2}\cdot \frac{1}{12}+\frac{1}{4}\cdot \frac{1}{6}+\frac{1}{8}\,0 + \frac{1}{8}}=\mfrac{1}{8} \\[1ex]
p(d)&=p(a) p(a \rightarrow d)+p(c) p(c \rightarrow d)+p(d) p(d \rightarrow d)\\
&\quad= \medmath{\frac{1}{2}\cdot \frac{1}{12}+\frac{1}{8}\cdot \frac{1}{3}+\frac{1}{8\cdot } \frac{1}{3}}=\mfrac{1}{3}
\end{align*}
\end{fleqn}

\end{document} 

在此处输入图片描述

相关内容