| 1 |
% This package was written for the CTAN submission of the blockdraw_mp documentation source. |
| 2 |
% |
| 3 |
% It is my first package using options... |
| 4 |
% |
| 5 |
% It should be loaded before the parskip package, or else it will not work! |
| 6 |
% |
| 7 |
% Author: Henrik Tidefelt |
| 8 |
|
| 9 |
|
| 10 |
\NeedsTeXFormat{LaTeX2e} |
| 11 |
\ProvidesPackage{tighttoc}[2006/07/18 Tight table of contents] |
| 12 |
|
| 13 |
\RequirePackage{ifthen} |
| 14 |
|
| 15 |
\newcounter{oldtocdepth} |
| 16 |
\newcounter{tighttoctocdepth} |
| 17 |
\newboolean{overridetocdepth} |
| 18 |
\newboolean{bookmarktoc} |
| 19 |
\newboolean{tighttoc} |
| 20 |
\newlength{\tighttocparskipreduction} |
| 21 |
|
| 22 |
\DeclareOption{bookmark}{\setboolean{bookmarktoc}{true}} |
| 23 |
\DeclareOption{nobookmark}{\setboolean{bookmarktoc}{false}} |
| 24 |
\DeclareOption{depthdefault}{\setboolean{overridetocdepth}{false}} |
| 25 |
\DeclareOption{depth0}{\setcounter{tighttoctocdepth}{0}\setboolean{overridetocdepth}{true}} |
| 26 |
\DeclareOption{depth1}{\setcounter{tighttoctocdepth}{1}\setboolean{overridetocdepth}{true}} |
| 27 |
\DeclareOption{depth2}{\setcounter{tighttoctocdepth}{2}\setboolean{overridetocdepth}{true}} |
| 28 |
\DeclareOption{depth3}{\setcounter{tighttoctocdepth}{3}\setboolean{overridetocdepth}{true}} |
| 29 |
\DeclareOption{depth4}{\setcounter{tighttoctocdepth}{4}\setboolean{overridetocdepth}{true}} |
| 30 |
\DeclareOption{0ex}{\setlength{\tighttocparskipreduction}{0ex}} |
| 31 |
\DeclareOption{1ex}{\setlength{\tighttocparskipreduction}{1ex}} |
| 32 |
\DeclareOption{2ex}{\setlength{\tighttocparskipreduction}{2ex}} |
| 33 |
\DeclareOption{3ex}{\setlength{\tighttocparskipreduction}{3ex}} |
| 34 |
|
| 35 |
\ExecuteOptions{bookmark,depthdefault,1ex} |
| 36 |
\ProcessOptions\relax |
| 37 |
|
| 38 |
\let\@oldstarttoc\@starttoc |
| 39 |
|
| 40 |
\renewcommand{\tableofcontents}% |
| 41 |
{% |
| 42 |
\ifthenelse{\isundefined{\href}}{% |
| 43 |
% Don't add a bookmark! |
| 44 |
}{% |
| 45 |
\ifthenelse{\boolean{bookmarktoc}}{% |
| 46 |
\pdfbookmark[1]{Contents}{thetocanchor}% |
| 47 |
}{% |
| 48 |
% do nothing |
| 49 |
}% |
| 50 |
}% |
| 51 |
\section*{\contentsname}% |
| 52 |
\addtolength{\parskip}{-\tighttocparskipreduction}% |
| 53 |
\setcounter{oldtocdepth}{\value{tocdepth}}% |
| 54 |
\ifthenelse{\boolean{overridetocdepth}}{% |
| 55 |
\setcounter{tocdepth}{\thetighttocdepth} % limit the depth of the conents tree |
| 56 |
}{% |
| 57 |
% do nothing |
| 58 |
}% |
| 59 |
\makeatletter |
| 60 |
\@oldstarttoc{toc}% |
| 61 |
\makeatother |
| 62 |
\setcounter{tocdepth}{\value{oldtocdepth}}% |
| 63 |
\addtolength{\parskip}{\tighttocparskipreduction}% |
| 64 |
} |