我是 TeXworks 的新用户。我想隐藏摘要中的某些行(我使用命令来实现\shorttoc
),但将它们保留在文档末尾的目录中。
下面是我想要做的事情的一个例子:
\documentclass[11pt]{article}
\usepackage{shorttoc}
\begin{document}
\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements}
I would like to thank...
\newpage{}
\shorttoc{Summary}{1}
\section*{Abstract}
\addcontentsline{toc}{section}{Abstract}
Here I write the abstract
\section*{Introduction}
\addcontentsline{toc}{section}{Introduction}
Here I write the introduction
\section{Part1}
Here I write my part 1
\section{Part2}
Here I write my part 2
\section*{Conclusion}
\addcontentsline{toc}{section}{Conclusion}
Here I write my conclusion
\begin{thebibliography}{1}
\addcontentsline{toc}{section}{Bibliography}
\bibitem{key-1}\noun{Author 1}, ``Book name'', Editor, 1998.
\end{thebibliography}
\tableofcontents
我\shorttoc
只想显示从引言到结论部分的名称(所以我想隐藏致谢、摘要和参考书目\shorttoc
),但保留长目录中的所有名称。
谢谢您的回答!
答案1
您shorttoc
只能决定附加 ToC 的深度级别。
titletoc
我认为就您而言最好使用。
在 MWE 中,我创建了一个名为 的定制 ToC myshort
。
编辑:如果你把要\section
列在简短的目录中
\resumecontents[myshort]
...
\stopcontents[myshort]
您可以自由选择将哪一个放入您的简短目录中。
为了方便起见,我创建了几个宏。
\documentclass[11pt]{article}
\usepackage{titletoc}
\renewcommand{\refname}{Bibliography}% Otherwise, the title is different from the ToC
\newcommand{\secinstoc}[1]{% for convenience, I've created a macro for the section (not starred) to be added in the short ToC
\resumecontents[myshort]
\section{#1}
\stopcontents[myshort]
}
\newcommand{\secinstocs}[1]{% and the version with the starred \section*
\resumecontents[myshort]
\section*{#1}
\addcontentsline{toc}{section}{#1}
\stopcontents[myshort]
}
\begin{document}
\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements} I would like to thank...
\clearpage
\startcontents[myshort]
\stopcontents[myshort]
\printcontents[myshort]{}{-1}{\section*{Summary}}
\addcontentsline{toc}{section}{Summary}
\clearpage
\section*{Abstract}
\addcontentsline{toc}{section}{Abstract}
Here I write the abstract
\secinstocs{Introduction}
Here I write the introduction
\subsection{This is not in my short ToC}
\secinstoc{Part1}
Here I write my part 1
\subsection{This is not in my short ToC}
\secinstoc{Part2} Here I write my part 2
\subsection{This is not in my short ToC}
\subsection{This is not in my short ToC}
\secinstocs{Conclusion}
Here I write my conclusion
\begin{thebibliography}{1}
\addcontentsline{toc}{section}{Bibliography}
\bibitem{key-1} Author 1 {``Book name''} Editor 1998.% I've not used \name because it gives an error
\end{thebibliography}
\clearpage
\tableofcontents
\end{document}
包含简短目录的页面:
包含目录的页面: