我如何更改章节编号?

我如何更改章节编号?

下面的代码编译了一个文档并且到目前为止它打印,例如:

定义1.1

例 1.1

例 1.2

推论1.1

但是我怎样才能将其更改为以下内容:

定义1.1

例 1.2

例 1.3

推论1.4

这是我目前正在使用的代码:

\documentclass[a4paper]{article}
\title{TITLE}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{mathtools,amssymb,amsthm}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{array}
\usepackage{calc}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}
\usepackage{titling}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{titling}
\usepackage{amsmath} % provides numberwithin (and lots more)
\usepackage{lipsum} 

\theoremstyle{plain}
\theoremstyle{definition}
\theoremstyle{remark}
\theoremstyle{plain}

\newtheorem{definition}{Definition}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\newtheorem{lemma}{Lemma}
\newtheorem{example}{Example}
\newtheorem*{axiom}{Axiom}
\newtheorem{exercise}{Exercise}

\numberwithin{definition}{section}
\numberwithin{theorem}{section}
\numberwithin{corollary}{section}
\numberwithin{lemma}{section}
\numberwithin{example}{section}

\begin{document}
\section{Section A}
\subsection{Subsection A}
\begin{definition}
blah blah
\begin{example}
blah blah
\end{example}
\subsection{Subsection B}
\subsection{Subsection C}
\subsection{Subsection D}
\subsection{Subsection E}
\section{Section B}
\subsection{Subsection A}
\end{document}

答案1

就在这里。请注意,您无需加载,amsmath因为mathtools它会为您完成:

\documentclass[a4paper]{article}
\title{TITLE}
 \usepackage[utf8]{inputenc}
 \usepackage[T1]{fontenc}
 \usepackage{textcomp}
\usepackage{mathtools,amssymb,amsthm}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{array}
\usepackage{calc}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}
\usepackage{titling}
\usepackage{enumitem}
\usepackage{hyperref}

\theoremstyle{definition}
\newtheorem{definition}{Definition}
\theoremstyle{plain} 
\newtheorem{theorem}[definition]{Theorem}
\newtheorem{corollary}[definition]{Corollary}
\newtheorem{lemma}[definition]{Lemma} 
\theoremstyle{remark} 
\newtheorem{example}[definition]{Example}
\newtheorem{exercise}[definition]{Exercise}
\newtheorem*{axiom}{Axiom}

 \numberwithin{definition}{section}

\begin{document}

\section{Section A}
\subsection{Subsection A}

\begin{definition} blah blah
\end{definition}
\begin{example} blah blah
\end{example}

\subsection{Subsection B}
\begin{theorem}
  A theorem. 
\end{theorem}

\subsection{Subsection C}

\subsection{Subsection D}

\subsection{Subsection E}

\section{Section B}

\subsection{Subsection A}

\end{document} 

在此处输入图片描述

相关内容