我想完成一份带有附件的文档。因此,对于第一个文档,目录是正确的,但第二个文档(将包含在第一个文档的末尾)的目录为空,如下例所示:
\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\begin{document}
\sffamily
\tableofcontents
\section{Document 1} % (fold)
\label{sec:document_1}
\section{Document 1} % (fold)
\label{sec:document_2}
\subsection{Subsection document 1} % (fold)
\label{sub:subsection_document_1}
a
\tableofcontents
%========HERE THE TOC OF THE SECOND DOC SHOULD APPEAR and from here this will be the content of the second doc
\section{Document 2.1} % (fold)
\label{sec:document_2_1}
\subsection{Subsection document 2}
\section{Document 2.2} %
\end{document}
答案1
如果要添加部分,可以使用 minitoc 包来显示每个部分的目录:
\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{minitoc}%
\doparttoc% Prepare minitoc package for part tocs usage
\begin{document}
\sffamily
\faketableofcontents
\part{Document 1}
\parttoc
\section{Document 1} % (fold)
\label{sec:document_1}
\section{Document 1} % (fold)
\label{sec:document_2}
\subsection{Subsection document 1} % (fold)
\label{sub:subsection_document_1}
a
\part{Document 2}
\parttoc
%========HERE THE TOC OF THE SECOND DOC SHOULD APPEAR and from here this will be the content of the second doc
\section{Document 2.1} % (fold)
\label{sec:document_2_1}
\subsection{Subsection document 2}
\section{Document 2.2} %
\end{document}