1

I am writing a document that consists of several chapters and three appendices. The chapters are divided into sections, while the appendices are not: each one of the three is short enough not to be divided into sections. The global numbering of the results is section-wise in the whole document:

\documentclass[a4paper,10pt,twoside, DIV=9]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[english]{varioref}

\usepackage{amsmath,amssymb, amsthm, mathtools, amsfonts}


\theoremstyle{plain}
    \newtheorem{theorem}{Theorem}[section]
    \newtheorem{lemma}[theorem]{Lemma}
    \newtheorem{proposition}[theorem]{Proposition}
    \newtheorem{corollary}[theorem]{Corollary}
    
    \theoremstyle{definition}
    \newtheorem{definition}{Definition}[section]
    \newtheorem{example}{Example}[section]
    
    \theoremstyle{remark}
    \newtheorem{remark}{Remark}[section]

This creates the problem that the theorems in the appendix are numbered "Theorem A.0.2", "Proposition B.0.17" and so on, because Latex interprets the absence of sections as being in section zero of a chapter. These $0$'s have no meaning. I would like to get rid of them, or, in other word, to pass to a chapter-wise numbering of results, bust just in the appendices, converting the previous examples in "Theorem A.2" and "Proposition B.17" How can I do this?

(Before someone asks: no, I do not want to make the appendices into sections of a chapter, they have to stay separated and be chapters)

1 Answer 1

1

You can define \thetheorem conditionally depending on whether the current section number is positive.

\documentclass[a4paper,10pt,twoside, DIV=9]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[english]{varioref}

\usepackage{amsmath,amssymb, amsthm, mathtools, amsfonts}


\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

\renewcommand{\thetheorem}{%
  \ifnum\value{section}>0
    \thesection.%
  \else
    \thechapter.%
  \fi
  \arabic{theorem}%
}

\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newtheorem{example}{Example}[section]

\theoremstyle{remark}
\newtheorem{remark}{Remark}[section]

\begin{document}

\chapter{Title}
\section{Title}

\begin{theorem}
A theorem
\end{theorem}

\appendix

\chapter{Title of appendix}

\begin{theorem}
A theorem in the appendix
\end{theorem}

\end{document}

You may need to similarly define \thedefinition and \theexample, if you have definitions and examples in the appendix.

enter image description here

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .