如何在對開頁上的章節之前放置 minitoc?

如何在對開頁上的章節之前放置 minitoc?

我正在寫一本大書,使用 minitoc 在每章開頭放置一個小目錄。但看起來很糟。

我想把 minitoc 放在對頁上本章的第一頁。例如,如果第 9 章從第 503 頁開始,那麼我希望第 9 章的 minitoc 出現在第 502 頁。

我知道如何清除到偶數頁。問題是我該用什麼來代替\minitoc取得 minitoc下一個章節而不是目前章節?


相關問題:如何在章節頁的對頁放置正確編號的圖表?

答案1

您可以使用埃托克為此,透過目錄的標籤/引用機制。

\documentclass{book}

\usepackage{etoc}
\usepackage{blindtext}

\makeatletter
\newcommand*\cleartoevenpage {%
   \clearpage 
   \if@twoside \ifodd \c@page \hbox {}\newpage 
        \if@twocolumn \hbox {}\newpage \fi 
   \fi \fi }
\makeatother


\begin{document}


\tableofcontents


% switch to article like style for table of contents
% (else they will start like chapters on odd numbered pages)
% would need adjustment in two-column mode

\etocarticlestyle
\renewcommand*\etocbeforetitlehook {\cleartoevenpage}


\tableofcontents\ref{toc:first}

\chapter{First}
\invisiblelocaltableofcontents\label{toc:first}

\section{Foo}
\blindtext[2]

\subsection{FooFoo}
\blindtext[5]
\subsubsection{FooFooFoo}
\blindtext[5]

\section{Foo2}
\blindtext[3]

\subsection{FooFoo2}
\blindtext[7]
\subsubsection{FooFooFoo2}
\blindtext[7]


\tableofcontents\ref{toc:bar}
\chapter{Bar}
\invisiblelocaltableofcontents\label{toc:bar}

\section{Bar}
\blindtext[2]

\subsection{BarBar}
\blindtext[5]
\subsubsection{BarBarBar}
\blindtext[5]


\tableofcontents\ref{toc:ear}
\chapter{Ear}
\invisiblelocaltableofcontents\label{toc:ear}

\section{Ear}
\blindtext[2]

\subsection{EarEar}
\blindtext[5]
\subsubsection{EarEarEar}
\blindtext[5]

\section{Ear2}
\blindtext[3]

\subsection{EarEar2}
\blindtext[7]
\subsubsection{EarEarEar2}
\blindtext[7]


\tableofcontents\ref{toc:fur}
\chapter{Fur}
\invisiblelocaltableofcontents\label{toc:fur}

\section{Fur}
\blindtext[2]

\subsection{FurFur}
\blindtext[5]
\subsubsection{FurFurFur}
\blindtext[5]


\end{document}

截圖:

在此輸入影像描述

在此輸入影像描述

在此輸入影像描述

答案2

嗯,這是一個有點隱藏的功能,但minitoc提供了\adjustmtc命令,這意味著加星號的章節等,即 mtc 計數器關閉 1 的情況。

該命令可能被“濫用”來為下一章提供 minitoc。

\adjustmtc[n]指令記錄在目前 .NET 手冊的第 34 頁minitoc。可選參數保存minitocs要增加的數量(預設n=1

\documentclass{book}

\usepackage{minitoc}
\usepackage{blindtext}


\setcounter{minitocdepth}{3}
\setcounter{secnumdepth}{3}

\dominitoc

\begin{document}
\tableofcontents
\markboth{}{}
\clearpage
\adjustmtc
\minitoc
\chapter{First}

\section{Foo}
\blindtext[2]

\subsection{FooFoo}
\blindtext[5]
\subsubsection{FooFooFoo}
\blindtext[5]
\chapter{Foobar}
\end{document}

請注意:這些語句只是為了用一定數量的條目\setcounter...填充等——它們對於功能來說並不重要。minitoc

在此輸入影像描述

更新(帶有\cleartoevenpage來自`jfbu's 答案的一些代碼!)

現在它會自動工作,即在先前的偶數頁上\chapter新增。minitoc

\documentclass{book}

\usepackage{xparse}

\usepackage{minitoc}

\setcounter{tocdepth}{5}

\usepackage{blindtext}

\setcounter{minitocdepth}{3}
\setcounter{secnumdepth}{3}

\makeatletter
\let\latex@chapter\chapter

\newcommand*\cleartoevenpage {%
   \clearpage 
   \if@twoside \ifodd \c@page \hbox {}\newpage 
   \if@twocolumn \hbox {}\newpage \fi 
   \fi \fi 
 }

% Automatic addition of minitoc
\RenewDocumentCommand{\chapter}{som}{%
  \def\@@chaptertitlefortoc{#3}%
  \IfValueTF{#2}{%
    \def\@@chaptertitlefortoc{#2}%
  }%
  \IfBooleanTF{#1}{%
    \latex@chapter*{#3}
  }{%
    \cleartoevenpage
    \markboth{}{}%
    \ifnum\value{chapter} = 0
    \adjustmtc
    \fi
    \minitoc
    \latex@chapter[\@@chaptertitlefortoc]{#3}
  }
}



\makeatother

\dominitoc

\begin{document}
\tableofcontents
\chapter{First}

\section{Foo}
\blindtext[2]

\subsection{FooFoo}
\blindtext[5]
\subsubsection{FooFooFoo}
\blindtext[5]

\chapter{Foobar}
\blindtext[5]
\section{Foo}
\blindtext[5]


\chapter{Foobar other}
\blindtext[5]
\section{Other Foo}
\blindtext[5]

\end{document}

相關內容