如何实现\chapter随\part的编号增加而清零重新编号

2019-09-16 21:22发布

如何实现\chapter随\part的编号增加而清零重新编号 MWE如下: ``` \documentclass{ctexbook} \usepackage{hyperref} \begin{docu...

如何实现\chapter随\part的编号增加而清零重新编号 MWE如下: ``` \documentclass{ctexbook} \usepackage{hyperref} \begin{document} \part{} \chapter{} \part{} \chapter{} \end{document} ``` 想实现这样的效果 ``` 第一部分 第一章 第二部分 第一章 ```
2条回答
建议给 ctexbook 添加 openany 选项减少空页。 解决方法: ```tex \documentclass[openany]{ctexbook} \usepackage{hyperref} \usepackage{chngcntr} \counterwithin{chapter}{part} \begin{document} \part{Hello} \chapter{Elegant\LaTeX{}} \part{World} \chapter{Program} \end{document} ``` 和另外一种方法 ```tex \makeatletter \@addtoreset{chapter}{part} \makeatother ``` 是等价的,推荐前者。 参考:[How to reset chapter and section counter with \part](https://tex.stackexchange.com/questions/54383/how-to-reset-chapter-and-section-counter-with-part)

回答: 2019-09-16 21:46

如果是 ElegantBook 模板,请使用 ```tex \makeatletter \@addtoreset{chapter}{part} \makeatother ``` 原因是模板修改过 `\partname`,导致两种方法并不等价。

一周热门 更多>

相关问答