\documentclass[UTF8]{article}\usepackage{ctex}\makeatletter\let\orig@section\section\renewcommand\section{@ifstar{\star@section}{@dblarg\nostar@section}}\newcommand{\star@section}[2][]{%\ifnum\value{section}=0\stepcounter{chapter}\fi\orig@section*{#2}}\def\nostar@section[#1]#2{%\ifnum\value{section}=0\stepcounter{chapter}\fi\orig@section[#1]{#2}}\makeatother\begin{document}\tableofcontents\chapter*{第一章}\addcontentsline{toc}{chapter}{第一章}\section{第一节}\section{第二节}\chapter*{第二章}\addcontentsline{toc}{chapter}{第二章}\section{第一节}\section{第二节}\setcounter{section}{0} % 将section计数器重置为0\section{附录}\end{document}

LaTeX 文档类中使用 \chapter 作为 \section 的上一级,并在目录中显示 \chapter,但 \section 不以 \chapter 的计数器为父计数器,如何实现?

原文地址: https://www.cveoy.top/t/topic/pHdB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录