同じ目次を 2 回タイプセットする方法: 1 回目は深さ 0 で、2 回目は深さ 1 で

同じ目次を 2 回タイプセットする方法: 1 回目は深さ 0 で、2 回目は深さ 1 で

ある本に 4 つの章しかないとします。各章に途方もなく多くのセクション (たとえば 100 個) があるとします。この本の depth=0 の目次は 1 ページしか必要ありませんが、depth=1 の目次は 20 ページになります。

このような本の場合、2 つの連続した目次があると便利です。最初の目次では章のみを参照し、2 番目の目次では章をセクションに分割します。

どうすればこれができるでしょうか?

次の例では、2 番目の TOC が空白になります。

\documentclass{book}
\begin{document}

\setcounter{tocdepth}{0}
\tableofcontents

\setcounter{tocdepth}{1}
\tableofcontents

\chapter{One}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Two}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Three}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Four}
\section{a} \section{b} \section{c} \section{d} \section{e}

\end{document}

答え1

パッケージshorttoc

\documentclass{book}
\usepackage{shorttoc}
\begin{document}
\shorttableofcontents{\contentsname}{0}

\setcounter{tocdepth}{1}
\tableofcontents



\chapter{One}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Two}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Three}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Four}
\section{a} \section{b} \section{c} \section{d} \section{e}

\end{document}

使用できます\shorttoc{\contentsname}{0}

関連情報