正如标题所述,我想在每个新章节开头的小目录中列出该章节内的所有部分。请查看图片以了解详情。
答案1
假设你没有对章节标题的布局做任何其他事情,这对双胞胎可以很容易地做到这一点»标题安全“ 和 ”标题目录« 就像这种方法一样。
\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{blindtext} % drop in actual document
\titleformat{name=\chapter}[display]
{\normalfont\huge\bfseries}
{\chaptertitlename\ \thechapter}
{20pt}
{\Huge}
[\normalsize\normalfont\vspace*{1pc}%
\hbox{\large\bfseries\contentsname}\vspace{6pt}\titlerule\vspace{3pt}
\startcontents
\printcontents{l}{1}{\setcounter{tocdepth}{2}}\vspace{1pt}
\titlerule\vspace{1pc}]
\titleformat{name=\chapter,numberless}[display]
{\normalfont\huge\bfseries}
{}
{20pt}
{\Huge}
\setcounter{tocdepth}{0}
\begin{document}
\tableofcontents
\blinddocument % drop in actual document
\end{document}
另一种方法是使用 »米尼托克“。这将更接近屏幕截图上显示的布局。
\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{minitoc}
\usepackage{lipsum}
\dominitoc
\setcounter{minitocdepth}{3}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{0}
\begin{document}
\tableofcontents
\chapter{Heading on level 0 (chapter)}
\minitoc
\section{Heading on level 1 (section)}
\lipsum
\subsection{Heading on level 2 (subsection)}
\lipsum
\subsubsection{Heading on level 3 (subsubsection)}
\lipsum
\chapter{Heading on level 0 (chapter)}
\minitoc
\section{Heading on level 1 (section)}
\lipsum
\subsection{Heading on level 2 (subsection)}
\lipsum
\subsubsection{Heading on level 3 (subsubsection)}
\lipsum
\end{document}
另一种选择是相当新的 »埃托克«。
\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{etoc}
\usepackage{lipsum}
\newcommand*\chaptertoc{%
\setcounter{tocdepth}{3}%
\etocsettocstyle{%
\section*{\contentsname}\par%
\hrule\vspace{3pt}%
\setcounter{tocdepth}{2}%
}{\vspace{3pt}\hrule}%
\localtableofcontents
}
\begin{document}
\tableofcontents
\chapter{Heading on level 0 (chapter)}
\chaptertoc
\section{Heading on level 1 (section)}
\lipsum
\subsection{Heading on level 2 (subsection)}
\lipsum
\subsubsection{Heading on level 3 (subsubsection)}
\lipsum
\chapter{Heading on level 0 (chapter)}
\chaptertoc
\section{Heading on level 1 (section)}
\lipsum
\subsection{Heading on level 2 (subsection)}
\lipsum
\subsubsection{Heading on level 3 (subsubsection)}
\lipsum
\end{document}