如何对齐公式编号

如何对齐公式编号

我似乎无法对齐方程式上的数字。如果有人能帮忙就太好了!这是我的代码:

\begin{multialign}

\item 

4x - 2 &< 3 && \\

4x - 2 + 2 &< 3+2 &\text{Add 2 to both side} && \\

4x &< 5 & \text{Simplify} && \\

\frac{4x}{4} &< \frac{5}{4} & \text{Divide both side by 4} && \\

x &< \frac{5}{4} &\text{Simplify} && \\

\item 

5(x+2) &\geq 6 && \\

\frac{5(x+2)}{5} &\geq \frac{6}{5} &\text{Divide both side by 5} && \\

x+2 &\geq \frac{6}{5} &\text{Simplify} && \\

x+2-2 &\geq \frac{6}{5}-2 &\text{Subtract 2 from both side} && \\

x &\geq - \frac{2}{5} &\text{Simplify} && \\

\item 

6x &> 3 && \\

\frac{6x}{6} &> \frac{3}{6} &\text{Divide both side by 6} && \\

x &> \frac{1}{2} &\text{Simplify} &&\\

\item 

10(x+15)+20 &> 10 && \\

10(x+15) +20-20 &> 10-20 &\text{Subtract 20 from both side} && \\

10(x+15) &> -10 &\text{Simplify} && \\

\frac{10(x+15)}{10} &> \frac{-10}{10} &\text{Divide both side by 10} && \\

x+15 &> -1 &\text{Simplify} &&\\

x+15-15 &> -1-15 &\text{Subtract 15 from both side} &&\\

x &> =16 &\text{Simplify} && \\

\item 

\frac{x}{5}+14 &\leq 20 && \\

5\frac{x}{5}+14 &\leq 20(5) &\text{Multiply 5 to both side} && \\

x+14 &\leq 100 &\text{Simplify} && \\

x+14-14 &\leq 100-14 &\text{Subtract 14 from both side} && \\

x &\leq 86 &\text{Simplify} && \\

\end{multialign}

这是我所指的图片。编号没有对齐。 在此处输入图片描述


所以我稍微调整了 @JPi 的帮助,结果非常好。最后一个补充问题是,这篇文章看起来是否足够清晰,可以通读?在此处输入图片描述

答案1

谢谢https://tex.stackexchange.com/users/31729/christian-hupfer的链接以下代码修复了您的问题。看来 Egreg 的解决方案需要在每行开头使用 & 符号。

\documentclass{article}
\usepackage{mathtools}
\newcounter{multialign}
\makeatletter
%% see https://tex.stackexchange.com/a/191379/5001 for the original definition of multialign
\newenvironment{multialign} 
  {%%\setcounter{multialign}{0}%
   \def\item{\refstepcounter{multialign}\themultialign.\qquad}%
   \start@align\tw@\st@rredtrue\m@ne}
  {\endalign}
\newcommand{\firstmaline}[1]{%
  \kern-1em \mathrlap{#1}\kern5cm}
\makeatother
\allowdisplaybreaks

\begin{document}

\begin{multialign}
\item 
&4x - 2 &< 3 && \\
&4x - 2 + 2 &< 3+2 &\text{Add 2 to both side} && \\
&4x &< 5 & \text{Simplify} && \\
&\frac{4x}{4} &< \frac{5}{4} & \text{Divide both side by 4} && \\
&x &< \frac{5}{4} &\text{Simplify} && \\
\item 
&5(x+2) &\geq 6 && \\
&\frac{5(x+2)}{5} &\geq \frac{6}{5} &\text{Divide both side by 5} && \\
&x+2 &\geq \frac{6}{5} &\text{Simplify} && \\
&x+2-2 &\geq \frac{6}{5}-2 &\text{Subtract 2 from both side} && \\
&x &\geq - \frac{2}{5} &\text{Simplify} && \\
\item 
&6x &> 3 && \\
&\frac{6x}{6} &> \frac{3}{6} &\text{Divide both side by 6} && \\
&x &> \frac{1}{2} &\text{Simplify} &&\\
\item 
&10(x+15)+20 &> 10 && \\
&10(x+15) +20-20 &> 10-20 &\text{Subtract 20 from both side} && \\
&10(x+15) &> -10 &\text{Simplify} && \\
&\frac{10(x+15)}{10} &> \frac{-10}{10} &\text{Divide both side by 10} && \\
&x+15 &> -1 &\text{Simplify} &&\\
&x+15-15 &> -1-15 &\text{Subtract 15 from both side} &&\\
&x &> =16 &\text{Simplify} && \\
\item 
&\frac{x}{5}+14 &\leq 20 && \\
&5\frac{x}{5}+14 &\leq 20(5) &\text{Multiply 5 to both side} && \\
&x+14 &\leq 100 &\text{Simplify} && \\
&x+14-14 &\leq 100-14 &\text{Subtract 14 from both side} && \\
&x &\leq 86 &\text{Simplify} && \\
\end{multialign}

\end{document}

相关内容