X-VM-v5-Data: ([nil nil nil nil nil nil nil t nil] [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]) Date: Wed, 18 Jul 90 15:05 UT+2 From: POPPELIER@HUTRUU53.bitnet Subject: partial toc; version 2 To: bk4@DHDURZ1.BITNET X-Organization: Medical Faculty, University of Utrecht, The Netherlands Status: R X-Status: X-Keywords: X-UID: 201 Rainer, here is version 2 of my partial toc solution. I've included a test LaTeX file with a corresponding test document style. I'm not saying it's finished, but it's going in the right direction. Feel free to put it on the list if you want. [Which I herewith do - Rainer] Nico Poppelier Elsevier Science Publishers, PSED, R&D Department Sara Burgerhartstraat 25, 1055 KV Amsterdam, The Netherlands Phone: +(20)5862504. Fax: +(20)5862425. Email: n.poppelier@elsevier.nl P.S.: the backup address, poppelier@hutruu53, has changed to poppelier@med.ruu.nl ------------------------------ test.tex ------------------------------ \documentstyle{test} \begin{document} \chapter{Between now and the turn of the century} \settocdepth{subsection} \tableofcontents* \section{It is widely} It is widely believed that between now and the turn of the century a substantial fraction of basic and applied scientists will be working on problems concerning structures characterized by the lack of conventional geometrical order. \subsection{Random materials} Random materials constitute a very large part of our natural environment as well as a substantial fraction of man-made objects. \subsection{Glasses} Glasses, polymers and amorphous materials are among the vast array of examples. On a larger scale, porous media, composites and suspensions can be mentioned. \subsection{Although the} Although the basic new ideas are finding widespread application, the field is troubled by the fact that a single coherent set of books that cover these new developments does not exist. \section{Indeed since} Indeed, since the field is truly interdisciplinary, the written accounts are as likely to be found in physics and chemistry books and journals as they are to be found on the shelves labeled ``materials science'' or ``engineering''. \subsection{The basic ideas} The basic ideas in the subject (such as percolation, fractals, and random fields) were generally introduced in connection with microscopic problems. \subsection{It has} It has, however, become clear to a community of scientists that these ideas are relevant to a broad spectrum of applications dealing with materials science where the disorder is at an intermediate or ``mesoscopic'' scale. \subsection{Not only} Not only static structures but also dynamic effects should be included. Examples are found in the growth processes of aggregates, in chemical dispersion within a fractured rock, in oceans, or in the structure of a flame front. In order to encompass this whole field, we are introducing this coherent series of books designed to reach engineers, scientists and mathematicians interested in recent progress in this multidisciplinary field. \newpage \chapter{Between now and the turn of the century} \section{It is widely} It is widely believed that between now and the turn of the century a substantial fraction of basic and applied scientists will be working on problems concerning structures characterized by the lack of conventional geometrical order. \begin{figure}[ht] \vspace{10mm} \caption{It is widely figure} \end{figure} \subsection{Random materials} Random materials constitute a very large part of our natural environment as well as a substantial fraction of man-made objects. \begin{figure}[ht] \vspace{10mm} \caption{Random figure} \end{figure} \subsection{Glasses} Glasses, polymers and amorphous materials are among the vast array of examples. On a larger scale, porous media, composites and suspensions can be mentioned. \begin{figure}[ht] \vspace{10mm} \caption{Glasses figure} \end{figure} \subsection{Although the} Although the basic new ideas are finding widespread application, the field is troubled by the fact that a single coherent set of books that cover these new developments does not exist. \begin{figure}[ht] \vspace{10mm} \caption{Although figure} \end{figure} \section{Indeed since} \listoffigures* Indeed, since the field is truly interdisciplinary, the written accounts are as likely to be found in physics and chemistry books and journals as they are to be found on the shelves labeled ``materials science'' or ``engineering''. \begin{figure}[ht] \vspace{10mm} \caption{Indeed figure} \end{figure} \subsection{The basic ideas} The basic ideas in the subject (such as percolation, fractals, and random fields) were generally introduced in connection with microscopic problems. \begin{figure}[ht] \vspace{10mm} \caption{Basic figure} \end{figure} \subsection{It has} It has, however, become clear to a community of scientists that these ideas are relevant to a broad spectrum of applications dealing with materials science where the disorder is at an intermediate or ``mesoscopic'' scale. \begin{figure}[ht] \vspace{10mm} \caption{It has figure} \end{figure} \subsection{Not only} Not only static structures but also dynamic effects should be included. Examples are found in the growth processes of aggregates, in chemical dispersion within a fractured rock, in oceans, or in the structure of a flame front. In order to encompass this whole field, we are introducing this coherent series of books designed to reach engineers, scientists and mathematicians interested in recent progress in this multidisciplinary field. \begin{figure}[ht] \vspace{10mm} \caption{Not only figure} \end{figure} \end{document} ------------------------------ test.sty ------------------------------ % TEST DOCUMENT STYLE -- Released 18 Jul 90 % for LaTeX version 2.09 % Copyright (C) 1990 by Nico Poppelier \typeout{Document Style `test' <18 Jul 90>.} \input toc.sty\relax % read re-definitions of existing parts of % LaTeX 2.09 and definitions of extra macros % **************************************** % * FONTS * % **************************************** % \lineskip 1pt % \lineskip is 1pt for all font sizes. \normallineskip 1pt \def\baselinestretch{1} \def\@normalsize{\@setsize\normalsize{12pt}\xpt\@xpt \abovedisplayskip 10pt plus2pt minus5pt \belowdisplayskip \abovedisplayskip \abovedisplayshortskip \z@ plus3pt \belowdisplayshortskip 6pt plus3pt minus3pt} \normalsize % Choose the normalsize font. % **************************************** % * PAGE LAYOUT * % **************************************** % \oddsidemargin 0pt % Left margin on odd-numbered pages. \evensidemargin 0pt % Left margin on even-numbered pages. \topmargin 50pt % Nominal distance from top of page to top of % box containing running head. \headheight 12pt % Height of box containing running head. \headsep 20pt % Space between running head and text. \footskip 25pt % Distance from baseline of box containing foot % to baseline of last line of text. \textheight=45\baselineskip \advance\textheight\topskip % Height of part of page containing text \textwidth 24pc % Width of text line. % **************************************** % * FIGURES AND TABLES * % **************************************** % \setcounter{topnumber}{2} \def\topfraction{0.95} \setcounter{bottomnumber}{2} \def\bottomfraction{0.9} \setcounter{totalnumber}{3} \def\textfraction{0.05} \def\floatpagefraction{0.5} \setcounter{dbltopnumber}{2} \def\dbltopfraction{0.7} \def\dblfloatpagefraction{0.5} % \@makecaption{NUMBER}{TEXT} : Macro to make a figure or table caption. \long\def\@makecaption#1#2{\setbox\@tempboxa\hbox{{\bf #1} #2} \ifdim \wd\@tempboxa >\hsize {\bf #1} #2\par \else \hbox to\hsize{\hfil\box\@tempboxa\hfil}\fi} % **************************************** % * SECTIONAL UNITS * % **************************************** % \new@level{chapter} \new@level{section}[chapter] \new@level{subsection}[section] \def\thechapter{\arabic{chapter}} \def\thesection{\thechapter.\arabic{section}} \def\thesubsection{\thesection.\arabic{subsection}} \setsecnumdepth{subsection} \def\chapter{\@startsection{chapter}{\z@}{-4ex plus -0.4ex minus -0.2ex}{0.0001pt}{\normalsize\bf}} \def\section{\@startsection{section}{\z@}{-2ex plus -0.2ex minus -0.1ex}{0.0001pt}{\normalsize\rm}} \def\subsection{\@startsection{subsection}{\z@}{-2ex plus -0.2ex minus -0.1ex}{0.0001pt}{\normalsize\sl}} % **************************************** % * TABLE OF CONTENTS * % **************************************** % % Note: here we feel the need for two new attributes of a % sectional-unit command, instead of the old starred and un-starred % versions. The table of contents heading should not just be an % un-numbered heading, but also it should not appear in the table of % contents. In version 2.09 this cannot be solved. % \def\tableofcontents{\@ifstar{\@parttoc}{\@fulltoc}} % a full table of contents is an un-numbered chapter \def\@fulltoc{\chapter*{Table of contents} \@partialtabfalse\@starttoc{toc}} % a partial table of contents is an % - un-numbered section for level 0 (chapter) % - un-numbered subsection, for level 1 (section) \def\@parttoc{\ifcase\cur@level \section*{Table of contents} \min@level=\dl@section \or \subsection*{Table of contents} \min@level=\dl@subsection \else\relax\fi \@partialtabtrue \@starttoc{toc}} \def\l@chapter#1#2{\vskip 1ex \@tocline{\thechapter}{#1}{#2}} \def\l@section#1#2{\@tocline{\thesection}{#1}{#2}} \def\l@subsection#1#2{\@tocline{\thesubsection}{#1}{#2}} \def\l@paragraph#1#2{\@tocline{\theparagraph}{#1}{#2}} \def\l@figure#1#2{\@tocline{\thefigure}{#1}{#2}} % a full list of figures is an un-numbered chapter \def\@fulllof{\chapter*{List of figures} \@partialtabfalse\@starttoc{lof}} % a partial list of figures is an % - un-numbered section for level 0 (chapter) % - un-numbered subsection, for level 1 (section) \def\@partlof{\ifcase\cur@level \section*{List of figures} \min@level=\dl@section \or \subsection*{List of figures} \min@level=\dl@subsection \else\relax\fi \@partialtabtrue \@starttoc{lof}} \def\listoffigures{\@ifstar{\@partlof}{\@fulllof}} % macros for formatting one .toc, .lof, ... entry \newdimen\@tocnumdim \settowidth\@tocnumdim{10.9.10} \def\@number#1{\hbox to \@tocnumdim{#1\hfil}} \def\@tocline#1#2#3{{\interlinepenalty\@M \leftskip\z@ \rightskip=1em plus 1fil \parindent\z@ \parfillskip\z@ \leavevmode \hangafter1 \hangindent\@tempdima \ifnum\cur@count=0 \@number{}\else \@number{#1}\fi \nobreak #2 \hskip1em \nobreak{\sl #3}\par}} % **************************************** % * FLOATS * % **************************************** % \newcounter{figure}[chapter] \def\thefigure{\thesection.\alph{figure}} \def\fps@figure{htb} \def\ftype@figure{1} \@extension{figure}{lof} \def\fnum@figure{Figure \thefigure} \def\figure{\@float{figure}} \let\endfigure\end@float % **************************************** % * INITIALIZATION * % **************************************** % % Default initializations \smallskipamount=.5\parskip % These values are used by the letter macros. \medskipamount=\parskip \bigskipamount=2\parskip \ps@plain % 'plain' page style \pagenumbering{arabic} % Arabic page numbers \onecolumn % Single-column \@fileswtrue % Inhibits writing of .AUX file. ------------------------------ toc.sty ------------------------------ % TOC DOCUMENT STYLE -- Released 18 Jul 90 % for LaTeX version 2.09 % Copyright (C) 1990 by Nico Poppelier \typeout{Document Style `toc' <18 Jul 90>.} % **************************************** % * SECTIONAL-UNIT LEVELS * % **************************************** % % \new@level{LEVEL}[WITHIN] % - if X = \n@level, then define % \dl@LEVEL == X and \dln@X == LEVEL % - allocate an extra counter \xc@LEVEL, to be used to save % the original counter value while we are generating the TOC, % during which \c@LEVEL holds the counter value that is read % from the .toc file % - \newcounter{LEVEL} is the last part of the macro, so it picks up % the optional argument, if this is present \newcount\n@level \n@level=\m@ne \def\new@level#1{\advance\n@level\@ne \expandafter\xdef\csname dl@#1\endcsname{\the\n@level} \expandafter\gdef\csname dln@\the\n@level\endcsname{#1} \expandafter\newcount\csname xc@#1\endcsname \expandafter\gdef\csname #1mark\endcsname##1{} \newcounter{#1}} % **************************************** % * TABLE FILES * % **************************************** % % In the document style, the definitions % \def\ext@figure{lof} % \def\ext@table{lot} % are replaced by % \@extension{figure}{lof} % \@extension{table}{lot} % \@extension{TYPE}{EXT}: % - globally defines \ext@TYPE == EXT % - globally sets \@extlist := \@extlist * \@op {EXT} % for TYPE = type of float object, EXT = file extension. % The .toc file is always on the list. \newtoks\@extlist \@extlist={\@op{toc}} \def\@extension#1#2{\expandafter\gdef\csname ext@#1\endcsname{#2} \begingroup \let\@op\relax \xdef\@tempa{\noexpand\@extlist={\the\@extlist\@op{#2}}} \endgroup \@tempa} % **************************************** % * TABLE OF CONTENTS * % * (PROCESSING THE INFORMATION) * % **************************************** % % The command \contentsline{NAME} executes \l@NAME. % So, to specify the table of contents, we must define \l@chapter, % \l@section, \l@subsection, ... ; to specify the list of figures, we must % define \l@figure; and so on. % % If a full table (of contents, of figures, ...) must be produced, we % read the entire table file, e.g. JOB.toc or JOB.lof. If a partial table % (of contents, of figures, ...) must be produced, we set up a restriction % and then read the entire table file, but only execute those entries that % satisfy the restriction. \newcount\cur@level \cur@level=\m@ne \newcount\cur@count \cur@count=\m@ne % \currentsection{TYPE}{NUMBER} \def\currentsection#1#2{\cur@level=\csname dl@#1\endcsname \cur@count=#2 \csname c@#1\endcsname=#2} % \contentsline{TYPE}{NUMBER}{TITLE}{PAGE} % arguments are absorbed, but nothing is done with them % Making a partial TOC at level D for counter values (c_0, ..., c_D) % means that only those entries are processed for which we have % \min@level <= \cur@level AND % \cur@level <= \max@level AND % (c_0, ..., c_D) = (r_0, ..., r_D) % \min@level and D are dependent, since we have: \min@level= D+1. % r_k is the value of the k-th counter as read from the table file. % % \check@result := true; % FOR k := 0 TO d DO % \check@result := \check@result AND (c_k = r_k) % OD % \check@result := \check@result AND % (\min@level <= \cur@level) AND (\cur@level <= \max@level) % % We translate each of these D+3 conditions to true = 1, false = 0. % If the result is 1 we process the entry, otherwise we don't. % % One \@whilenum loop is used to build up a token list. The token list % is used to simulate a loop in the decision whether to process % a certain entry. % % \if@partialtab indicates whether the table currently being constructed % is a partial one (\@partialtabtrue) or a full one (\@partialtabfalse) \newif\if@partialtab \@partialtabfalse \newtoks\@levlist \newcount\min@level \newcount\max@level \def\@addlevel#1{\begingroup \let\@op\relax \xdef\@tempa{\noexpand\@levlist={\the\@levlist\@op{#1}}} \endgroup \@tempa} \def\settocdepth#1{\c@tocdepth=\csname dl@#1\endcsname} \def\setsecnumdepth#1{\c@secnumdepth=\csname dl@#1\endcsname} \def\@starttoc#1{\begingroup % build list of all counters that need to be compared % \min@level should be set by calling macro \if@partialtab \@tempcnta\z@ \@levlist={} \max@level=\c@tocdepth \@whilenum \@tempcnta<\min@level\do% {\edef\@tempa{\noexpand\@addlevel{\csname dln@\the\@tempcnta\endcsname}} \@tempa \advance\@tempcnta\@ne} \fi % save the global values of the counters \c@TYPE in \xc@TYPE \def\@op##1{\csname xc@##1\endcsname=\csname c@##1\endcsname}\the\@levlist % define condition on counter values \def\@op##1{\ifnum\csname c@##1\endcsname=\csname xc@##1\endcsname \else \check@result\z@ \fi} % read .toc file \makeatletter \@input{\jobname.#1} \if@filesw \expandafter\newwrite\csname tf@#1\endcsname \expandafter\openout \csname tf@#1\endcsname \jobname.#1\relax\fi \global\@nobreakfalse \endgroup} \newcount\check@result \def\@checkentry{\check@result\@ne \ifnum\cur@level<\min@level \check@result\z@ \fi \ifnum\cur@level>\max@level \check@result\z@ \fi \the\@levlist} \def\contentsline#1#2#3#4{\csname c@#1\endcsname=#2 \if@partialtab\@checkentry\else\check@result\@ne\fi \ifnum\check@result=\@ne \csname l@#1\endcsname{#3}{#4}\fi} \def\contentsextra#1{\if@partialtab\@checkentry\else\check@result\@ne\fi \ifnum\check@result=\@ne #1\fi} % **************************************** % * TABLE OF CONTENTS * % * (GENERATING THE INFORMATION) * % **************************************** % % Entries in the table of contents, or another table file, are % generated by a call to % \addcontentsline{EXT}{TYPE}{ENTRY} % % For every sectional-unit command \TYPE the following instructions must % be written to the .aux file: % \currentsection{TYPE}{NUMBER} % \contentsline{TYPE}{NUMBER}{TITLE}{PAGE} % % For every sectional-unit command \TYPE the following instruction must % also be written to all table files, e.g. the .lof and .lot files: % \currentsection{TYPE}{NUMBER} % % For every caption of a float object TYPE the following % instruction must be written to the corresponding table file: % \contentsline{TYPE}{NUMBER}{TITLE}{PAGE} % % Extra instructions, added via \addtocontents{EXT}{TEXT}, % must result in the following line, without the in this case % irrelevant page number, on the .EXT file % \contentsextra{TEXT} % % Legend: % NUMBER = the value of the counter corresponding to LEVEL % PRINT = y: print number of sectional unit in table of cont % n: do not print number % TITLE = heading of sectional unit % PAGE = page number (formatted) % \def\addcontentsline#1#2#3{\if@filesw \begingroup \let\label\@gobble \let\index\@gobble \let\glossary\@gobble \def\protect##1{\string\string\string##1\string\space \space}\@temptokena{\thepage}% \edef\@tempa{\write \@auxout{\string\@writefile{#1}{\protect \contentsline{#2}{\the\cur@count}{#3}{\the\@temptokena}}}}\@tempa \if@nobreak \ifvmode\nobreak\fi\fi\endgroup\fi} \def\addcurrentsection#1{\if@filesw \begingroup \def\protect##1{\string\string\string##1\string\space \space}\edef\@tempa {\write\@auxout{\string\currentsection{#1}{\the\cur@count}}}\@tempa \def\@op##1{\edef\@tempa{\write \@auxout{\string\@writefile{##1}{\protect \currentsection{#1}{\the\cur@count}}}}\@tempa} \the\@extlist \if@nobreak \ifvmode\nobreak\fi\fi\endgroup\fi} \long\def\addtocontents#1#2{\if@filesw \begingroup \let\label\@gobble \let\index\@gobble \let\glossary\@gobble \def\protect##1{\string\string\string##1\string\space\space}% \edef\@tempa{\write \@auxout{\string\@writefile{#1}{\protect \contentsextra{#2}}}}\@tempa \if@nobreak \ifvmode\nobreak\fi\fi\endgroup\fi} % **************************************** % * SECTIONS * % **************************************** % % \@startsection{NAME}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE} == \def\@startsection#1#2#3#4#5{\if@noskipsec \leavevmode \fi \par \@tempskipa #3\relax \@afterindenttrue \cur@level=\csname dl@#1\endcsname \ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse\fi \if@nobreak \everypar{}\else \addpenalty{\@secpenalty}\addvspace{\@tempskipa}\fi \@ifstar {\@ssect{#1}{#2}{#3}{#4}{#5}}{\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}}}} % \@sect{NAME}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}[ARG1]{ARG2} == \def\@sect#1#2#3#4#5[#6]#7{\ifnum \cur@level>\c@secnumdepth \cur@count=\m@ne \def\@svsec{} \else \refstepcounter{#1} \cur@count=\csname c@#1\endcsname \edef\@svsec{\csname the#1\endcsname\hskip 1em }\fi \addcurrentsection{#1} \@tempskipa #4\relax \ifdim \@tempskipa>\z@ \begingroup #5\relax \@hangfrom{\hskip #2\relax\@svsec}{\interlinepenalty \@M #7\par}% \endgroup \csname #1mark\endcsname{#6}\addcontentsline{toc}{#1}{#6}\else \def\@svsechd{#5\hskip #2\@svsec #7\csname #1mark\endcsname {#6}\addcontentsline{toc}{#1}{#6}}\fi \@xsect{#4}} % \@ssect{NAME}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}{ARG} == \def\@ssect#1#2#3#4#5#6{\cur@count=\m@ne \addcurrentsection{#1} \@tempskipa #4\relax \ifdim \@tempskipa>\z@ \addcontentsline{toc}{#1}{#6} \begingroup #5\@hangfrom{\hskip #2}{\interlinepenalty \@M #6\par}\endgroup \else \def\@svsechd{#5\hskip #1\relax #6 \addcontentsline{toc}{#1}{#6}}\fi \@xsect{#4}} % **************************************** % * FLOATS * % **************************************** % % \addcontentsline is used in the following part of LATEX.TEX, where % it should be changed as follows (the \numberline part is removed): % \long\def\@caption#1[#2]#3{\cur@count=\csname c@#1\endcsname \par \addcontentsline{\csname ext@#1\endcsname}{#1}{{\ignorespaces #2}} \begingroup \@parboxrestore \normalsize \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par \endgroup}