我想在我的文档中有两个目录。第一个(主目录)应仅包含“附录 A:...”、“附录 B:...”等,并带有页码。
在附录中,我想要另一个目录,该目录告诉我哪些部分可用以及在哪一页上。
我在网上搜索过,但找不到任何匹配的东西。
我想我不是第一个用 LaTeX 尝试的人。
最好的开始方式是什么?
编辑:
我现在使用了 lockstep 的解决方案以及附加的\phantomsection
(关联)
现在我正在寻找
... 有可能一级标题在下面附录?
我认为目录和书签之间必须有分离。
答案1
您可以bookmarksdepth
\documentclass[toc=flat,numbers=noenddot]{scrartcl}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{hyperref}
\makeatletter
\newcommand*{\maintoc}{%
\begingroup
\@fileswfalse
\renewcommand*{\appendixattoc}{%
\value{tocdepth}=-10000%
}%
\tableofcontents%
\endgroup
}
\newcommand*{\appendixtoc}{
\begingroup
\edef\@alltocdepth{\the\value{tocdepth}}%
\setcounter{tocdepth}{-10000}%
\renewcommand*{\contentsname}{%
List of Appendices}%
\renewcommand*{\appendixattoc}{%
\setcounter{tocdepth}{\@alltocdepth}%
}%
\tableofcontents%
\setcounter{tocdepth}{\@alltocdepth}%
\endgroup
}
\newcommand*{\appendixattoc}{}%
\g@addto@macro\appendix{%
\clearpage%
\phantomsection%
\addcontentsline{toc}{section}{\appendixname}%
\addtocontents{toc}{\protect\appendixattoc}%
\renewcommand*{\thesection}{Appendix~\Alph{section}}%
}
\makeatother
\begin{document}
\maintoc
\blinddocument
\hypersetup{bookmarksdepth=-1}
\appendix
\pdfbookmark[-1]{Appendix}{appendixentry}
\appendixtoc
\hypersetup{bookmarksdepth=4}
\blinddocument
\end{document}
编辑:
您还可以修改级别的内部——这里我按照以下方式更改它们:
\g@addto@macro\appendix{%
\clearpage%
\phantomsection%
\addcontentsline{toc}{section}{\appendixname}%
\addtocontents{toc}{\protect\appendixattoc}%
\renewcommand*{\thesection}{Appendix~\Alph{section}}%
\def\toclevel@chapter{1}%0
\def\toclevel@section{2}%1
\def\toclevel@subsection{3}%2
\def\toclevel@subsubsection{4}%
\def\toclevel@paragraph{5}%
\def\toclevel@subparagraph{6}%
\def\toclevel@figure{7}%
\def\toclevel@table{8}%
}
结果是一样的:
\documentclass[toc=flat,numbers=noenddot]{scrartcl}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{hyperref}
\usepackage{bookmark}
\makeatletter
\newcommand*{\maintoc}{%
\begingroup
\@fileswfalse
\renewcommand*{\appendixattoc}{%
\value{tocdepth}=-10000%
}%
\tableofcontents%
\endgroup
}
\newcommand*{\appendixtoc}{
\begingroup
\edef\@alltocdepth{\the\value{tocdepth}}%
\setcounter{tocdepth}{-10000}%
\renewcommand*{\contentsname}{%
List of Appendices}%
\renewcommand*{\appendixattoc}{%
\setcounter{tocdepth}{\@alltocdepth}%
}%
\tableofcontents%
\setcounter{tocdepth}{\@alltocdepth}%
\endgroup
}
\newcommand*{\appendixattoc}{}%
\g@addto@macro\appendix{%
\clearpage%
\phantomsection%
\addcontentsline{toc}{section}{\appendixname}%
\addtocontents{toc}{\protect\appendixattoc}%
\renewcommand*{\thesection}{Appendix~\Alph{section}}%
\def\toclevel@chapter{1}
\def\toclevel@section{2}
\def\toclevel@subsection{3}
\def\toclevel@subsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@subparagraph{6}
\def\toclevel@figure{7}
\def\toclevel@table{8}
}
\makeatother
\begin{document}
\maintoc
\blinddocument
\appendix
\appendixtoc
\blinddocument
\end{document}
\appendix
编辑:改变了和的顺序\pdfbookmark
答案2
titletoc
以下是使用包(构建部分目录)、tocvsec2
包(控制tocdepth
主目录)和appendix
包(修改附录在主目录中出现的方式)的选项:
\documentclass{scrbook}
\usepackage{titletoc}
\usepackage{tocvsec2}
\usepackage[title,titletoc]{appendix}
\usepackage{hyperref}
\begin{document}
\hypersetup{bookmarksdepth=4}
\tableofcontents
\chapter{First regular chapter}
\section{Section one one}
\subsection{Subsection one one one}
\chapter{Second regular chapter}
\section{Section two one}
\subsection{Subsection two one one}
\begin{appendices}
\settocdepth{chapter}
\addtocontents{ptc}{\setcounter{tocdepth}{3}}
\chapter{First Appendix}
\startcontents[sections]
\printcontents[sections]{}{1}{}
\section{First section in appendix one}
\subsection{First subsection in appendix one one}
\subsubsection{First subsubsection in appendix one one one}
\section{Second section in appendix one}
\subsection{First subsection in appendix one two}
\stopcontents[sections]
\chapter{Second Appendix}
\startcontents[sections]
\printcontents[sections]{}{1}{}
\section{First section in appendix two}
\section{Second section in appendix two}
\stopcontents[sections]
\end{appendices}
\end{document}