19

I want my document to look like this:

Normal document text.

equation (1)

Definition Definition text.

equation (D1)

More definition text.

Normal document text.

equation (2)

More document text.

So the numbering changes inside the definition, and remains unaltered outside the definition.

16

If you only want a temporary change, use the \tag command, loaded by the amsmath package. Here's the code:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

Equation the first, normally numbered.
\begin{equation}
a=b+c
\end{equation}

A special equation.
\begin{equation}\tag{D1}
d=e+f
\end{equation}

A second, normally numbered equation.
\begin{equation}
g=h+i
\end{equation}

\end{document}

If you use \label to reference the equations later, \tag doesn't have to have the same argument as \label. This is the result:

enter image description here

13

You can define a new environment.

\newcounter{defcounter}
\setcounter{defcounter}{0}

.
.
.

\newenvironment{myequation}{%
\addtocounter{equation}{-1}
\refstepcounter{defcounter}
\renewcommand\theequation{D\thedefcounter}
\begin{equation}}
{\end{equation}}

And use it like

\begin{myequation}\label{myeq:one}
  a = b
\end{myequation}

You can use it any where and you get D1, D2 etc as the equation number.

Full code:

\documentclass{article}
\newcounter{defcounter}
\setcounter{defcounter}{0}

\usepackage{amsthm}
\newtheorem{defn}{Definition}

\newenvironment{myequation}{%
\addtocounter{equation}{-1}
\refstepcounter{defcounter}
\renewcommand\theequation{D\thedefcounter}
\begin{equation}}
{\end{equation}}
%
\begin{document}
  Bbla bla
   \begin{equation}
     x = y
   \end{equation}
\begin{defn}
   bla bla
   \begin{myequation}\label{myeq:one}
     a = b
   \end{myequation}
   \begin{myequation}
     a = b
   \end{myequation}
\end{defn}
bla bla
   \begin{equation}\label{eq:one}
     x = yz
   \end{equation}
   \begin{myequation}
     a = b
   \end{myequation}

From equation~\ref{myeq:one} and~\ref{eq:one}...
\end{document}

enter image description here

6

I'm not really sure if one would want to do this, but with the following implementation it will be easy to revert to a unique numbering scheme. The equation counter is changed inside the defn environment, so there's no need to change the coding style.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}

\usepackage{hyperref} % just to show it works also with it

\theoremstyle{definition}
\newtheorem{defninn}{Definition}

\newcounter{defcounter}

\makeatletter
\newenvironment{defn}
 {\global\chardef\dc@currentequation=\value{equation}%
  \let\c@equation\c@defcounter
  \renewcommand{\theequation}{D\arabic{equation}}%
  % comment the following line if you don't use hyperref
  \renewcommand{\theHequation}{D\arabic{equation}}%
  \defninn}
 {\enddefninn
  \setcounter{equation}{\dc@currentequation}}
\makeatother

\begin{document}

Bla bla
\begin{equation}
x = y
\end{equation}

\begin{defn}
bla bla
\begin{equation}\label{eq:one}
a = b
\end{equation}
\end{defn}

Bla bla
\begin{equation}
a = b \label{eq:two}
\end{equation}

\begin{defn}
bla bla
\begin{gather}
x = yz \label{eq:ga} \\
a = b \label{eq:gb}
\end{gather}
\end{defn}

Bla bla
\begin{equation}
1=1
\end{equation}

From equations \eqref{eq:one}~and~\eqref{eq:two} or
from equation~\eqref{eq:ga}, we deduce something.

\end{document}

enter image description here

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.