# LaTeX numbering

One advantage of LaTeX over the other TeX-flavors is that it provides an automatic numbering of the sections, theorems, equations etc., together with an easy way to refer to these numbers.

The value of a counter can be changed with a command of the type


\setcounter{equation}{0}


One can achive the reseting of the equation counter at the beginning of each section and the inclusion of the section number in the equation numbering with the command

\numberwithin{equation}{section}


To add a label to any of the items which received a number, use

\label{label-name}


One can refer anywhere else in the text to it with one of the following:

\ref{label-name}
\eqref{label-name}
\pageref{label-name}


The meaning is the following:
• \ref gives the "number" to which the label refers,
• \eqref includes the "number" in parantheses,
• \pageref gives the page where the reference was created.

One can adjust the way items are numbered by re-defining some of the commands (the first example is essentially equivalent to \numberwithin{equation}{section}):


\renewcommand{\theequation}{\thesection.\arabic{equation}}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{(\alph{subsection})}


The \newtheorem command defines a new "theorem-like" environment. Its syntax is described below. Two arguments are required (as in the first form), the others are optional.

\newtheorem{env-name}{label-text}
\newtheorem{env-name}[other_env]{label-text}
\newtheorem{env-name}[other_env]{label-text}[within]


where:
• env-name is the name of the new environment
• label-text is the label printed (usually in bold) at the beginning (e.g., Theorem, Lemma, etc.)
• other_env is the environment whose numbering should be used by the env-name (e.g., you might want theorems and lemmas to be numbered in the same sequence)
• within is a counter (e.g., section); it indicates that the numbering should include this counter (and start from 1 each time this counter changes)
Here is an example of macros that define the way theorems etc. are numbered and presented:

\newtheorem{thm}{Theorem}[section]
\newtheorem{lemma}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{defn}[thm]{Definition}
\newtheorem{examp}[thm]{Example}
\newtheorem{conj}[thm]{Conjecture}
\newtheorem{rmk}[thm]{Remark}}


For more on variations of the fonts used, see this part in the Fancy Stuff Section.