为何我的对齐不起作用?

为何我的对齐不起作用?

我正在尝试对齐下图中的所有 = 符号。但是,我使用\begin{align*}with'&...\\表示对齐的所有尝试都只产生了错误。我能做的最好的就是添加&without align*,正如您所见,大多数都对齐了 - 但不是全部。当我继续添加&到其他等式时,我再次收到错误。在此处输入图片描述

我该如何对齐其余部分?我的代码很乱,但它看起来像这样:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{color}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{mathtools}
\usepackage{array}
\begin{document}
\pagenumbering{gobble}
\pagestyle{empty}
\date{}
\author{}
\title{Performing Row Operations to Solve Systems}
\maketitle
\vspace{-1.5cm} Recall a matrix for linear equations depends entirely on the coefficients of your variables. This allows you to create what is called an {\bfseries augmented matrix}. Consider the following example, and suppose $x_1=w, x_2=x, x_3=y, \text{and} \ x_4=z$. Remember the rows in the matrix must be placed in ascending order in terms of $x_n$ ($x_1, x_2, x_3...$), so you will need to rearrange the system and allow every gap to equal 0.
$$\begin{cases} 
x_2-3x_1+x_4&=2 \\
2x_1+4x_3&=5 \\
4x_2-x_4&=3 
\end{cases} 
\implies
\begin{cases}
-3w+x+\textcolor{red}{0y}+z&=2 \\
2w+\textcolor{red}{0x}+4y+\textcolor{red}{0z} &=5 \\
\textcolor{red}{0w}+4x+\textcolor{red}{0y}-z &=3 
\end{cases}
\implies
\newenvironment{amatrix}[1]{%
  \left(\begin{array}{@{}*{#1}{c}|c@{}}
}{%
  \end{array}\right)
}
\begin{amatrix}{4}
-3 & 1 & 0 & 1 & 2 \\  
2 & 0 & 4 & 0 & 5 \\
0 & 4 & 0 & -1 & 3
 \end{amatrix}
$$
\\
$$
R_1=-\frac{1}{3}r_1 \implies
\newenvironment{amatrix}[1]{%
  \left(\begin{array}{@{}*{#1}{c}|c@{}}
}{%
  \end{array}\right)
}
\begin{amatrix}{4}
1 & -\frac{1}{3} & 0 & -\frac{1}{3} & -\frac{2}{3} \\
2 & 0 & 4 & 0 & -5 \\
0 & 4 & 0 & -1 & 3  
\end{amatrix}
R_2=-2r_1+r_2 \implies 
\begin{amatrix}{4}
1 & -\frac{1}{3} & 0 & -\frac{1}{3} & -\frac{2}{3} \\
0 & \frac{2}{3} & 4 & \frac23 & \frac{19}{3} \\
0 & 4 & 0 & -1 & -\frac{5}{3}
\end{amatrix}
$$
\\
$$
R_2=\frac32r_2 \implies
\newenvironment{amatrix}[1]{%
  \left(\begin{array}{@{}*{#1}{c}|c@{}}
}{%
  \end{array}\right)
}
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\
0 & 1 & 6 & 1 & \frac{19}{2} \\
0 & 4 & 0 & -1 & -\frac53
\end{amatrix}
R_3=-4r_2+r_3 \implies
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\ 
0 & 1 & 6 & 1 & \frac{19}{2} \\
0 & 0 & -24 & -5 & -35 
\end{amatrix}
$$
\\
$$
R_3=-\frac{1}{24}r_3 \implies
\newenvironment{amatrix}[1]{%
  \left(\begin{array}{@{}*{#1}{c}|c@{}}
}{%
  \end{array}\right)
}
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\
0 & 1 & 6 & 1 & \frac{19}{2} \\
0 & 0 & 1 & \frac{5}{24} & \frac{35}{24} 
\end{amatrix}
R_2=-6r_3+r_2
\implies
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\
0 & 1 & 0 & -\frac14 & \frac34 \\
0 & 0 & 1 & \frac{5}{24} & \frac{35}{24} 
\end{amatrix}
$$
\\
$$
R_1=\frac13r_2+r_1 \implies
\newenvironment{amatrix}[1]{%
  \left(\begin{array}{@{}*{#1}{c}|c@{}}
}{%
  \end{array}\right)
}
\begin{amatrix}{4}
1 & 0 & 0 & -\frac{5}{12} & -\frac{5}{12} \\
0 & 1 & 0 & -\frac14 & \frac34 \\
0 & 0 & 1 & \frac{5}{24} & \frac{35}{24} 
\end{amatrix}
\implies \begin{cases}
w-\frac{5}{12}z=-\frac{5}{12} \\
x-\frac14z=\frac34 \\
y+\frac{5}{24}z=\frac{35}{24}
\end{cases}
$$
\\
$$
\therefore \\
\DeclarePairedDelimiter\set\{\}
\{(\frac{5}{12}z-\frac{5}{12}, \frac{1}{4}z+\frac{3}{4}, -
\frac{5}{24}z+\frac{35}{24}, z)\}, \{z|-\infty<z<\infty\}$$
\end{document}

答案1

我建议您在每一行中只放置一个行操作。这将使您的读者更容易弄清楚发生了什么,并且还可以确保材料适合文本块的宽度。

一定要将环境定义放在amatrix序言中。这样,您就不必\newenvironment一遍又一遍地重复该语句。

以下解决方案采用了外部gather*环境和内部aligned环境。aligned环境不仅对齐=7 行中的符号,还对齐\implies符号。

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{mathtools,amssymb,array}
\allowdisplaybreaks

\newenvironment{amatrix}[1]{%
   \left(\begin{array}{@{}*{#1}{r}|r@{}}}{%
   \end{array}\right)}
\DeclarePairedDelimiter\set\lbrace\rbrace

\begin{document}
\section*{Performing Row Operations to Solve Systems}
\thispagestyle{empty}

Recall that a matrix for linear equations depends entirely on the 
coefficients of your variables. This allows you to create what is 
called an \emph{augmented matrix}. Consider the following example, 
and suppose $x_1=w$, $x_2=x$, $x_3=y$, and $x_4=z$. Remember that 
the rows in the matrix must be placed in ascending order in terms 
of~$x_n$ ($x_1, x_2, x_3, \dotsc$), so you will need to rearrange 
the system and allow every gap to equal~$0$.
\begingroup
\renewcommand\arraystretch{1.25} % to give the arrays a more open "look"
\renewcommand\arraycolsep{4pt}   % default is 5pt
\medmuskip=3mu % default is 4mu
\begin{gather*}
\left\{ \begin{array}{@{}l@{{}={}}r@{}}
x_2-3x_1+x_4&2 \\
2x_1+4x_3&5 \\
4x_2-x_4&3
\end{array}\right.
\implies
\left\{ \begin{array}{@{}l@{{}={}}r@{}}
-3w+x+\textcolor{red}{0y}+z&2 \\
2w+\textcolor{red}{0x}+4y+\textcolor{red}{0z} &5 \\
\textcolor{red}{0w}+4x+\textcolor{red}{0y}-z &3
\end{array}\right.
\implies
\begin{amatrix}{4}
-3 & 1 & 0 & 1 & 2 \\
2 & 0 & 4 & 0 & 5 \\
0 & 4 & 0 & -1 & 3
\end{amatrix} \\  
\begin{aligned}
R_1&=-\frac{1}{3}r_1 &&\implies
\begin{amatrix}{4}
1 & -\frac{1}{3} & 0 & -\frac{1}{3} & -\frac{2}{3} \\
2 & 0 & 4 & 0 & -5 \\
0 & 4 & 0 & -1 & 3
\end{amatrix} \\
R_2&=-2r_1+r_2 &&\implies
\begin{amatrix}{4}
1 & -\frac{1}{3} & 0 & -\frac{1}{3} & -\frac{2}{3} \\
0 & \frac{2}{3} & 4 & \frac23 & \frac{19}{3} \\
0 & 4 & 0 & -1 & -\frac{5}{3}
\end{amatrix} \\
R_2&=\frac32 r_2 &&\implies
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\
0 & 1 & 6 & 1 & \frac{19}{2} \\
0 & 4 & 0 & -1 & -\frac53
\end{amatrix}\\
R_3&=-4r_2+r_3 &&\implies
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\
0 & 1 & 6 & 1 & \frac{19}{2} \\
0 & 0 & -24 & -5 & -35
\end{amatrix} \\
R_3&=-\frac{1}{24}r_3 &&\implies
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\
0 & 1 & 6 & 1 & \frac{19}{2} \\
0 & 0 & 1 & \frac{5}{24} & \frac{35}{24}
\end{amatrix}\\
R_2&=-6r_3+r_2&&\implies
\begin{amatrix}{4}
1 & -\frac13 & 0 & -\frac13 & -\frac23 \\
0 & 1 & 0 & -\frac14 & \frac34 \\
0 & 0 & 1 & \frac{5}{24} & \frac{35}{24}
\end{amatrix} \\
R_1&=\frac13r_2+r_1 &&\implies
\begin{amatrix}{4}
1 & 0 & 0 & -\frac{5}{12} & -\frac{5}{12} \\
0 & 1 & 0 & -\frac14      & \frac34 \\
0 & 0 & 1 & \frac{5}{24}  & \frac{35}{24}
\end{amatrix}
\implies 
\left\{ \begin{array}{@{}l@{{}={}}r@{}}
w-\frac{5}{12}z&-\frac{5}{12} \\
x-\frac14z&\frac34 \\
y+\frac{5}{24}z&\frac{35}{24}
\end{array}\right.
\end{aligned}\\[2ex]
\therefore \quad
\set*{\bigl( \tfrac{5}{12}z-\tfrac{5}{12}, 
              \tfrac{1}{4}z +\tfrac{3}{4}, 
             -\tfrac{5}{24}z+\tfrac{35}{24}, 
              z
      \bigr) },\ 
\set{z\mid -\infty<z<\infty}
\end{gather*}
\endgroup
\end{document}

相关内容