6

Personally, I wanted to have "Eq." in front of the equation numbering. Also, I wanted to have the section numbering in front of the equation, so that the equations are numbered as (Eq. 3.1) instead of (1).

Anyone knows whether this is possible?

Mico
  • 506,678
Teun Zijp
  • 437

2 Answers2

7

You should look into loading the mathtools package (which, incidentally, automatically loads the amsmath package) and use its \newtagform and \usetagform macros.

\documentclass{article}
\usepackage{mathtools}
\numberwithin{equation}{section} % how the equation numbers are formed
\newtagform{show_eq}{(Eq.\ }{)}  % how the equation numbers are displayed
\usetagform{show_eq}

\begin{document}
\section{Introduction}
\begin{equation}
1+1=3?
\end{equation}
\begin{equation}
1+1\neq3
\end{equation}
\section{Some section or chapter without content...}
\section{Content!}
\begin{equation}
1+1=2
\end{equation}
\begin{equation}
1+2=3
\end{equation}
\end{document}

example of what it should look like

Teun Zijp
  • 437
Mico
  • 506,678
  • I tried it, it gives the exact same screenshot as what I had! :)) PS, can you maybe add the tag "equation-numbering"? – Teun Zijp Nov 29 '17 at 10:31
  • @TeunZijp - Thanks. I've gone ahead and added the 'labels' tag. – Mico Nov 29 '17 at 10:33
  • @TeunZijp - The output may indeed look the same. Going the \newtagform-\settagform route is slightly more robust, as these instructions may be run either before of after \numberwithin{equation}{section}; your solution, in contrast, requires a specific loading sequence. – Mico Nov 29 '17 at 10:35
1

It is possible!

I started from How to change equation numbering style, but this MWE should be sufficient to help you out.

\documentclass{article}
\usepackage{amsmath} % \numberwithin{equation} doesn't exist without this package.
\numberwithin{equation}{section} % This line resets equation numbering when starting a new section.
\renewcommand{\theequation}{Eq. \thesection.\arabic{equation}} % This line ads "Eq." in front of your equation numbering.
\begin{document}
\section{Introduction}
\begin{equation}
1+1=3?
\end{equation}
\begin{equation}
1+1\neq3
\end{equation}
\section{Some section or chapter without content...}
\section{Content!}
\begin{equation}
1+1=2
\end{equation}
\begin{equation}
1+2=3
\end{equation}
\end{document}

example of what it should look like

Unfortunately, the order of lines is crucial, because it is possible to override \renewcommand{\theequation}{Eq. \thesection.\arabic{equation}} with \numberwithin{equation}{section}, and you only get (1.1).

Note that if \numberwithin{equation}{section} is left out, equation numbering continues after opening a new section, so it numbers like (Eq. 1.1), (Eq. 1.2), (Eq. 3.3), (Eq. 3.4), which is awkward.

Teun Zijp
  • 437