3

I'd like to create an environment that hides equation numbers from numbered equations. I'd should work like this:

\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}
  • 3
    why not simply use equation* ? (amsmath, or \[) – David Carlisle Mar 22 at 18:10
  • To make a long story short, I'm inputting them from an external text file which I load with a command, so the intended use would be like \begin{nonumber}\thatcommand\end{nonumber}. – noibe Mar 22 at 18:47
3

If you're only using equations, then the following will suffice:

enter image description here

\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}

Note that \nonumber already exists, so you'd have to use a different environment name, like noeqnumber.


If you're using aligns, then we can adjust the counter stepping and tag printing mechanism:

enter image description here

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.