Math & Science ⇒ Enumerating equations
Enumerating equations
I have a simple question regarding Latex.
I tried many manuals but couldn't find the answer.
I am trying to write a document containing several sections, and in each there are equations.
I would like to number the equations with the number of sections, followed by a dot and then the equation number (e.g. 1.1, 1.2, 1.3, ..., 2.1, 2.2 etc.)
The thing is that I can't do it - I always get the equations numbered from 1 to the number of equations (1, 2, 3) regardless which section they are.
Can someone tell me what am I doing wrong?
Thanks
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Enumerating equations
From your description I assume that you are using the article class (or a similar one). You are nothing doing wrong. This is the way this class numbers equations. The amsmath package helps you to get your equations numbered as desired.
Code: Select all
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{amsmath}
\numberwithin{equation}{section}
\begin{document}
\section{Foo}
\begin{equation}\label{eqn:einstein}
E=mc^2
\end{equation}
\section{Bar}
\begin{subequations}\label{eqn:binomi}
\begin{align}
(a+b)^2&=a^2+2ab+b^2 \label{subeqn-1:binomi} \\
(a-b)^2&=a^2-2ab+b^2 \label{subeqn-2:binomi} \\
(a+b)(a-b)&=a^2-b^2 \label{subeqn-3:binomi}
\end{align}
\end{subequations}
\end{document}
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Enumerating equations
Thats just what was missing:
The \numberwithin command
Thanks again
Guy