5

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}
\begin{equation}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}
x^3 + y^3 \neq z^3
\end{equation}

\section{Next}
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\begin{equation}
\sqrt{-1} = - \sqrt{-1}
\end{equation}

\end{document}
6

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.

So you can add to your preamble:

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

Solution:

enter image description here

MWE:

\documentclass{report}
\usepackage{amsmath}

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

\chapter{First}
\begin{equation}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}
x^3 + y^3 \neq z^3
\end{equation}

\section{Next}
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\begin{equation}
\sqrt{-1} = - \sqrt{-1}
\end{equation}

\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. – Oscar Feb 6 '18 at 22:39
  • 1
    @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. – Bobyandbob Feb 7 '18 at 15:32

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.