使用minitoc
包中的scrartcl
我想仅为附录及其内容创建目录。我的代码运行,但我无法仅为附录的内容在附录中创建目录。最小示例:
\documentclass[]{scrartcl}
\KOMAoption{listof}{totoc}
\usepackage{minitoc}
\begin{document}
\dosecttoc
\tableofcontents
\section{Hello}
\appendix
\section{Appendix}
\secttoc
\dosecttoc
\end{document}
答案1
附录中没有子节。如果我添加子节,则会在附录中得到目录:
例子:
\documentclass[]{scrartcl}
\KOMAoption{listof}{totoc}
\usepackage{minitoc}
\begin{document}
\dosecttoc
\tableofcontents
\section{Hello}
\appendix
\section{Appendix}
\secttoc
\dosecttoc
\subsection{Foo}% <- added
\subsection{Bar}% <- added
\KOMAScriptVersion
\end{document}
但不建议将该包minito
与KOMA-Script 类一起使用。
建议在主目录中仅包含“附录”:
\documentclass{scrartcl}
\KOMAoption{listof}{totoc}
\DeclareNewTOC[%
owner=\jobname,
listname={\contentsname},
setup=leveldown
]{atoc}
\makeatletter
\newcommand*{\useatocs}{%
\renewcommand*{\ext@toc}{atoc}%
\scr@ifundefinedorrelax{hypersetup}{}{% maybe you use hyperref and bookmarks
\hypersetup{bookmarkstype=atoc}%
}%
}
\makeatother
\begin{document}
\tableofcontents
\section{Hello}
\appendix
\section{Appendix}
\useatocs
\listofatocs
\subsection{Foo}
\subsection{Barg}
\end{document}
包含完整主要目录的建议:
\documentclass{scrartcl}
\KOMAoption{listof}{totoc}
\usepackage{scrwfile}
\TOCclone[{\contentsname}]{toc}{atoc}
\setuptoc{atoc}{leveldown}
\addtocontents{atoc}{\protect\value{tocdepth}=-2}
\newcommand*{\useatoc}{%
\addtocontents{atoc}{\protect\value{tocdepth}=\subsubsectiontocdepth}%
}
\begin{document}
\tableofcontents
\section{Hello}
\appendix
\section{Appendix}
\useatoc
\listofatoc
\subsection{Foo}
\subsection{Bar}
\end{document}
答案2
所以,解决方案来了。而不是minitoc
使用titletoc
,事情就会好起来:
\documentclass[]{scrartcl}
\usepackage{titletoc}
\newcommand\DoToC{%
\startcontents
\printcontents{}{2}{\textbf{Contents}\vskip3pt\hrule\vskip5pt}
\vskip3pt\hrule\vskip5pt
}
\begin{document}
\section{Hello}
\newpage
\appendix
\section{Appendix}
\DoToC
\subsection{goodnight}
\subsection{goodmourning}
\end{document}
放置以下物品很重要:
%toc for appendix only:
\usepackage{titletoc}
\newcommand\DoToC{%
\startcontents
\printcontents{}{2}{\textbf{Contents}\vskip3pt\hrule\vskip5pt}
\vskip3pt\hrule\vskip5pt
}
否则{scrartcl}
,目录将包含放错位置toc
的