我想创建一个环境,隐藏编号方程中的方程编号。我应该像这样工作:
\documentclass{article}
\begin{document}
% ---------------------------
% \begin{nonumber}
\begin{equation}
a + b = c \quad \text{this equation should be unnumbered}
\end{equation}
% \end{nonumber}
\begin{equation}
a + b = c \quad \text{this equation should be numbered}
\end{equation}
\end{document}
答案1
如果您仅使用equation
s,则以下内容就足够了:
\documentclass{article}
\newenvironment{noeqnumber}
{\renewenvironment{equation}{\[}{\]}}
{}
\begin{document}
\begin{noeqnumber}
\begin{equation}
a + b = c \quad \mbox{this equation should be unnumbered}
\end{equation}
\end{noeqnumber}
\begin{equation}
a + b = c \quad \mbox{this equation should be numbered}
\end{equation}
\end{document}
请注意\nonumber
已经存在,因此您必须使用不同的环境名称,例如noeqnumber
。
如果您使用align
s,那么我们可以调整计数器步进和标签打印机制:
\documentclass{article}
\usepackage{mathtools}
\makeatletter
% New tag form that gobbles the number
\newtagform{gobble}[\@gobble]{}{}
\makeatother
\let\oldrefstepcounter\refstepcounter
\newenvironment{noeqnumber}
{\renewcommand{\refstepcounter}[1]{%
% Only step counter if it is not equation
\ifnum\pdfstrcmp{##1}{equation}=0\else
\oldrefstepcounter{##1}%
\fi
}%
\usetagform{gobble}}
{}
\begin{document}
\begin{noeqnumber}
\begin{align}
a + b &= c \quad \text{this equation should be unnumbered} \\
d &= e + f \quad \text{this equation should be unnumbered}
\end{align}
\end{noeqnumber}
\begin{equation}
a + b = c \quad \text{this equation should be numbered}
\end{equation}
\end{document}