% \iffalse % thumb.dtx %<*copyright> % thumb macros for use with the LaTeX book class. % $Header: thumb.dtx,v 1.0 97/12/24 14:43:14 sdc Exp $ %$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Copyright (C) 1997 Christian Holm. % % The thumb package is free software; you can redistribute it % and/or modify it under the terms of the GNU General Public License % as published by the Free Software Foundation; either version 2 of % the License, or (at your option) any later version. % % The thumb package is distributed in the hope that it will be % useful, but WITHOUT ANY WARRANTY; without even the implied warranty % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% @LaTeX-style-file{ %% Author = "Christian Holm", %% Version = "1.0", %% Date = "1997/12/24", %% Time = "14:43:14", %% Filename = "thumb.dtx", %% Address = "Niels Bohr Institute of Physics %% University of Copenhagen %% Denmark", %% Email = "cholm@fys.ku.dk (Internet)", %% CodeTable = "ISO/ASCII", %% Keywords = "LaTeX2e, thumb, minitoc, fancyhdr", %% Supported = "yes", %% Abstract = "LaTeX package for providing support for the %% inclusion of ``thumb'' marks." %% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %<*driver> \documentclass{ltxdoc} \EnableCrossrefs % \DisableCrossrefs % use \DisableCrossrefs if the % index is ready \RecordChanges % \OnlyDescription \CodelineIndex \typeout{Expect some Under- and overfull boxes} \begin{document} \DocInput{thumb.dtx} \end{document}% % % % \fi % %\def\fileversion{v1.0} %\def\filedate{97/12/24} %\def\docdate {97/12/24} %\def\bs{{\tt\char'134}} %\newcommand{\Lcs}[1]{{\bs\tt#1}} %\def\SpecialOptIndex#1{% % \index{#1\actualchar{\protect\ttfamily#1} % (option)\encapchar usage}% % \index{options:\levelchar{\protect\ttfamily#1}\encapchar % usage}} %\def\DescribeOption{\leavevmode % \begingroup\MakePrivateLetters\DescribeOpt} %\def\DescribeOpt#1{\endgroup % \marginpar{\raggedleft\PrintDescribeMacro{#1}}% % \SpecialOptIndex{#1}\ignorespaces} %\def\SpecialCountIndex#1{% % \index{#1\actualchar{\protect\ttfamily#1} % (counter)\encapchar usage}% % \index{counters:\levelchar{\protect\ttfamily#1}\encapchar % usage}} %\def\DescribeCount{\leavevmode % \begingroup\MakePrivateLetters\DescribeCou} %\def\DescribeCou#1{\endgroup % \marginpar{\raggedleft\PrintDescribeMacro{#1}}% % \SpecialCountIndex{#1}\ignorespaces} %\def\SpecialPageIndex#1{% % \index{#1\actualchar{\protect\ttfamily#1} % (page style)\encapchar usage}% % \index{page styles:\levelchar{\protect\ttfamily#1}\encapchar % usage}} %\def\DescribePage{\leavevmode % \begingroup\MakePrivateLetters\DescribePg} %\def\DescribePg#1{\endgroup % \marginpar{\raggedleft\PrintDescribeMacro{#1}}% % \SpecialPageIndex{#1}\ignorespaces} %\def\SpecialBoxIndex#1{% % \index{#1\actualchar{\protect\ttfamily#1} % (box)\encapchar usage}% % \index{box:\levelchar{\protect\ttfamily#1}\encapchar % usage}} %\def\DescribeBox{\leavevmode % \begingroup\MakePrivateLetters\DescribeBx} %\def\DescribeBx#1{\endgroup % \marginpar{\raggedleft\PrintDescribeMacro{#1}}% % \SpecialPageBox{#1}\ignorespaces} % % \DoNotIndex{\@ne,\advance,\begin,\char,\closein,\def,\DeclareOption} % \DoNotIndex{\divide,\docdate,\else,\end,\fi,\filedate,\fileversion} % \DoNotIndex{\framebox,\global,\ifdim,\ifeof,\ifnum,\ifx,\let,\loop} % \DoNotIndex{\makebox,\mbox,\mutliply,\NeedsTeXFormat,\newcommand} % \DoNotIndex{\newcount,\newdim,\newenvironment,\newif,\newsavebox} % \DoNotIndex{\noindent,\openin,\PackageWarning,\par,\ProcessOptions} % \DoNotIndex{\ProvidesPackage,\put,\relax,\repeat,\RequirePackage} % \DoNotIndex{\rule,\savebox,\space,\tempa,\textsc,\tt,\undefined} % \DoNotIndex{\usebox} % \iffalse % \CheckSum{881} % \fi % \changes{v1.0}{97/12/24}{The creation of \textsf{thumb}} % % \title{The \textsf{thumb}--Package\thanks{% % This file has version number \fileversion{} dated \filedate{}. % The documentation was last revised on \docdate. % }} % \author{Christian Holm\thanks{This package id largely based on the % work of Piet van Oosrum, in the package \textsf{fancyhdr}.}\\ % Niels Bohr Institute of Physics\\ % University of Copenhagen} % % \date{\today} % % \maketitle % % \begin{abstract} % This style option contains the definitions that are necessary to % make a \textit{thumb} index, providing an easy reference methode % for large books, manuals, and reference guides. % \end{abstract} % % \tableofcontents % % \section{Use of this package} % % This package puts running thumb marks in the margin, moving downward % as the chapters increase. Also, it is possible to have an % ``Overview'' page, contaning the chapter names and a thumb mark % corrosponding to every chapter, and where it is positioned in the % chapter. I think this package could be usefull for people writing % referance guides, where quick look--up is important, or for % anthologies or the like. % % This package is intented for large documents only, and should be % used with a document class, such as \texttt{book} or \texttt{report}, % \emph{not} \texttt{article}. The reason why this is limited so, is % because, it doesn't make sense to have thumbmarks in a docuemnt % smaller then 30 pages. % % \subsection{What to do in your document source} % % To use this package, include it in a document with % \begin{quote} % \Lcs{usepackage[}\textsl{options}\texttt{]\{thumb\}} % \end{quote} % % \DescribeOption{minitoc} % Here \textsl{option}, can be \texttt{minitoc} for miniture table of % contents at each chapter. This depends on package \textsf{minitoc}, % so you need to have this installed, if you want to use this feature. % % \DescribeOption{box}\DescribeOption{filledbox}\DescribeOption{oval} % \DescribeOption{filledoval} % Option \texttt{minitoc}, can be combined with \emph{one} of the % below, or not at all. In any case, of the options below, \emph{only % one} or less can be used. % % These options specify the \textit{style} of the ``thumbs''. They % are shown in figure~\ref{tab:styles} % \begin{figure}[htbp] % \setlength{\unitlength}{1cm} % \begin{picture}(5,10) % \put(0,0){\mbox{\texttt{filledbox} (defualt)}} % \put(5,0){\rule{3cm}{1cm}} % \put(0,2){\mbox{\texttt{box}}} % \put(5,2){\framebox(3,1)} % \put(0,4){\mbox{\texttt{oval}}} % \put(6.5,4.5){\oval(3,1)} % \put(0,6){\mbox{\texttt{filledoval}}} % \put(5,6){\circle*{0.5}} % \put(5,5.77){\rule{3cm}{0.5cm}} % \end{picture} % \caption{``thumb'' styles}\label{tab:styles} % \end{figure} % % Notice the style \texttt{filledoval} \emph{cannot} be made any % higher. This is due the the primitive drawning mechanisms of % \LaTeX{} without extension packages as \textsf{epic} etc.. % % The \texttt{box} and \texttt{oval} style, will extend the thumbs on % the ``overview page'', to reach over the chapter name and % number. This will effecually ``frame'' the chapter name with the % thumb. % % \subsection{Style Commands} % % While the general style of the ``thumbs'' are selected by option to % the package, it is also possible to say something more via commands. % % \DescribeMacro{\Overviewpage} % % First of, there is the ``Overview page''. To trigger this page, put % \Lcs{Overviewpage} at the begining of your document. I think it % should come just before the preface and the table of contents, but % you may disagree. % % This page will contain, the thumbs for all the capters. plus their % names, printed next to there corrosponding thumb mark, and the % title, author(s) and date of the document, in a seperate cloumn of % its own. % % If you use the overview page, you should proberly run you docuemnt % through \LaTeX{} \emph{at least} three times. This is because, the % first time, \LaTeX{} must create a file, the second time, it will % have to adjust the space between the thumb marks, and thirdly, it % should type set it all proberly. However, this is not that strange, % in fact, packages like \textsf{minitoc}, may sometimes require 5 % runs, until the utput comes out right. % % The use of the ``Overview page'' does, however put some restrains on % your formatting, though they are minor, and I think a have made a % suttable compensation. More on this later. % % \subsection{Manipulating the ``thumbs''} % % There are two ways in which you can maniplute the thumb marks. It % should come as no surpise, that these are the height and width of % the thumbs. All you ghave to do is to set this \textsl{lengths} to % the value, you desire. By default, they are calculated from the % paper and text dimensions. % % \DescribeMacro{\thumbwidth}\DescribeMacro{\thumbheight} % The \textsl{lenghts} you should change are \Lcs{thumbheight} and % \Lcs{thumbwidth}. The should be cahnge by using the \LaTeX{} command % \Lcs{setlength\{}\textsl{length}\texttt{\}\{}\textsl{dimension}\texttt{\}} % where \textsl{dimension} is a valid \LaTeX{} dimension (a number % plus a unit). % % \StopEventually{} % \iffalse %<*package> % \fi % % \section{Implementation} % % First some package identification: % \begin{macrocode} \def\fileversion{v1.0} \def\filedate{97/12/24} \ProvidesPackage{thumb}[\filedate\space\fileversion\space thumb package.] \NeedsTeXFormat{LaTeX2e}[1994/06/01] % \end{macrocode} % % \subsection{Initialization} % % \begin{macro}{\ifhave@fancyhdr} % Then we check to se if package \textsf{fancyhdr} is avaliable. This % is done by a new conditional \Lcs{ifhave@fancyhdr}: % \begin{macrocode} \newif\ifhave@fancyhdr \openin\@ne fancyhdr.sty \ifeof\@ne \else \have@fancyhdrtrue \fi \closein\@ne \relax % \end{macrocode} % \end{macro} % If we found {\tt fancyhdr.sty} we use it. % Notice the rest of the package is \emph{conditional}, in the sense, % that if \textsf{fancyhdr} isn't installed, nothing will be defined. % \begin{macrocode} \ifhave@fancyhdr \RequirePackage{fancyhdr} % \end{macrocode} % \DescribeCount{thumb} % Initialize the counter \texttt{thumb}, which will be used to measure % out the distance between the ``thumbs''. % \begin{macrocode} % Define primitive counters \newcount\thumbchap \newcount\thumbHskip % Define lengths \setlength{\unitlength}{1sp} \newlength{\thumbheight} \newlength{\thumbwidth} \newlength{\thumbskip} \newlength{\overviewskip} % Define counters \newcounter{thumbheight} \newcounter{thumbwidth} \newcounter{lthumbskip} \newcounter{rthumbskip} \newcounter{overviewskip} % the height of the thumbs \setlength{\thumbheight}{1cm} % the width of the thumbs \newdimen\thumbtmp \thumbtmp\paperwidth \advance\thumbtmp-\textwidth \divide\thumbtmp2 \setlength{\thumbwidth}{\thumbtmp} % the skip of the overview titles \thumbtmp\textwidth \divide\thumbtmp2 \setlength{\overviewskip}{\thumbtmp} % Set counters \AtBeginDocument{ \setcounter{thumbheight}{\thumbheight} \setcounter{thumbwidth}{\thumbwidth} \setcounter{overviewskip}{\overviewskip} } % \end{macrocode} % % \subsection{The \Lcs{chapter} macro} % % \begin{macro}{\chapter} % The chapter needs to be redefined, so that the ``overview'' page can % be produced in a nice way. The page style is set to % \texttt{thumbplain} so that the \texttt{plain} page style can be % used for page that should contain \emph{no} fancy stuff at all. In % any other respect, the \Lcs{chapter} works as usual. % \begin{macrocode} \renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi \thispagestyle{thumbplain}% \global\@topnum\z@ \@afterindentfalse \secdef\@chapter\@schapter} % \end{macrocode} % \end{macro} % \begin{macro}{\@chapter} % However it is only the \emph{un--stared} % form \Lcs{chapter\{...\}} that needs this modfication. The stared % form should not create any line in the ``overview'' page, nor should % it have a ``table of contents'' if the \texttt{minitoc} option is % used. This have to be done before the options decleration, because % style \textsf{minitoc} changes the \Lcs{chapter} macro. % \begin{macrocode} %\let\sv@chapter\@chapter %\def\@chapter[#1]#2{\sv@chapter[{#1}]{#2}\relax%} \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne \if@mainmatter \refstepcounter{chapter}% \typeout{\@chapapp\space\thechapter.}% \addcontentsline{toc}{chapter}% {\protect\numberline{\thechapter}#1}% \else \addcontentsline{toc}{chapter}{#1}% \fi \else \addcontentsline{toc}{chapter}{#1}% \fi \chaptermark{#1}% \addtocontents{lof}{\protect\addvspace{10\p@}}% \addtocontents{lot}{\protect\addvspace{10\p@}}% \if@twocolumn \@topnewpage[\@makechapterhead{#2}]% \else \@makechapterhead{#2}% \@afterheading \fi \relax % \end{macrocode} % The above code is taken from \texttt{book.cls}. No changes so far. % % Now we put an entry in the \textsl{filename}\texttt{.ovr} file, so % that the ``overview'' page can input it later. Notice this implies % \LaTeX{} should be run \emph{at least} twice. % \begin{macrocode} \ifOverview \def\ovrout{\noexpand\secname{\@arabic\c@chapter}{#2}{\thepage}} \immediate\write\thumbovr{\ovrout} \fi \advance\thumbchap1 % \end{macrocode} % If the \texttt{minitoc} option is given, a table of contents for % this chapter is output. Notice this implies \LaTeX{} should be run % \emph{at least} three times. % \begin{macrocode} \ifx\thumbmini\undefined \else \minitoc \fi } % \end{macrocode} % \end{macro} % % \begin{macro}{\preface} % This macro is for including a preface (a chapter with no number, but % a entry in the table of contents and the overview page. % % The macro \Lcs{Prefacename} is set to \Lcs{prefacename} if it is % defined (as in the \textsf{babel} package), else it is set to % ``Preface''. This means non--english users should redefine the macro % \Lcs{prefacename}, \emph{not} \Lcs{Prefacename}. % \begin{macrocode} \ifx\prefacename\undefined \newcommand{\Prefacename}{Preface} \else \newcommand{\Prefacename}{\prefacename} \fi % \end{macrocode} % A new \textsl{if} is defined, so that the overview page may use the % \Lcs{Prefacename} \emph{only} if a preface is present. This means % the preface should come before the overview page. % \begin{macrocode} \newif\ifPreface \Prefacefalse % \end{macrocode} % The command \Lcs{preface} takes an optional argument, so % non--english users may specify another name for the preface, e.g.\ % ``Vorrede''. A new right--handed page is started, and a line is % added to the table of contents. % \begin{macrocode} \newcommand{\preface}[1][\Prefacename]{% \Prefacetrue \cleardoublepage \thispagestyle{thumbplain} \addcontentsline{toc}{chapter}{#1}% % \end{macrocode} % Marks are set, and apropiate % vertical space is added. Next, we take into account wether the % document is set in two column or not. % \begin{macrocode} \chaptermark{#1}% \vspace*{50\p@}% \if@twocolumn \@topnewpage[{\Huge \bfseries #1}]% \else { \interlinepenalty\@M \Huge \bfseries #1 \par\nobreak \vskip 40\p@ } \@afterheading \fi \relax % \end{macrocode} % Some commands for the overview page is defined, etc. % \begin{macrocode} \renewcommand{\Overviewname}{#1} \newcount\tempa \tempa\thepage \newcommand{\Overviewpage}{\the\tempa} } % \end{macrocode} % \end{macro} % \subsection{Options} % % The options are declared. These are \texttt{minitoc, filledbox, box, % filledoval,} and \texttt{oval}. % % \begin{macro}{minitoc} % If option \texttt{minitoc} is set, we check to see if the file % \texttt{minito.sty} is avaliable. If it is we load it. % % \begin{macro}{\ifhave@minitoc} % To accomplish this we define a new \Lcs{if} % \begin{macrocode} \DeclareOption{minitoc}{ \newif\ifhave@minitoc \openin\@ne minitoc.sty \ifeof\@ne \else \have@minitoctrue \fi \closein\@ne \relax \ifhave@minitoc \def\thumbmini{} % \end{macrocode} % Notice if you use some other language then English, you will have % to redefine the macro \Lcs{contentsname} yourself to something % apropriate\footnote{For example Danish users should say % \Lcs{renewcommand\{}\Lcs{contentsname\}\{Kort oversigt\}}.}. % % If the option \texttt{minitoc} is not set, then put out a warning. % \begin{macrocode} \else \PackageWarning{thumb}{style `minitoc´ not avaliable \return option `minitoc' will not be used} \fi } % \end{macrocode} % \end{macro} % \end{macro} % % \subsubsection{The ``thumb'' styles} % % Next the options for the thumbs styles is set. Notice, in every % option there is a definiton of three different marks % \Lcs{rthumb}, \Lcs{lthumb} and \Lcs{ovrthumb}. These are used on % right--, left--handed pages and on the overview page, respectivly. % % First some commands to use wit the options. % % Most of the dimensions are defined here also, but often not set % until at \Lcs{begin\{document\}}, since various packages such as % \texttt{a4wide.sty}, may change the size of the paper etc. % % \begin{macro}{thumbfilledbox} % \begin{macrocode} \newcommand{\thumbfilledbox}{% \thumbtmp\paperwidth \advance\thumbtmp-\textwidth \divide\thumbtmp2 \divide\thumbtmp3 \setlength{\thumbskip}{\thumbtmp} \typeout{Expect some overfull hbox'es in the overview page} \AtBeginDocument{ \setcounter{lthumbskip}{\thumbskip} \setcounter{rthumbskip}{\thumbskip} \addtocounter{lthumbskip}{\value{thumbwidth}} } % \end{macrocode} % From then on, it's is just a question of defing the thumb marks. % % First the thumbmarks for right--handed pages. % % \begin{macrocode} \def\rthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \put(\value{rthumbskip},-\the\thumbHskip){ \rule{\thumbwidth}{\thumbheight}} \end{picture} } % \end{macrocode} % Then the thumbmarks for left--handed pages. % % \begin{macrocode} \def\lthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \put(-\value{lthumbskip},-\the\thumbHskip){ \rule{\thumbwidth}{\thumbheight}} \end{picture} } % \end{macrocode} % And finally the thumbmarks for overview page. % % \begin{macrocode} \def\ovrthumb{% \hspace{\thumbskip}\rule{\thumbwidth}{\thumbheight} } } % \end{macrocode} % \end{macro} % \begin{macro}{thumbbox} % This makes the ``thumbs'' black frames. This is pretty much the same % as above, expect for \Lcs{lthumb}, which I had to define in a % roundabout way. % \begin{macrocode} \newcommand{\thumbbox}{ \thumbtmp\paperwidth \advance\thumbtmp-\textwidth \divide\thumbtmp6 \setlength{\thumbskip}{\thumbtmp} \typeout{Expect some overfull hbox'es in the overvew page} \AtBeginDocument{ \setcounter{rthumbskip}{\thumbskip} \setcounter{lthumbskip}{\thumbtmp} \newcounter{thumbovrwidth} \setcounter{thumbovrwidth}{\value{overviewskip}} \addtocounter{thumbovrwidth}{\value{overviewskip}} } \def\rthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \put(\value{rthumbskip},-\the\thumbHskip){ \framebox(\value{thumbwidth},\value{thumbheight})} \end{picture} } % \end{macrocode} % The left--handed pages thumbs are a bit tricky. Since \LaTeX{} have % some problem starting a picture \emph{outside} the page, I had to % make up the left thumbs, from lines, instead of using the % \Lcs{framebox} command, which would have been easier, but didn't work! % % \begin{macrocode} \def\lthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \advance\thumbHskip-\value{thumbheight} \begin{picture}(0,0) \put(-\value{rthumbskip},-\the\thumbHskip) {\line(-1,0){\value{thumbwidth}}} \put(-\value{lthumbskip},-\the\thumbHskip){% \line(0,-1){\value{thumbheight}}} \advance\thumbHskip\value{thumbheight} \put(-\value{rthumbskip},-\the\thumbHskip) {\line(-1,0){\value{thumbwidth}}} \end{picture} } % \end{macrocode} % The thumbmarks for overview page are actually a bit interresting, % since it produces a frame around the text put on the overview page % for each chapter. The thumbs are therefore wider on the overview % page then in the rest of the document (half the textwidth plus some % more, aloving it to go beyod the page). % % \begin{macrocode} \def\ovrthumb{% \hspace{-\overviewskip}\hspace{-2em}\raisebox{-2ex}{ \framebox(\value{thumbovrwidth},\value{thumbheight})} } } % \end{macrocode} % \end{macro} % \begin{macro}{thumbfilledoval} % This makes the ``thumbs'' filled ovals. Notice, these \emph{can not} % be higher then ca.\ 0.7cm (ca.\ 0.3 inches), due to \LaTeX{} % handling of the macro \Lcs{circle}. \Lcs{HOLD} is used to prevent % redifintion of \Lcs{unitlenght}. % % \textbf{Notice:} This style may not come out completly right. That % is due to some rounding errors, which I didn't try to prevent, % since I think it is only a minor bug\footnote{OK, so I was lazy % --- you correct it!}. It is most notaciable on the overview page. % \begin{macrocode} \newcommand{\thumbfilledoval}{ \thumbtmp\paperwidth \advance\thumbtmp-\textwidth \divide\thumbtmp6 \setlength{\thumbskip}{\thumbtmp} \setlength{\thumbheight}{983025sp} \typeout{Expect some overfull hbox'es in the overvew page} \AtBeginDocument{ \setcounter{rthumbskip}{\thumbskip} \setcounter{lthumbskip}{\thumbtmp} \addtocounter{lthumbskip}{\value{thumbwidth}} } \def\rthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \thicklines \put(\value{rthumbskip},-\the\thumbHskip){ \circle*{983025}} \advance\thumbHskip491513 \put(\value{rthumbskip},-\the\thumbHskip){ \rule{\thumbwidth}{\thumbheight}} \end{picture} } \def\lthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \thicklines \put(-\value{rthumbskip},-\the\thumbHskip){ \circle*{983025}} \advance\thumbHskip491513 \put(-\value{lthumbskip},-\the\thumbHskip){ \rule{\thumbwidth}{\thumbheight}} \end{picture} } \def\ovrthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \thicklines \put(\value{rthumbskip},-\the\thumbHskip){ \circle*{983025}} \advance\thumbHskip491513 \put(\value{rthumbskip},-\the\thumbHskip){ \rule{\thumbwidth}{\thumbheight}} \end{picture} } \def\HOLD{} } % \end{macrocode} % \end{macro} % \begin{macro}{thumboval} % This makes the ``thumbs'' non--filled ovals. % % These thumbs are a bit interresting, in a \TeX{}nical way. The % starting point of a \Lcs{framebox}, is the lower left corner, and % for \Lcs{rule}, is the left edge, and for \Lcs{cirle} it is the % center. However, for \Lcs{oval}, it is the \emph{middle} of the % oval, so some extra care must be used to put the thumbs on the % page, when ovals is used. Again, we use the page dimensions to % ensure the optimal layout. % % \begin{macrocode} \newcommand{\thumboval}{ \thumbtmp\paperwidth \advance\thumbtmp-\textwidth \divide\thumbtmp6 \multiply\thumbtmp2 \setlength{\thumbskip}{\thumbtmp} \AtBeginDocument{ \setcounter{rthumbskip}{\thumbskip} \newcounter{thumbovrwidth} \setcounter{thumbovrwidth}{\value{overviewskip}} \addtocounter{thumbovrwidth}{\value{overviewskip}} } \def\rthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \thicklines \put(\value{rthumbskip},-\the\thumbHskip) {\oval(\value{thumbwidth},\value{thumbheight})} \put(\value{rthumbskip},-\the\thumbHskip) {\usebox{\ovalmark}} \end{picture} } \def\lthumb{% \thumbHskip\thumbchap \multiply\thumbHskip\value{thumbhskip} \begin{picture}(0,0) \thicklines \put(-\value{rthumbskip},-\the\thumbHskip) {\oval(\value{thumbwidth},\value{thumbheight})} \put(-\value{rthumbskip},-\the\thumbHskip) {\usebox{\ovalmark}} \end{picture} } % \end{macrocode} % The thumbmarks for overview page are actually a bit interresting, % since it produces a frame around the text put on the overview page % for each chapter. This is like the thumbs defined in the % \texttt{box} style option. % % \begin{macrocode} \def\ovrthumb{% \hspace{-2em}\oval(\value{thumbovrwidth},\value{thumbheight}) } } % \end{macrocode} % \end{macro} % Now the actual option declarations. % \begin{macrocode} \DeclareOption{filledbox}{% \thumbfilledbox{} } \DeclareOption{box}{ \thumbbox{} } \DeclareOption{filledoval}{ \thumbfilledoval{} } \DeclareOption{oval}{ \thumboval{} } % \end{macrocode} % % If some strange option is given, then give an error message. % \begin{macrocode} \DeclareOption*{\PackageWarning{thumb}{Unkown option: `\CurrentOption'}} % \end{macrocode} % Make the option \texttt{filledbox} default. % \begin{macrocode} \ExecuteOptions{filledbox} \ProcessOptions\relax % \end{macrocode} % % \subsection{Boxes for headings} % % \begin{macro}{\thumbheader} % \begin{macro}{\Overviewtitlefont} % \begin{macro}{\Overviewauthorfont} % \begin{macro}{\Overviewdatefont} % First we define some commands, and there defaults, to format the % header fonts. % \begin{macrocode} \newcommand{\thumbheaderfont}{\small\sl} \newcommand{\Overviewtitlefont}{\sf\LARGE} \let\Overviewauthorfont\Overviewtitlefont \let\Overviewdatefont\Overviewtitlefont % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % \begin{macro}{\thumbtitlefont} % \begin{macro}{\thumbauthorfont} % \begin{macro}{\thumbdatefont} % Then we define a new macro to control the font of the title \emph{on % the titlepage} and nowhere else. This is done, so that the font in % the headers may be different from the one on the titlepage. However, % this must be considered a bug, because it means, you have to use the % macro \Lcs{thumbtitlefont}, if you wish to change the font of the % title on the titlepage. Otherwise, you can get strange headers! % Also, you can only use fontmacroes, that normally change the font % globally, e.g.\ \Lcs{tt}, \Lcs{rm}, \Lcs{bf}, \Lcs{Huge}, % \Lcs{Large}, and \emph{not} the local counterparts \Lcs{texttt}, % \Lcs{textrm}, \Lcs{textbs} etc.. \Lcs{thumbauthorfont} and % \Lcs{thumbdatefont} work in the same way as \Lcs{thumbtitlefont} % \begin{macrocode} \newcommand{\thumbtitlefont}{} \newcommand{\thumbauthorfont}{} \newcommand{\thumbdatefont}{} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % % \begin{macro}{\thumbtitle} % \begin{macro}{\thumbauthor} % \begin{macro}{\thumbdate} % \begin{macro}{\Overviewtitle} % The next step is to make some saveboxes, and fill them with the % title of the document. % \begin{macrocode} \newsavebox{\thumbtitle} \newsavebox{\thumbauthor} \newsavebox{\thumbdate} \newsavebox{\Overviewtitle} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % Then we fill the boxes. this have to be done at the begin of the % document, since, other styles might change the marks. % \begin{macrocode} \AtBeginDocument{ \let\tmptitlefont\thumbtitlefont \let\thumbtitlefont\relax \let\tmpauthorfont\thumbauthorfont \let\thumbauthorfont\relax \let\tmpdatefont\thumbdatefont \let\thumbdatefont\relax % \end{macrocode} % This is the tricky part. Here we set \Lcs{thumbtitlefont} to be % void, so that any large font, or otherwise unreasonable font, % headerwise that is, specified on the titlepage, will not affect the % header fonts. this is why you \emph{must} use the % \Lcs{thumbtitlefont} macro to change the bfont on the title font. % The \Lcs{thumbtitlefont} is restored to it original use below. % \begin{macrocode} \let\tmpand\and \let\and\par \savebox{\thumbtitle} {{\thumbheaderfont\@title}} \begin{lrbox}{\Overviewtitle} \begin{minipage}[c]{0.4\textwidth} \Overviewtitlefont\@title\newline \Overviewauthorfont\@author\newline \Overviewdatefont\@date\newline \end{minipage} \end{lrbox} \let\thumbtitlefont\tmptitlefont \let\thumbauthorfont\tmpauthorfont \let\thumbdatefont\tmpdatefont \let\and\tmpand % \end{macrocode} % % \begin{macro}{\chaptermark} % \begin{macro}{\sectionmark} % \begin{macro}{\subsectionmark} % After having filled the boxes, we make use of them in the % headers. If you don't like to have the title in the headers, you % can always redefine the marks, with \Lcs{markboth\{\}\{\}} and % \Lcs{markright\{\}\{\}}, though it should be done \emph{after} the % \Lcs{begin\{document\}}. % \begin{macrocode} \markboth{\usebox{\thumbtitle}}{\usebox{\thumbtitle}} \renewcommand{\chaptermark}[1]{ \markboth{{\small #1}}{\usebox{\thumbtitle}} } \renewcommand{\sectionmark}[1]{ \markboth{{\small #1}}{\usebox{\thumbtitle}} } \renewcommand{\subsectionmark}[1]{ \markboth{{\small #1}}{\usebox{\thumbtitle}} } } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % % \subsection{The Appendix} % % \begin{macro}{\appendix} % The command \Lcs{appendix} is redefined, so that the thumb % marks come out running, instead of shifting up at the appendix % \DescribeCount{appendix} % \DescribeCount{chapter} % \DescribeCount{section} % \begin{macrocode} \newif\ifAppendix \Appendixfalse \newcounter{appendix} \setcounter{appendix}{0} \renewcommand\appendix{\par \setcounter{appendix}{\value{chapter}} \setcounter{chapter}{0}% \setcounter{section}{0}% \renewcommand\chaptername{\appendixname}% \renewcommand\thechapter{\Alph{chapter}} \ifOverview \immediate\write\thumbovr{\noexpand\Appendixtrue} \fi } % \end{macrocode} % \end{macro} % % \subsection{The Lists} % % If the option \texttt{minitoc} is set, then the tableofcontents, % should only contain the parts and and chapters (Like a ``Short Table % of Contents'') % \begin{macrocode} \ifx\thumbmini\undefined \else \RequirePackage{minitoc} \setcounter{tocdepth}{0} \def\contentsname{Short Table of Contents}% \AtBeginDocument{\dominitoc} % \end{macrocode} % Also, since \texttt{minitoc} redefines a lot of the behavior of the % lists, we have to be able to print the ``List of Figures'', and % ``List of Tables''. Now since \texttt{tocdepth} is set to 0, normally % the above lists would \emph{not} be printed, but if we redefine the % macroes \verb+\l@figure+ and \verb+\l@table+, wich \LaTeX{} use to % control the beaviour of the lists, so that the first number is less % then 0, then the lists \emph{do} get printed\footnote{This all sound % so simple, but it tok me a couple of hours to figure it out.}. % \begin{macrocode} \renewcommand*\l@figure{\@dottedtocline{-1}{1.5em}{2.3em}} \let\l@table\l@figure \fi % \end{macrocode} % % \subsection{Page Styles} % % \begin{macro}{\thumbsecnum} % First we create the macro \Lcs{thumbsecnum}, to get nice headers. It % test if a counter is 0, if it is, then it, and \emph{all} subsequent % counters in the section number, should not be printed. Notice, if all % section numbers are 0, nothing is printed \emph{at all}. % \begin{macrocode} \newlength{\thumbspace} \settowidth{\thumbspace}{9} \newcommand{\thumbsecnum}{ \ifnum\value{chapter}=0 \else \ifnum\value{section}=0 \thechapter \else \ifnum\value{subsection}=0 \thesection \else \thesubsection \fi \fi \fi } % \end{macrocode} % \end{macro} % The macro \Lcs{thumbspace} is a length, we use when a number was % supposed to be there, but isn't dor some reason, and so we % want a empty space. It also used below. % % \DescribePage{fancynormal} % This is he normal page style, that puts the ``thumbs'' on the page, % and the current section name in the center of the header, and the % current subsection number on the farmost corner of the header. The % page number is put in the farmost footer. % % The macroes \emph{could} have been made so that the user could % change them, but instead of doing that, I leave it up to the user, % to browse the manual of \texttt{fanyhdr} and find out how to do that % % \begin{macrocode} \fancypagestyle{thumbnormal}{ \fancyhf{} \renewcommand{\footrulewidth}{\headrulewidth} \fancyfoot[LO]{} \fancyfoot[CO]{} \fancyfoot[RO]{\thepage} \fancyfoot[LE]{\thepage} \fancyfoot[CE]{} \fancyfoot[RE]{} \fancyhead[LO]{} \fancyhead[CO]{\small\leftmark} \fancyhead[RO]{\thumbsecnum\rthumb} \fancyhead[LE]{\lthumb\thumbsecnum} \fancyhead[CE]{\small\rightmark} \fancyhead[RE]{} } \pagestyle{thumbnormal} % \end{macrocode} % % \DescribePage{plain} % This is the page style \LaTeX{} on special pages, such as the first % of the chapter or part, the tableofcontents, etc. % \begin{macrocode} \fancypagestyle{thumbplain}{% \fancyhf{} \fancyfoot[C]{\thepage} \fancyhead[RO]{\rthumb} \fancyhead[LE]{\lthumb} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} } \fancypagestyle{plain}{% \fancyhf{} \fancyfoot[C]{} \fancyhead[R]{} \fancyhead[L]{} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} } % \end{macrocode} % \DescribePage{fancyoverview} % This is the page style of the overview page. This page contains a % ``thumb'' for every chapter of document, plus a line containing the % chapter number and name. % \begin{macrocode} \fancypagestyle{thumboverview}{% \fancyhf{} \fancyfoot[C]{} \fancyfoot[R]{} \fancyfoot[L]{} \fancyhead[C]{} \fancyhead[L]{} \fancyhead[R]{\thumboverview} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} } % \end{macrocode} % % \subsection{Commands for the Overview page} % % \begin{macro}{\Ovreviewname} % The first macro, is for deciding what the name of % ``Overview'' page should be. This can be refined by saying: % % \Lcs{renewcommand\{\bs{}Overviewname\}\{}\textsl{name\_of\_page}\texttt{\}} % % \begin{macrocode} \newcommand{\Overviewname}{Overview} % \end{macrocode} % \end{macro} % % Like above, only it sets the font. % % \begin{macro}{\Overviewfont} % \begin{macrocode} \newcommand{\Overviewfont}{\sf\Large} % \end{macrocode} % \end{macro} % % \begin{macro}{\secname} % This is the command that sets the individual lines on the % ``Overview'' page. Notice how the previous defined \Lcs{ifAppendix} % is used here, and the names of the chapters are set to align, by % inspecting the number before. % % First, we put in the thumb, then we put in the text, though the % numbers need special attention. % \begin{macrocode} \newcommand{\secname}[3]{% \put(0,-\value{thumbline}){\ovrthumb} \put(-\value{overviewskip},-\value{thumbline}){% {\Overviewfont % \end{macrocode} % If the first number is zero, the we don't want the number on the page. % \begin{macrocode} \ifnum#1=0 #2\dotfill\ #3 \else % \end{macrocode} % Else, the counter is put on the page, according to thier meaning. % \begin{macrocode} \setcounter{Overviewnumber}{#1} \ifAppendix \Alph{Overviewnumber} \else \arabic{Overviewnumber} \fi % \end{macrocode} % Then a check to see if space is need in front of the number, so that % the numbers will come out right adjusted. % \begin{macrocode} \ifnum#1>99 \hspace{\thumbspace} \else \ifnum#1>9 \hspace{2\thumbspace} \else \hspace{3\thumbspace} \fi \fi % \end{macrocode} % Finally, the text and page number is put on the page. % \begin{macrocode} #2\dotfill\ #3 \fi } } % \end{macrocode} % We need to increment the \texttt{line} counter, so that the next % line isn't put on top of this line. % \begin{macrocode} \stepcounter{line} \addtocounter{thumbline}{\value{thumbhskip}} } % \end{macrocode} % \end{macro} % % \begin{macro}{\thumboverview} % This is the command used in the previous defined % \texttt{thumboverview} page style. It does nothing fancy, expect % check to see if the file \Lcs{\jobname.ovr} exists. If it does, it % inputs it. Othewise it outputs a warning. % % \begin{macrocode} \newcommand{\thumboverview}{% \begin{picture}(0,0) \IfFileExists{\jobname.ovr}{% \noindent \input{\jobname.ovr} } { \PackageWarning{thumb}{I couldn't finde \jobname.ovr} \AtEndDocument{ \typeout{``thumbs'' set, please run LaTeX again} } } \end{picture} } % \end{macrocode} % \end{macro} % % If the Overview page is not used, the \texttt{thumbhskip} counter % still needs to be set, so we set it in any case. This is not a % problem, since the overview page \emph{always} comes after % \Lcs{begin\{document\}}. % \begin{macrocode} \newcounter{thumbhskip} \AtBeginDocument{ \setcounter{thumbhskip}{\value{thumbheight}} } % \end{macrocode} % \begin{macro}{\OverviewPage} % This is the macro to be used in the document. It typesets the % ``Overview'' page where it is given. It is \emph{always} set on a % right--handed page. This look best, I think (and makes the coding % easier). Notice, the empty \Lcs{mbox} at the end is % nessecary. Oterwise \LaTeX{} think you have asked for 3 or 4 empty % pages, and will reduce these to 1 or zero respectivly. Figure that % out! Also the file \textsl{jobname}\texttt{.ovr} is opened and ready % to be written in. At the end of the document, we close it. % % First some counters and a new \textsl{if}, so that we may check in % the \Lcs{chapter} macro, wether we should write to the file % \Lcs{jobname.ovr}. % \begin{macrocode} \newcounter{Overviewnumber} \newcounter{line} \newcounter{thumbline} \newif\ifOverview \Overviewfalse % \end{macrocode} % Now to the macro it self. First \Lcs{ifOverview} should test % \textsl{true}, and the counter \texttt{thumbhskip} is reset. % Then we open the file \Lcs{jobname.ovr} for writting, and start a % new righthanded page. The page style is what actually does all the % work. This is defined earlier. % \begin{macrocode} \newcommand{\OverviewPage}{% \Overviewtrue \setcounter{thumbhskip}{0} \newwrite\thumbovr \cleardoublepage \thispagestyle{thumboverview} \ifPreface \else \newcommand{\Overviewpage}{\thepage} \fi % \end{macrocode} % Now, we put a small paragraph containg the titlepage stuff, next to % the overview index. The \Lcs{vfill}'s is to ensure the page will % appear non--empty, and create appropiate vertical space. % \begin{macrocode} \vfill \usebox{\Overviewtitle} \vfill % \end{document} % The file \Lcs{jobname.ovr} is closed at the end of the document. % \begin{macrocode} \AtEndDocument{ \closeout\thumbovr \typeout{(\jobname.ovr)} } % \end{macrocode} % Then a new right--handed page is started, and we open the file % \Lcs{jobname.ovr} for writting. % \begin{macrocode} \cleardoublepage \immediate\openout\thumbovr=\jobname.ovr % \end{macrocode} % If the file \Lcs{jobname.ovr} wasn't found, then we do not know the % number of chapters in the document, so we guess it to be less then % 10 (I think thats a reasonable number --- you may differ). Also, we % ask the user to run \LaTeX{} again, so that the thumbs may come % out right. % \begin{macrocode} \newdimen\tempa \tempa\textheight \ifnum\value{line}>0 \divide\tempa\value{line} \thumbtmp\value{thumbhskip}sp \multiply\thumbtmp\value{line} % \end{macrocode} % Next we test to see if there are too many thumbs, or if they are to % high, if so right an error, and prompt. % \begin{macrocode} \ifdim\thumbtmp>\textheight \PackageError{thumb}{The total height of the thumbs is larger then the text}{Go on now, but correct the mistake afterwards} \fi \else \divide\tempa10 \AtEndDocument{ \typeout{``thumbs'' not set right, please run LaTeX again} } \fi % \end{macrocode} % Now we that we have the (approximate) value of \texttt{thumbhskip}, % we output it to the file \Lcs{jobname.ovr}. % \begin{macrocode} \newcounter{thumbtmp} \setcounter{thumbtmp}{\tempa} \immediate\write\thumbovr{\noexpand\setcounter{thumbhskip}{\thethumbtmp}} \def\ovrout{ \noexpand\secname{0}{\noexpand\Overviewfont\noexpand\Overviewname} {\noexpand\Overviewpage} } \immediate\write\thumbovr{\ovrout} } % \end{macrocode} % \end{macro} % % \subsection{Ending} % % Finally, the errormessage if \texttt{fancyhdr} wasn't found. % \begin{macrocode} \else \PackageWarning{thumb}{style `fancyhdr´ not avaliable \return style `thumb' will not be used} \fi % \end{macrocode} % \iffalse % % \fi % % \Finale % \PrintIndex % \PrintChanges \endinput