有谁知道一种优雅的方法,可以避免\nonumber
在最后一行时手动将 放在 的末尾 \shortintertext{}
?如下面的最小工作示例 (MWE) 中被 注释掉的部分所示%
。
我很高兴\shortintertext{}
使用mathtools
.\shortintertext{}
不产生方程编号,我喜欢这样,但如果我将其用作方程块\shortintertext{}
中的最后一个项,则会产生一个额外的方程编号(如本例中所示,请参阅 MWE)
{align}
\shortintertext{}
它也似乎\shortintertext{}
产生了额外的行距......
MWE(灵感来自这个 SE 示例(英文):
\documentclass[preview]{standalone}
\usepackage{mathtools}
\usepackage[usenames,dvipsnames]{xcolor}
\begin{document}
\begin{align}
\shortintertext{\color{gray} We are trying to solve for $x$}
3+x &=4\\
\shortintertext{\color{gray} Subtract 3 from both sides:}
x &=4-3 \
\shortintertext{\color{gray} Hence, $x$ must be 1:}
x &=1
\shortintertext{\color{gray} Some comments on the conclussion} % \nonumber
\end{align} % \vspace{-3.4 em}
\end{document}
答案1
您可以使用不同的方法:
\documentclass{article}
\usepackage{mathtools}
\usepackage[usenames,dvipsnames]{xcolor}
\newenvironment{compactequations}
{\setlength{\abovedisplayskip}{2pt plus 2pt}%
\setlength{\abovedisplayshortskip}{2pt plus 2pt}%
\setlength{\belowdisplayskip}{2pt plus 2pt}%
\setlength{\belowdisplayshortskip}{2pt plus 2pt}}
{}
\begin{document}
\begin{compactequations}
\noindent\textcolor{gray}{We are trying to solve for $x$}
\begin{align}
3+x &=4\\
\intertext{\color{gray} Subtract 3 from both sides:} % \nonumber
x &=4-3 \\
\intertext{\color{gray} Hence, $x$ must be 1:}
x &=1
\end{align}
\textcolor{gray}{Some comments on the conclusion}
\end{compactequations}
\end{document}
不在等号处对齐:
\documentclass{article}
\usepackage{mathtools}
\newenvironment{compactequations}
{\setlength{\abovedisplayskip}{2pt plus 2pt}%
\setlength{\abovedisplayshortskip}{2pt plus 2pt}%
\setlength{\belowdisplayskip}{2pt plus 2pt}%
\setlength{\belowdisplayshortskip}{2pt plus 2pt}}
{}
\begin{document}
\begin{compactequations}
\noindent We are trying to solve for $x$
\begin{equation}
3+x=4
\end{equation}
Subtract 3 from both sides:
\begin{equation}
x=4-3
\end{equation}
Hence, $x$ must be 1:
\begin{equation}
x=1
\end{equation}
Some comments on the conclusion
\end{compactequations}
\end{document}