3

I am writing a book with over 20 chapters using LaTex. I generated the detailed Table of Contents with the package tocloft, and a brief TOC with shorttoc. Right now, the brief TOC has two pages but I really like it to be one page long. Commands from tocloft can only control some of the features in the brief TOC. I have my sample code attached at the end. Specifically, my questions are as follows. I greatly appreciate any help you have. -- Edwin

Question 1: How can I adjust the line spaces in the brief TOC only so it can be one page long?

Question 2: How can I adjust the space before and after the title of "Brief Contents?"

Question 3: How can I remove the entry of "Contents" from the brief TOC only?

---- sample code -----------------

\documentclass{book}

% 1. load two packges
\usepackage[tight]{shorttoc}
\usepackage{tocloft}

% 2. add a line below part title in TOC
\makeatletter  
    \renewcommand{\@tocrmarg}{0em}
    \renewcommand\cftpartafterpnum{\par\vskip-2ex\hrulefill\par}
\makeatother

% 3. adjust vertical space in TOC
\setlength\cftbeforetoctitleskip{0pt} % change space before TOC title
\setlength\cftaftertoctitleskip{0pt}  % change space after  TOC title
\setlength\cftbeforepartskip{16pt}  % change space before part
\setlength\cftbeforechapskip{8pt}   % change space before chapter
%\setlength\cftbeforesecskip{1pt}   % change space before section
%\setlength\cftparskip{-2pt}        % distance between paragraphs/entry; default 0


\begin{document}

% 4. add brief TOC
\clearpage \phantomsection 
\shorttoc{Brief Contents}{0}

% 5. add detailed TOC
\clearpage \phantomsection
\setcounter{tocdepth}{2} 
\addcontentsline{toc}{chapter}{Contents} % add a link for Contents in TOC 
\tableofcontents


\part{Part 1}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 2}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 3}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 4}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 5}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 6}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 7}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 8}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\end{document}
2

I wouldn't know how to do it using shorttoc, but here's one possibility using the powerful titletoc package:

\documentclass{book}
\usepackage{titletoc}
\usepackage{tocloft}

\makeatletter  
    \renewcommand{\@tocrmarg}{0em}
    \renewcommand\cftpartafterpnum{\par\vskip-2ex\hrulefill\par}
\makeatother

\setlength\cftbeforetoctitleskip{0pt} % change space before TOC title
\setlength\cftaftertoctitleskip{0pt}  % change space after  TOC title
\setlength\cftbeforepartskip{16pt}  % change space before part
\setlength\cftbeforechapskip{8pt}   % change space before chapter


\titlecontents{schapter}
  [27pt]
  {\bfseries}
  {\contentslabel{27pt}}
  {\hspace*{-27pt}}
  {\titlerule*[100pc]{.}\contentspage}
\titlecontents{spart}
  [27pt]
  {\large\bfseries\vskip5pt}
  {\contentslabel{27pt}}
  {\hspace*{-27pt}}
  {\titlerule*[100pc]{.}\contentspage}[\vskip-2ex\hrulefill{\\*[-1.8ex]}]


\begin{document}

\startcontents[short]

\clearpage 
\phantomsection
\printcontents[short]{s}{-1}{%
  \setcounter{tocdepth}{0}%
  \noindent{\Huge\bfseries Brief Contents}\par\bigskip%
}

\clearpage 
\phantomsection
\setcounter{tocdepth}{2} 
\addtocontents{toc}{}

\stopcontents[short]

\addcontentsline{toc}{chapter}{Contents} % add a link for Contents in TOC 
\tableofcontents


\resumecontents[short]

\part{Part 1}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 2}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 3}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 4}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 5}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 6}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 7}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\part{Part 8}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}
\chapter{Test Chapter} \section{Test Section} \section{Test Section}

\end{document}

An image of the resulting ToCs showing the requested features:

enter image description here

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.