Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I might be doing something stupid, but the following code produces a document with the first equation unnumbered (only an empty set of parentheses is given). The second equation is correctly numbered as 1.1.2. If I remove the change to \theequation, then everything is counted normally.

\documentclass[draft,fleqn,openany]{book}
\usepackage[tbtags]{amsmath}
\usepackage{amssymb}
\usepackage[no-math]{fontspec}
\usepackage{xkeyval}
\usepackage{polyglossia}
\setmainfont[BoldFont={* Bold},ItalicFont={* Italic},BoldItalicFont={* Bold Italic},SlantedFont={Linux Libertine Slanted O}]{Linux Libertine O}
\usepackage[letterpaper]{geometry}
\renewcommand{\theequation}{\numberwithin{equation}{section}}
\allowdisplaybreaks[1]
\setdefaultlanguage[variant=british]{english}
\begin{document}
\frontmatter
\title{A test document}
\author{AstroPig7}
\date{}
\maketitle
\tableofcontents
\mainmatter
\chapter{One}
Test document.
\section{Two}
Test document.
\begin{equation}
\text{Test.}
\end{equation}
\subsection{Three}
\begin{equation}
\text{Test.}
\end{equation}
\end{document}

I’ve also tried removing various non-essential declarations from the preamble with no success.

share|improve this question
    
Thank you for pointing out my moment of illiteracy. That did it. :) –  AstroPig7 Dec 7 '12 at 20:45
add comment

1 Answer 1

up vote 3 down vote accepted

amsmath's \numberwithin{<slave>}{<master>} does a couple of things. It:

  1. checks whether the counters <slave> and <master> exist. If they do, then it
  2. redefines the presentation of the <slave> counter to include the master using the format <master>.<slave>; and
  3. adds <slave> to the reset list of <master>. That is, <slave> will reset to 0 whenever <master> is incremented.

Here it is, in super high definition, from amsmath.sty:

\newcommand{\numberwithin}[3][\arabic]{%
  \@ifundefined{c@#2}{\@nocounterr{#2}}{%
    \@ifundefined{c@#3}{\@nocnterr{#3}}{%
      \@addtoreset{#2}{#3}%
      \@xp\xdef\csname the#2\endcsname{%
        \@xp\@nx\csname the#3\endcsname .\@nx#1{#2}}}}%
}

So, you would only need

\numberwithin{equation}{section}

to achieve what you're after.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.