etoc 包中的章节未出现在目录中

etoc 包中的章节未出现在目录中

我使用 etoc 包自定义 Tufte-book 文档类中的目录,其中包含部分、章节、节、参考书目、词汇表、索引和“片段索引”。我使用以下 MWE:

\documentclass[nobib,twoside,symmetric,justified,marginals=raggedouter]{tufte-book}


\usepackage{calc}
\usepackage{adjmulticol} 
\newlength{\rmarginW}
\setlength{\rmarginW}{\marginparwidth +\marginparsep}
\newcommand{\full}[1]{%    
    \begin{adjmulticols}{1}{0cm}{-\rmarginW}
        #1
\end{adjmulticols}}

\usepackage[backend=biber,style=authoryear-icomp]{biblatex}
\usepackage{glossaries}
\usepackage{imakeidx}
\makeindex[title=Index,columns=2]
\makeindex[name=piece,title={Index des \oe uvres},columns=2]

\usepackage{etoc}

\begin{document}
\chapter{Preface}
\chapter{Introduction}
\part{Part 1}
\chapter{First chapter}
\section{First section}
\section{second section}
\chapter{second chapter}

\part{Part 2}
\chapter{Third chapter}
\section{First section}
\section{second section}
\chapter{Fourth chapter}

\backmatter
\printbibheading[heading=bibintoc]

\begin{tcolorbox}[enhanced, breakable, colback=white, colframe=white, check odd page, toggle left and right, grow to right by=\marginparwidth+\marginparsep, toggle enlargement=evenpage]
\printbibliography[nottype=misc, heading=subbibintoc, title=Sources bibliographiques]
\printbibliography[type=misc, heading=subbibintoc, title= Sources internet]
\end{tcolorbox}

\clearpage
\full{\printglossaries}
\clearpage
\full{\printindex}
\clearpage
\printindex[piece]
\clearpage

\newcommand*{\DotsAndPage}
{\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
         \hfill\nobreak
         \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}
     
\etocsetstyle {part}
{\parindent 0pt
\nobreak
\etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\LARGE\rmfamily\bfseries\scshape\centering
\etocifnumbered{Partie \etocnumber{} - }{}\etocname\par}
{}

\etocsetstyle {chapter}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
\nobreak\medskip
\etocskipfirstprefix}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
\pagebreak[1]\smallskip}
{\normalsize\rmfamily\bfseries\scshape
\etocnumber. \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax }

\etocsetstyle {section}
{\leftskip1cm\rightskip .75cm \parfillskip 0pt plus 1fil\relax
\nobreak\smallskip}
{}
{\footnotesize\sffamily\mdseries\itshape
\etocname{} (p. \etocpage). }
{\par\medskip}


\etocsettagdepth {preamble} {none}
\etocsettagdepth {linestyles} {section}
\etocsettagdepth {globalcmds} {section}
\etocsettagdepth {custom} {none}
\full{\tableofcontents}

\end{document}

我不明白为什么目录中没有出现章节,以及附录的内容(参考书目、词汇表和 2 个索引)。如何纠正这些问题?

答案1

这是一个完整的工作示例

\documentclass[nobib,twoside,symmetric,justified,marginals=raggedouter]{tufte-book}

\usepackage{calc}
\usepackage{adjmulticol} 
\newlength{\rmarginW}
\setlength{\rmarginW}{\marginparwidth +\marginparsep}
\newcommand{\full}[1]{%    
    \begin{adjmulticols}{1}{0cm}{-\rmarginW}
        #1
\end{adjmulticols}}

\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage[backend=biber,style=authoryear-icomp]{biblatex}
\usepackage[toc]{glossaries}
\usepackage{imakeidx}
%\usepackage{tocbibind}
\makeindex[title=Index,columns=2,intoc]
\makeindex[name=piece,intoc,title={Index des \oe uvres},columns=2]

\usepackage{etoc}

\begin{document}
\chapter{Preface}
\chapter{Introduction}
\part{Part 1}
\chapter{First chapter}
\section{First section}
\index{Test} Test
\section{second section}
\chapter{second chapter}

\part{Part 2}
\chapter{Third chapter}
\section{First section}
\section{second section}
\chapter{Fourth chapter}

\backmatter
\printbibheading[heading=bibintoc]

\begin{tcolorbox}[enhanced, breakable, colback=white, colframe=white, check odd page, toggle left and right, grow to right by=\marginparwidth+\marginparsep, toggle enlargement=evenpage]
\printbibliography[nottype=misc, heading=subbibintoc, title=Sources bibliographiques]
\printbibliography[type=misc, heading=subbibintoc, title= Sources internet]
\end{tcolorbox}

\clearpage
\full{\printglossaries}
\clearpage
\full{\printindex}
\clearpage
\printindex[piece]
\clearpage

\newcommand*{\DotsAndPage}
{\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
         \hfill\nobreak
         \makebox[\rightskip][r]{\bfseries\normalsize\etocpage}\par}
     
\etocsetstyle {part}
{\parindent 0pt
\nobreak
\etocskipfirstprefix}
{\pagebreak[3]\bigskip}
{\LARGE\rmfamily\bfseries\scshape\centering
\etocifnumbered{Partie \etocnumber{} - }{}\etocname\par}
{}

\etocsetstyle {chapter}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
\nobreak\medskip
\etocskipfirstprefix}
{\leftskip 0pt \rightskip .75cm \parfillskip-\rightskip
\pagebreak[1]\smallskip}
{\normalsize\rmfamily\bfseries\scshape
\etocnumber. \etocname\DotsAndPage }
{\parfillskip 0pt plus 1fil\relax }

\etocsetstyle {section}
{\leftskip1cm\rightskip .75cm \parfillskip 0pt plus 1fil\relax
\nobreak\smallskip}
{}
{\footnotesize\sffamily\mdseries\itshape
\etocname{} (p. \etocpage). }
{\par\medskip}

\etocsettagdepth {preamble} {none}
\etocsettagdepth {linestyles} {section}
\etocsettagdepth {globalcmds} {section}
\etocsettagdepth {custom} {none}
\setcounter{tocdepth}{1}

\full{\tableofcontents}

\end{document}

原始答案

要获取目录中的章节,请使用

\setcounter{tocdepth}{1}
or
\etocsettocdepth{section}

要获取目录中的参考书目和索引,您可以使用

\usepackage{tocbibind}

或者在\makeindex命令上使用intoc选项

\makeindex[title=Index,columns=2,intoc]

对于词汇表,使用

\usepackage[toc]{glossaries}

顺便说一下,在所有常规章节之后,以及参考书目等开始之前,使用

\backmatter

我认为这应该涵盖大部分或全部缺失的条目。

相关内容