latex book文档类中 将chapter与section的计数器关联性取消
在book文档类中,chapter和section的计数器是默认关联的,即每次chapter计数器增加时,section计数器会重置为1。如果你想取消这种关联性,可以使用以下方法:
-
使用chngcntr宏包:在导言区添加
\usepackage{chngcntr},然后使用命令\counterwithout{section}{chapter}取消chapter与section的关联性。 -
使用titlesec宏包:在导言区添加
\usepackage{titlesec},然后使用命令\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{1em}{}取消chapter与section的关联性。
以下是一个示例代码:
\documentclass{book}
\usepackage{chngcntr} % 使用chngcntr宏包取消关联性
\counterwithout{section}{chapter} % 取消chapter与section的关联性
\begin{document}
\chapter{Chapter 1}
\section{Section 1}
\section{Section 2}
\chapter{Chapter 2}
\section{Section 1}
\section{Section 2}
\end{document}
运行上述代码,你会发现section的计数不会受到chapter的影响,而是连续递增的
原文地址: http://www.cveoy.top/t/topic/hYp1 著作权归作者所有。请勿转载和采集!