0

I have two tables of contents, a short one and a detailed one. In the short one, I do not want the List of Figures, List of Tables, and Appendices listed. In the long one, I would like it all listed. How can I 'delete' the lists and appendices from the short toc?

\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}
  • Please provide a compilable document, i.e. one without \input statements -- we don't have the files you have on your computer, nor do we have library.bib. It is also missing makeidx or imakeidx package – user31729 Mar 17 '18 at 16:43
  • Please note also, that shorttoc is almost 15 years old and its author, J.P. Drucbert died in 2009 unfortunately, so this package is not maintained. You could use minitoc (also by J. Drucbert) or etoc – user31729 Mar 17 '18 at 16:44
  • The real culprit is that tocbibind adds the full information to the .toc, and shorttoc evaluates this – user31729 Mar 17 '18 at 16:50
  • Sorry, I was on vacation. As it turned out, I am not allowed to leave out the Lists and Appendices in my short TOC, so the question solved itself in a way. I think it is best not to work with shorttoc in general. Unfortunately I started with my thesis eons ago and am now struggling with not being uptodate. – reenah Mar 26 '18 at 12:44
1

A small workaround, by writing a separate toc and using \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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.