summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/blockdraw_mp/tighttoc.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/metapost/blockdraw_mp/tighttoc.sty')
-rw-r--r--Master/texmf-dist/doc/metapost/blockdraw_mp/tighttoc.sty64
1 files changed, 64 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/metapost/blockdraw_mp/tighttoc.sty b/Master/texmf-dist/doc/metapost/blockdraw_mp/tighttoc.sty
new file mode 100644
index 00000000000..ebfd73b4f4b
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/blockdraw_mp/tighttoc.sty
@@ -0,0 +1,64 @@
+% This package was written for the CTAN submission of the blockdraw_mp documentation source.
+%
+% It is my first package using options...
+%
+% It should be loaded before the parskip package, or else it will not work!
+%
+% Author: Henrik Tidefelt
+
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{tighttoc}[2006/07/18 Tight table of contents]
+
+\RequirePackage{ifthen}
+
+\newcounter{oldtocdepth}
+\newcounter{tighttoctocdepth}
+\newboolean{overridetocdepth}
+\newboolean{bookmarktoc}
+\newboolean{tighttoc}
+\newlength{\tighttocparskipreduction}
+
+\DeclareOption{bookmark}{\setboolean{bookmarktoc}{true}}
+\DeclareOption{nobookmark}{\setboolean{bookmarktoc}{false}}
+\DeclareOption{depthdefault}{\setboolean{overridetocdepth}{false}}
+\DeclareOption{depth0}{\setcounter{tighttoctocdepth}{0}\setboolean{overridetocdepth}{true}}
+\DeclareOption{depth1}{\setcounter{tighttoctocdepth}{1}\setboolean{overridetocdepth}{true}}
+\DeclareOption{depth2}{\setcounter{tighttoctocdepth}{2}\setboolean{overridetocdepth}{true}}
+\DeclareOption{depth3}{\setcounter{tighttoctocdepth}{3}\setboolean{overridetocdepth}{true}}
+\DeclareOption{depth4}{\setcounter{tighttoctocdepth}{4}\setboolean{overridetocdepth}{true}}
+\DeclareOption{0ex}{\setlength{\tighttocparskipreduction}{0ex}}
+\DeclareOption{1ex}{\setlength{\tighttocparskipreduction}{1ex}}
+\DeclareOption{2ex}{\setlength{\tighttocparskipreduction}{2ex}}
+\DeclareOption{3ex}{\setlength{\tighttocparskipreduction}{3ex}}
+
+\ExecuteOptions{bookmark,depthdefault,1ex}
+\ProcessOptions\relax
+
+\let\@oldstarttoc\@starttoc
+
+\renewcommand{\tableofcontents}%
+{%
+ \ifthenelse{\isundefined{\href}}{%
+ % Don't add a bookmark!
+ }{%
+ \ifthenelse{\boolean{bookmarktoc}}{%
+ \pdfbookmark[1]{Contents}{thetocanchor}%
+ }{%
+ % do nothing
+ }%
+ }%
+ \section*{\contentsname}%
+ \addtolength{\parskip}{-\tighttocparskipreduction}%
+ \setcounter{oldtocdepth}{\value{tocdepth}}%
+ \ifthenelse{\boolean{overridetocdepth}}{%
+ \setcounter{tocdepth}{\thetighttocdepth} % limit the depth of the conents tree
+ }{%
+ % do nothing
+ }%
+ \makeatletter
+ \@oldstarttoc{toc}%
+ \makeatother
+ \setcounter{tocdepth}{\value{oldtocdepth}}%
+ \addtolength{\parskip}{\tighttocparskipreduction}%
+}