I'm writing a thesis as a collection of different articles. I'm treating each article as a chapter. The first article has Equations numbering A.1, A.2 etc and the second article has equation numbering B.1, B.2 etc. For some unknown reason, now when I compile the thesis, the equations in Article B has numbers as B.2.1, B.2.2 where the middle 2 is the section number. I want to have B.1 and B.2 as before. Why is LaTeX now including the section number in the equation numbering?
Any help would be highly appreciated.
Thanks a lot…
Update: I still have problems after "mpg" answer. The problem is that in my Article 2, the equation numbers are reset at each main section so that I have in Section B.1 equations B.1, B.2 etc and in Section B.2 I get equation numbers B.1 , B.2 again instead of B.3 and B.4. The equation numbers from Article 1 is fine though. I'm attaching a minimal example. Here is the main document (save as main.tex):
\documentclass[fleqn,a4paper,openany,twoside,11pt]{book}
\usepackage[latin1]{inputenx}
\usepackage[OT1]{fontenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{cite}
\usepackage{fancyhdr}
\usepackage{chapterbib}
\parfillskip 0pt plus 0.75\textwidth
\renewcommand\chaptername{Paper}
\renewcommand{\thechapter}{\Alph{chapter}}
\setcounter{secnumdepth}{4}
\pagestyle{empty}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[LE,RO]{\bfseries{\thepage}}
\renewcommand{\headrulewidth}{0.6pt}
\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}
\begin{document}
%\clearemptydoublepage
\newpage{\pagestyle{empty}\cleardoublepage\pagenumbering{roman}}
\setcounter{page}{3}
\clearemptydoublepage
\begingroup
\renewcommand{\appendix}{%
\par
\setcounter{section}{0}%
\renewcommand{\thesection}{\thechapter.\Alph{section}}%
}
\include{paper1}
\endgroup
\begingroup
\renewcommand{\appendix}{%
\par
\setcounter{section}{0}%
\renewcommand{\thesection}{\thechapter.\Alph{section}}%
}
\include{paper2}
\endgroup
\end{document}
Here is paper 1 (article 1)…save as paper1.tex :
\chapter{\huge \bfseries My paper A}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhead[LO]{\scriptsize \bfseries\rightmark}
\fancyhead[CE]{\scriptsize \bfseries{Paper A}}
\section{Modelling}
\subsection{Simulating}
bla bla bla bla bla blabla blabla blabla blabla blabla blabla blabla blabla bla
bla blabla blabla blabla blabla blabla blabla bla
\begin{equation}\label{eq:eqmotion}
\begin{bmatrix}
m & 0 \\
0 & m
\end{bmatrix}
=
\begin{pmatrix}
F \thinspace \cos \omega_{f} \thinspace t \\
F \thinspace \sin \omega_{f} \thinspace t
\end{pmatrix}
\end{equation}
\section{experiment}
bla bla bla bla bla blabla blabla blabla blabla blabla blabla blabla blabla bla
bla blabla blabla blabla blabla blabla blabla bla
\begin{equation}\label{eq:eqmotion2}
\begin{bmatrix}
m & 0 \\
0 & m
\end{bmatrix}
=
\begin{pmatrix}
F \thinspace \cos \omega_{f} \thinspace t \\
F \thinspace \sin \omega_{f} \thinspace t
\end{pmatrix}
\end{equation}
\appendix
\numberwithin{equation}{section}
\section{force coefficients}
\subsection{second force}
The coefficients of bla bla
\begin{align}
A_{0} & = 15 \nonumber \\
B_{1} & = 1
\end{align}
\subsection{first force}
\begin{align}
A_{0} & = 14 \nonumber \\
B_{1} & = 2
\end{align}
And paper2 (article 2)…….save as paper2.tex :
\chapter{\huge \bfseries My paper B}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhead[LO]{\scriptsize \bfseries\rightmark}
\fancyhead[CE]{\scriptsize \bfseries{Paper B}}
\numberwithin{equation}{chapter}
\section{Modelling}
\subsection{Simulating}
bla bla bla bla bla blabla blabla blabla blabla blabla blabla blabla blabla bla
bla blabla blabla blabla blabla blabla blabla bla
\begin{equation}\label{eq:beqmotion}
\begin{bmatrix}
m & 0 \\
0 & m
\end{bmatrix}
=
\begin{pmatrix}
F \thinspace \cos \omega_{f} \thinspace t \\
F \thinspace \sin \omega_{f} \thinspace t
\end{pmatrix}
\end{equation}
\section{experiment}
bla bla bla bla bla blabla blabla blabla blabla blabla blabla blabla blabla bla
bla blabla blabla blabla blabla blabla blabla bla
\begin{equation}\label{eq:beqmotion2}
\begin{bmatrix}
m & 0 \\
0 & m
\end{bmatrix}
=
\begin{pmatrix}
F \thinspace \cos \omega_{f} \thinspace t \\
F \thinspace \sin \omega_{f} \thinspace t
\end{pmatrix}
\end{equation}
\appendix
\numberwithin{equation}{section}
\section{force coefficients}
\subsection{second force}
The coefficients of bla bla
\begin{align}
A_{0} & = 15 \nonumber \\
B_{1} & = 1
\end{align}
\subsection{first force}
\begin{align}
A_{0} & = 14 \nonumber \\
B_{1} & = 2
\end{align}
On compiling the main document (with paper1.tex and paper2.tex in the same folder as main.tex), you will note that in paper B (article 2) in section B.2, the equation numbering starts as B.1 again..which is wrong. It should be B.2. What am I doing wrong?
Thanks a lot…
Best Answer
Looks like
\numberwithin
is not meant to be used the way you are trying to use it. (I'm surprised too!) The problem is that it essentially does two things:\renewcommand*\the<slave counter>{\the<master counter>.\arabic{slave counter}}
\@addtoreset{<slave counter>}{<master counter>}
The second one is what change the numbering. Notice that it is "addtoreset". Which means that it will make the increment operation on the master counter trigger a reset of the slave counter. So after calling
\numberwithin{equation}{section}
, the trigger has been laid. And a second call of\numberwithin{equation}{chapter}
does not remove the previous trigger. Therefore theequation
counter will still be reset everytime thesection
counter increases.So much for why it does what you see that it does. For a solution, clearly you must stop using the convenient
\numberwithin
command. A substitute is the\counterwithin
and\counterwithout
commands provided by thechngcntr
package.So you should define, in your preamble, the following commands:
And call
\startappendixeqnumbering
before the first appendix and\startnormaleqnumbering
after the last appendix, before the start of the next chapter.