Text FormattingSection numbering for amsthm theorem numbering

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
rschley
Posts: 3
Joined: Thu Apr 24, 2014 3:06 am

Section numbering for amsthm theorem numbering

Post by rschley »

I am writing chapters as individual LaTeX documents. For example, Chapter 8 is its own file. Within each chapter, I want to number the theorems [chapter number.theorem number] (e.g., 8.1, 8.2, etc.). Because each chapter is its own file, I am unable to use sections to create decimal forms of theorem numbers using amsthm.

In the code below, my goal is to have Theorem 8.1, not 1.8. I've been searching and trying different things, but haven't had any luck on my own. Any help is greatly appreciated.

Code: Select all

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{framed}
\colorlet{shadecolor}{gray!50}
\newtheorem{theorem}{Theorem}[section]
\newenvironment{theo}
  {\begin{shaded}\begin{theorem}}
  {\end{theorem}\end{shaded}}

\begin{document}

\section{Section 8}

\setcounter{theorem}{7}

\begin{theo}
Some important theorem.
\end{theo}

\end{document}

Recommended reading 2024:

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

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Section numbering for amsthm theorem numbering

Post by Johannes_B »

I think i am not quite getting what you want to achieve, because at the moment the solution seems more than obvious to me.

Code: Select all

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{framed}
\colorlet{shadecolor}{gray!50}
\newtheorem{theorem}{Theorem}[section]
\newenvironment{theo}
  {\begin{shaded}\begin{theorem}}
  {\end{theorem}\end{shaded}}

\begin{document}
\setcounter{section}{7}
\section{Section 8}
%\setcounter{theorem}{7}
\begin{theo}
Some important theorem.
\end{theo}

\end{document}
It seems to me, that report (or even better scrreprt) might be a better documentclass for you. Maybe even book (scrbook). You can still input (or \include) all the different chapters on their own.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
rschley
Posts: 3
Joined: Thu Apr 24, 2014 3:06 am

Section numbering for amsthm theorem numbering

Post by rschley »

Thank you, Johannes_B. As you suggested, once I calmed down the answer was simple and obvious. The code below inserts a page of dummy sections, but the theorem on the second page begins numbering at 8.1, which is what I wanted. The number of dummy sections forces the incrementation of the leftmost digit.

I know I'm not explaining myself very well, but hopefully the code below showing my result helps clarify what I was asking for in my initial post.

Code: Select all

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{framed}
\colorlet{shadecolor}{gray!50}
\newtheorem{theorem}{Theorem}[section]
\newenvironment{theo}
  {\begin{shaded}\begin{theorem}}
  {\end{theorem}\end{shaded}}

\begin{document}
\section{ }\section{ }\section{}\section{}\section{ }\section{ }\section{}\section{}
\newpage

\begin{theo}
Some important theorem.
\end{theo}

\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Section numbering for amsthm theorem numbering

Post by Johannes_B »

Is your question answered now?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
rschley
Posts: 3
Joined: Thu Apr 24, 2014 3:06 am

Re: Section numbering for amsthm theorem numbering

Post by rschley »

Yes, my question is answered.
Post Reply