答案1
看起来比我想象的要容易:
\documentclass{scrbook}
\usepackage{etoc, blindtext}
\newcommand{\chaptertoc}[1][Chaptertoc]{%
\etocsettocstyle{\addsec*{#1}}{}%
\localtableofcontents%
}
\begin{document}
\chapter{First Chapter}
\label{CLA:first-chapter}
\chaptertoc{}
\bigskip{}
\blindtext
\section{First section in first chapter}
\label{CLA:first-section-first}
\blindtext
\section{Second section in first chapter}
\label{CLA:second-section-first}
And this section even has subsections:
\blindtext{}
\subsection{First subsec in second sec of first chapter}
\label{CLA:first-subsec-second}
\blindtext{}
\subsection{You know how to proceed}
\label{CLA:you-know-how}
\blindtext{}
\end{document}
首先,我尝试找出如何在没有 etoc 包的情况下做到这一点,因为 KOMAscript 包中的 tocbasic 包肯定提供了这种机制。但是,使用 etoc 似乎相当容易。
答案2
@aerious 使用@keks-dose 提供的代码,您唯一需要做的更改就是在第四行添加命令。
像这样,
\documentclass{scrbook}
\usepackage{etoc, blindtext}
\newcommand{\chaptertoc}[1][Chaptertoc]{%
\etocsettocstyle{\addsec*{#1\\\rule{\textwidth}{0.4pt}}}{}%}{}%<---- NOTE HERE THE CHANGE,
%%%%TO ADD THE RULE.
\localtableofcontents%
}
\begin{document}
\chapter{First Chapter}
\label{CLA:first-chapter}
\chaptertoc{}
\bigskip{}
\blindtext
\section{First section in first chapter}
\label{CLA:first-section-first}
\blindtext
\section{Second section in first chapter}
\label{CLA:second-section-first}
And this section even has subsections:
\blindtext{}
\subsection{First subsec in second sec of first chapter}
\label{CLA:first-subsec-second}
\blindtext{}
\subsection{You know how to proceed}
\label{CLA:you-know-how}
\blindtext{}
\end{document}