7

Where is the full definition of the equation environment? I cannot find it in the .cls files. Is this in latex.ltx? Or something?

7

In texdoc source2e it starts on p214. It's in ltmath.dtx.

Here it is:

\@definecounter{equation}
\def\equation{$$\refstepcounter{equation}}
\def\endequation{\eqno \hbox{\@eqnnum}$$\@ignoretrue}
1
  • I'll try to mimic this piece of code to understand how it behaves. thanks – pluton Dec 12 '10 at 18:29
6

Yes, you can find it in latex.ltx. Seamus pointet you already to the source in ltmath.dtx and noted the three lines.

If you use equations, you very probably use the amsmath package because that's very recommendable for writing math texts. This package redefines the equation environment! It even defines a starred environment equation*.

So, if you use amsmath, you can find the definition of the equation environment in amsmath.sty:

\renewenvironment{equation}{%
  \incr@eqnum
  \mathdisplay@push
  \st@rredfalse \global\@eqnswtrue
  \mathdisplay{equation}%
}{%
  \endmathdisplay{equation}%
  \mathdisplay@pop
  \ignorespacesafterend
}
\newenvironment{equation*}{%
  \mathdisplay@push
  \st@rredtrue \global\@eqnswfalse
  \mathdisplay{equation*}%
}{%
  \endmathdisplay{equation*}%
  \mathdisplay@pop
  \ignorespacesafterend
}

Even \[ ... \] is redefined to use this equation*. For more information regarding the used macros look at amsmath.sty. Or just at latex.ltx, if you decide to to without amsmath.

2
  • I find it strange to see portions of code in latex.ltx, other portions, in cls files and some other in sty files. Thanks – pluton Dec 12 '10 at 18:31
  • @pluton: Why not - some are standard (latex.ltx) and available everywhere, some are for use only with a certain class (.cls) - chapter commands would be meaningless in articles, some are provided by packages (.sty) and can be used with any class you like - optionally. – Stefan Kottwitz Dec 12 '10 at 18:36

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.