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?

lockstep
  • 250,273
pluton
  • 16,421

2 Answers2

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}
Seamus
  • 73,242
7

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.

Stefan Kottwitz
  • 231,401
  • 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
  • 1
    @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