What rules should be used if all theorems, figures, definitions, observations and lemmas are to use a continuous counter for the individual section only.
Asked
Active
Viewed 260 times
1
-
Each of these environments with its own counter? – Bernard Dec 18 '16 at 00:57
-
sorry @bernard, all one counter for each section – Sam Harper Dec 18 '16 at 01:00
1 Answers
2
You can define the figure counter to change with section and declare all your theorem structure to use the figure counter. If you want these counters to be prefixed by the section counter, use \counterwithin in the place of \counterwithin*.:
\documentclass[l]{article}
\usepackage{xcharter}
\usepackage[demo]{graphics}%
\usepackage{mathtools, chngcntr}
\counterwithin{figure}{section}
\usepackage{amsthm}
\newtheorem{thm}[figure]{Theorem}%
\newtheorem{lemma}[figure]{Lemma}
\theoremstyle{definition}
\newtheorem{defn}[figure]{Definition}
\begin{document}
\section{A first section}
\begin{defn}
A simple definition
\end{defn}
\begin{thm}
The following assertion is true: %
\[ a = a\]%
\end{thm}
\begin{figure}[!htbp]
\centering
\includegraphics{myfig}
\caption{A figure}\label{Afig}
\end{figure}
\begin{lemma}
The following assertion is true: %
\begin{equation}\label{testeq}
a = a\end{equation}
\end{lemma}
\section{Another lovely section}
\begin{defn}
A simple definition
\end{defn}
\begin{thm}
The following assertion is true: %
\[ b\,a = ba\]%
\end{thm}
\end{document}
barbara beeton
- 88,848
Bernard
- 271,350
-
how would you change this such that it was definition 1.1 for section 1 ect – Sam Harper Dec 18 '16 at 02:22
-
