我有两个目录,一个简短的,一个详细的。在简短的目录中,我不想列出图片列表、表格列表和附录。在详细的目录中,我想列出所有内容。我怎样才能从简短的目录中“删除”列表和附录?
\documentclass[a4paper,12pt]{book}
\usepackage[nottoc]{tocbibind}
\usepackage{shorttoc}
\usepackage[titletoc]{appendix}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\renewcommand*\contentsname{Contents (detailed)}
\begin{document}
\shorttoc{Contents (short)}{1}
\tableofcontents
\listoffigures
\listoftables
\input{chapter1}
\input{chapter2}
\input{chapter3}
\bibliographystyle{mine}
\bibliography{library}
\printindex
\appendix
\input{appendix1}
\input{appendix2}
\input{appendix3}
\end{document}
答案1
一个小的解决方法,通过编写单独的目录并使用\ifshowinshorttoc
\documentclass[a4paper,12pt]{book}
\usepackage[nottoc]{tocbibind}
\usepackage[titletoc]{appendix}
\usepackage{hyperref}
\newif\ifshowinshorttoc
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\renewcommand*\contentsname{Contents (detailed)}
\makeatletter
\AtBeginDocument{
\let\l@tex@ddcontentsline\addcontentsline
\renewcommand{\addcontentsline}[3]{%
\l@tex@ddcontentsline{#1}{#2}{#3}%
\ifnum0=\pdfstrcmp{#1}{toc}%
\ifshowinshorttoc
\l@tex@ddcontentsline{stoc}{#2}{#3}%
\fi
\fi
}
}
\newcommand{\shorttoc}[1]{%
\chapter*{#1}%
\@starttoc{stoc}
}
\g@addto@macro{\appendix}{\showinshorttocfalse}
\makeatother
\begin{document}
\shorttoc{Contents (short)}%{1}
\showinshorttoctrue
\tableofcontents
\showinshorttocfalse
\listoffigures
\listoftables
\showinshorttoctrue
\chapter{Foo}
%\input{chapter1}
%\input{chapter2}
%\input{chapter3}
\bibliographystyle{alpha}
\bibliography{biblio}
%\printindex
\appendix
\chapter{Foo appendix}
%\input{appendix1}
%\input{appendix2}
%\input{appendix3}
\end{document}