Text FormattingNumbering theorem within chapter

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Numbering theorem within chapter

Post by localghost »

Hanneke wrote:Not sure if this is what you mean by an MWE, but however; [...]
What do you think was the link for?

According to the style declaration the counter of the »opgave« theorem like environment contains the section counter. So you have to use the \section command first to have a full enumeration for this environment.

Code: Select all

\documentclass[12pt,a4paper,dutch]{article} 
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts,amssymb,amsthm}

\theoremstyle{plain}                            
\newtheorem{opgave}{Opgave}[section]

\begin{document}
  \section{Secton One}
  \setcounter{opgave}{3}
  \begin{opgave}
    Show that  $|b| \leq a$ if and only if $ -a \leq b \leq a$. 
  \end{opgave}
\end{document}
The environment is numbered within a section thus the counter opgave is reset with every new \section command.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Hanneke
Posts: 8
Joined: Sun Feb 07, 2010 9:36 pm

Re: Setcounter

Post by Hanneke »

Ah, I didn't know I had to change the section as well, but actually it's quite logic. Thanks!

I've changed the enumerate, but the a4wide is a bit different from a4paper, sometimes I prefer a4wide, so why wouldn't I keep it? Most of my documents are for private use only.
Last edited by Hanneke on Sun Feb 07, 2010 11:29 pm, edited 1 time in total.
Hanneke
Posts: 8
Joined: Sun Feb 07, 2010 9:36 pm

Numbering theorem within chapter

Post by Hanneke »

localghost wrote:
Hanneke wrote:Not sure if this is what you mean by an MWE, but however; [...]
What do you think was the link for?
I read it, at least a bit. But I was expecting that an MWE would be made with a program or whatever. Since I couldn't find that on the page you directed my too, I thought that wouldn't be it, but I still was not sure wheter it was just my code. ;)
magicmoose
Posts: 90
Joined: Fri Nov 06, 2009 7:29 am

Numbering theorem within chapter

Post by magicmoose »

An MWE is a fully compilable document with only what is required to generate your error. Start with the full document you are working on and remove everything until the error goes away, then add the last bit you removed. Remove all packages that aren't used, all preamble (new commands etc. that aren't used) and everything between \begin{document} and \end{document} that you can without losing the error. This is a good example from gmedina
gmedina wrote:

Code: Select all

\documentclass[a4paper,12pt]{article} 
\usepackage{amsmath, amsfonts, amssymb, amsthm, amsrefs}
\usepackage[dutch]{babel}

\theoremstyle{plain}                            
\newtheorem{opgave}{Opgave}[section]

\begin{document}

\setcounter{section}{3}
\setcounter{opgave}{3}
\begin{opgave}
Show that  $|b| \leq a$ if and only if $ -a \leq b \leq a$. 
\end{opgave}

\end{document}
Hanneke
Posts: 8
Joined: Sun Feb 07, 2010 9:36 pm

Re: Setcounter

Post by Hanneke »

Thanks, next time, I will post that directly.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Numbering theorem within chapter

Post by localghost »

Hanneke wrote:[...] the a4wide is a bit different from a4paper, sometimes I prefer a4wide, so why wouldn't I keep it? Most of my documents are for private use only.
Obsolete packages and classes can cause trouble when used together with modern ones in one document. Searching the error may cost a lot of time then.
Post Reply