在以下示例中,我修改了回忆录类中各节的编号,以便我可以使用“节”作为“章节”。这使得它们在目录中显示得很好。但是,和的编号\label
差\ref
了一个。可以在不大量修改代码的情况下修复此问题吗?
\documentclass[article, a4paper, 12pt, oneside]{memoir}
\setlrmarginsandblock{23mm}{63mm}{*}
\setulmarginsandblock{23mm}{28mm}{*}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{1mm}{*}
\chapterstyle{plain}
\checkandfixthelayout
\setsecnumformat{\addtocounter{section}{-1} \addtocounter{chapter}{1}}
\renewcommand*\thesection{\arabic{chapter}}
\begin{document}
\tableofcontents
\section{Introduction} \label{beginning}
Beginning. Just wait til you see the end, that's in Chapter \ref{end}.
\section{Conclusion} \label{end}
End. Hopefully you read the beginning! (Chapter \ref{beginning})
\end{document}
答案1
无需使用计数器。如果您只需要“提升”部分,则以下方法有效:
\documentclass[article, a4paper, 12pt, oneside]{memoir}
\setlrmarginsandblock{23mm}{63mm}{*}
\setulmarginsandblock{23mm}{28mm}{*}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{1mm}{*}
% \chapterstyle{plain} % needed?
\checkandfixthelayout
\renewcommand{\thesection}{\arabic{section}}
\makeatletter
\let\l@section\l@chapter
\makeatother
\begin{document}
\tableofcontents
\section{Introduction} \label{beginning}
Beginning. Just wait til you see the end, that's in Chapter \ref{end}.
\section{Conclusion} \label{end}
End. Hopefully you read the beginning! (Chapter \ref{beginning})
\end{document}
如果你还必须推广子部分,那么
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\makeatletter
\let\l@subsection\l@section
\let\l@section\l@chapter
\makeatother
该策略是将目录中的条目用作上级设置(因此我们必须从下往上进行操作)。宏
\l@<sectional unit>
负责排版该部门单位的目录条目。
当然\tableofcontents*
应该使用,以避免目录本身就列出来,这无论如何都没有什么意义。
答案2
如果您只想更改目录中章节条目的格式,memoir 为您提供了内置命令,可轻松执行此操作,而无需重新定义计数器,也不会更改章节单元的“自然”含义:
\documentclass[article, a4paper, 12pt, oneside]{memoir}
\setlrmarginsandblock{23mm}{63mm}{*}
\setulmarginsandblock{23mm}{28mm}{*}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{1mm}{*}
\chapterstyle{plain}
\checkandfixthelayout
\cftsetindents{chapter}{1.5em}{2.3em}
\renewcommand\cftchapterfont{\normalfont}
\renewcommand\cftchapterleader{\cftdotfill{\cftsectiondotsep}}
\renewcommand\cftchapterpagefont{\normalfont}
\renewcommand\cftchapterafterpnum{\par\vskip-10pt}
\begin{document}
\tableofcontents*
\chapter{Introduction} \label{beginning}
Beginning. Just wait til you see the end, that's in Chapter \ref{end}.
\chapter{Conclusion} \label{end}
End. Hopefully you read the beginning! (Chapter \ref{beginning})
\end{document}