答案1
使用更友好的输入语法(以代码为代价):
\documentclass{article}
\usepackage{amsmath,amssymb,xparse}
\ExplSyntaxOn
\NewDocumentEnvironment{derivation}{b}
{
\bool_gset_false:N \g_vanderwalt_derivation_therefore_bool
\seq_set_split:Nnn \l_vanderwalt_derivation_body_seq { \\ } { #1 }
\begin{alignedat}{2}
\seq_map_function:NN \l_vanderwalt_derivation_body_seq \vanderwalt_derivation_line:n
\end{alignedat}
}{}
\bool_new:N \g_vanderwalt_derivation_therefore_bool
\seq_new:N \l_vanderwalt_derivation_body_seq
\seq_new:N \l_vanderwalt_derivation_line_seq
\tl_new:N \l_vanderwalt_derivation_line_tl
\cs_new_protected:Nn \vanderwalt_derivation_line:n
{
\seq_set_split:Nnn \l_vanderwalt_derivation_line_seq { & } { #1 }
\tl_put_right:Nn \l_vanderwalt_derivation_line_tl { & }
\bool_if:NTF \g_vanderwalt_derivation_therefore_bool
{ \tl_put_right:Nn \l_vanderwalt_derivation_line_tl { \therefore } }
{ \bool_gset_true:N \g_vanderwalt_derivation_therefore_bool }
\tl_put_right:Nx \l_vanderwalt_derivation_line_tl
{
\seq_item:Nn \l_vanderwalt_derivation_line_seq { 1 }
& \exp_not:N \qquad &
\int_compare:nT { \seq_count:N \l_vanderwalt_derivation_line_seq > 1 }
{
\exp_not:N \text{(\seq_item:Nn \l_vanderwalt_derivation_line_seq { 2 })}
}
\exp_not:N \\
}
\tl_use:N \l_vanderwalt_derivation_line_tl
}
\ExplSyntaxOff
\begin{document}
\begin{equation*}
\begin{derivation}
4x^2 - 12x = -8 \\
x^2 - 3x = -2 & divide all terms by $4$ \\
x^2 - 3x + 2 = 0 & write in standard form \\
(x - 2)(x - 1) = 0 & factorise \\
x-2 = 0 \text{ or } x-1 = 0 & apply the zero factor law \\
x = 2 \text{ or } x = 1
\end{derivation}
\end{equation*}
\end{document}
环境derivation
收集其内容并将其拆分为\\
。然后处理每一行,并将<formula> & <text>
其转换为
& <formula> & \qquad & \text{(<text>)} \\
\therefore
从第二行开始添加符号;只有<text>
在 之后添加了内容时才会添加括号中的&
。
代码在alignedat
环境中执行。
这与
\begin{equation*}
\begin{alignedat}{2}
& 4x^2 - 12x = -8 \\
& \therefore x^2 - 3x = -2 &\qquad& \text{divide all terms by $4$} \\
& \therefore x^2 - 3x + 2 = 0 &\qquad& \text{write in standard form} \\
& \therefore (x - 2)(x - 1) = 0 &\qquad& \text{factorise} \\
& \therefore x-2 = 0 \text{ or } x-1 = 0 &\qquad& \text{apply the zero factor law} \\
& \therefore x = 2 \text{ or } x = 1
\end{alignedat}
\end{equation*}
但输入语法要繁琐得多。
答案2
您可以通过两个并排的对齐来获得它:
\documentclass{article}
\usepackage{mathtools, amssymb}
\begin{document}
\begin{align*}
& 4x^2-12x = -8\\
& \therefore x^2-3x = -2 & & \text{ (divide all terms by 4)}\\
& \therefore x^2-3x + 2 = 08 & & \text{ (write in standard form)}\\
& \therefore (x-2)(x-1)=0 & & \text{ (factorise)}\\
& \therefore x-2 = 0\text{ or } x-1= 0 & & \text{ (apply the zero factor law)}\\
& \therefore x = 2 \text{ or }x =1
\end{align*}
\end{document}
答案3
这是一个开始吗?
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
4x^2-12x = -8 & \text{ (Text Text Text)}\\
4x^2-12x = -88 & \text{ (Text Text Text)}\\
4x^2-12x = -8 & \text{ (Text Text Text)}\\
4x^2-12x = -888 & \text{ (Text Text Text)}\\
4x^2-12x = -8 & \text{ (Text Text Text)}\\
4x^2-12x = -88 & \text{ (Text Text Text)}
\end{align*}
\end{document}