下面是一个 MWE,当我取消注释加载tocloft
包的行时,它会在 minitoc 中显示页码。除了设置之外,如何防止这种情况\mtcsetpagenumbers{minitoc}{off}
?
\documentclass{book}
%\usepackage[titles]{tocloft}
%\makeatletter
%\def\l@subsubsection#1#2{{\let\numberline\@gobble{\sffamily\small #1~[#2]}}}
%\makeatother
\usepackage{minitoc} % Mini-ToCs with loose line spacing
\setcounter{minitocdepth}{2}
\mtcsettitle{minitoc}{} % for empty title
\mtcsetpagenumbers{minitoc}{off} % turn off page numbering in minitocs
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\begin{document}
\dominitoc
\tableofcontents
{\let\clearpage\relax \chapter{Chapter title}}
\minitoc
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\end{document}
此外,如果我取消注释周围的上下文\def\l@subsubsection#1#2
(以实现类似于microtype
手册中的紧凑目录;行是从那里复制的),即使 ,minitoc 也会显示子部分minitocdepth=2
。
答案1
看起来,当首先加载 tocloft 时,minitoc 会延迟,而\l@section
当之后加载时,tocloft 会发生变化等等。
顺便说一句,\l@subsection
应该检查\value{tocdepth}
,而你的(注释掉的)替换却没有。
\documentclass{book}
\usepackage{minitoc} % Mini-ToCs with loose line spacing
\setcounter{minitocdepth}{2}
\mtcsettitle{minitoc}{} % for empty title
\mtcsetpagenumbers{minitoc}{off} % turn off page numbering in minitocs
\makeatletter
\let\normal@section=\l@section
\let\normal@subsection=\l@subsection
\makeatother
\usepackage[titles]{tocloft}
\makeatletter
\let\l@section=\normal@section
\let\l@subsection=\normal@subsection
\makeatother
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\begin{document}
\dominitoc
\tableofcontents
{\let\clearpage\relax \chapter{Chapter title}}
\minitoc
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\end{document}