I would like to number equations in the following way:

Chapter 1

x^2 + y^2 = z^2 (1.1)

x^3 + y^3 \neq z^3 (1.2)

Section 1.1

a^2 + b^2 = c^2 (1.1.1)

\sqrt{-1} = - \sqrt{-1} (1.1.2)

etc.

Currently the best I can achieve is to have (1.0.1), (1.0.2), etc., before the first section in the chapter. Aesthetically I find the unnecessary 0's quite ugly. Is there a way to tidy it up?

MWE:

\documentclass{report}
\numberwithin{equation}{section}
\begin{document}

\chapter{First}
$$x^2 + y^2 = z^2$$
$$x^3 + y^3 \neq z^3$$

\section{Next}
$$a^2 + b^2 = c^2$$
$$\sqrt{-1} = - \sqrt{-1}$$

\end{document}


If the section counter is zero ... -> The additional level of chapter can be suppressed. Similar to https://tex.stackexchange.com/a/245988/124842 for sections.

You nedd \usepackage{amsmath} package for MWE.

\numberwithin{equation}{section}
\renewcommand*{\theequation}{%
\ifnum\value{section}=0 %
\thechapter
\else
\thesection
\fi
.\arabic{equation}%
}


Solution:

MWE:

\documentclass{report}
\usepackage{amsmath}

\numberwithin{equation}{section}
\renewcommand*{\theequation}{%
\ifnum\value{section}=0 %
\thechapter
\else
\thesection
\fi
.\arabic{equation}%
}
\begin{document}

\chapter{First}
$$x^2 + y^2 = z^2$$
$$x^3 + y^3 \neq z^3$$

\section{Next}
$$a^2 + b^2 = c^2$$
$$\sqrt{-1} = - \sqrt{-1}$$

\end{document}

• Hi, How can you do the same, but in my case I want the numbering to be different in the appendix. for example I have in the chapter the equation (1.2.3), in the appendix I want (A.1), (A.2), etc independently on the section. Feb 6, 2018 at 22:39
• @Oscar .My first guess is something like : \renewcommand{\thechapter}{A.\arabic{chapter}} after \appendix. Does it fit your problem? - General: If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. Feb 7, 2018 at 15:32