From 6617b4a0f42121f0525d461aab9e940e3a3181e1 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 19 Apr 2008 19:00:20 +0200 Subject: [PATCH] Table of contents. --- Makefile | 2 +- adv.tex | 2 +- dyn.tex | 2 +- macros.tex | 38 ++++++++++++++++++++++++++++++++++---- rank.tex | 2 +- saga.tex | 3 +++ 6 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9d0d809..e387ee0 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ saga.dvi: $(addsuffix .tex,$(CHAPTERS)) dvipdfm -o $@ -p a4 -r 600 -z 9 $< mostlyclean: - rm -f *.dvi *.log *~ core *.o *.aux *.bbl *.blg *.ids + rm -f *.dvi *.log *~ core *.o *.aux *.bbl *.blg *.ids *.toc clean: mostlyclean rm -f *.ps *.pdf diff --git a/adv.tex b/adv.tex index b5ca232..1051525 100644 --- a/adv.tex +++ b/adv.tex @@ -1051,7 +1051,7 @@ preprocessing in linear time, the queries require $\Omega(\alpha(n))$ time. %-------------------------------------------------------------------------------- -\section{A~randomized algorithm}\id{randmst}% +\section{A randomized algorithm}\id{randmst}% When we analysed the contractive Bor\o{u}vka's algorithm in Section~\ref{contalg}, we observed that while the number of vertices per iteration decreases exponentially, diff --git a/dyn.tex b/dyn.tex index 3024256..41a5e2d 100644 --- a/dyn.tex +++ b/dyn.tex @@ -515,7 +515,7 @@ to fit our needs, so we omit the details. %-------------------------------------------------------------------------------- -\section{Dynamic MSF} +\section{Dynamic spanning forests} Let us turn our attention back to the dynamic MSF now. Most of the early algorithms for dynamic connectivity also imply $\O(n^\varepsilon)$ diff --git a/macros.tex b/macros.tex index 9dba90d..77f8c26 100644 --- a/macros.tex +++ b/macros.tex @@ -328,14 +328,18 @@ \thmcount=0 \def\currentid{??} -\def\chapter#1{\vfill\supereject -\advance\chapcount by 1 +\def\rawchapter#1{\vfill\supereject +\leftline{\chapfont #1} +\bigskip +} + +\def\chapter#1{\advance\chapcount by 1 \seccount=0 \thmcount=0 \footcnt=0 \edef\currentid{\the\chapcount} -\leftline{\chapfont\currentid. #1} -\bigskip +\rawchapter{\currentid. #1} +\writetoc{chap}{#1} } \def\section#1{\bigskip @@ -343,7 +347,10 @@ \thmcount=0 \edef\currentid{\the\chapcount.\the\seccount} \leftline{\secfont\currentid. #1} +\nobreak \medskip +\nobreak +\writetoc{sec}{#1} } \def\para{\advance\thmcount by 1 @@ -382,6 +389,29 @@ \def\proof{\noindent {\sl Proof.}\enspace} \def\proofsketch{\noindent {\sl Proof sketch.}\enspace} +%%% Table of contents %%% + +\newwrite\toc +\immediate\openout\toc=\jobname.toc +\newif\iftoc +\tocfalse + +\def\writetoc#1#2{ + \toctrue + \toks0={\the\count0} + \edef\tocaux{\write\toc{\noexpand\expandafter\noexpand\string\noexpand\csname toc#1\noexpand\endcsname{\currentid}{#2}{\the\toks0}}} + \tocaux + \tocfalse +} + +\def\includetoc{ +\immediate\closeout\toc +\input \jobname.toc +} + +\def\tocchap#1#2#3{\smallskip\line{\bo #1.~~#2 \dotfill ~#3}} +\def\tocsec#1#2#3{\line{#1.~~#2 \dotfill ~#3}} + %%% References %%% \newwrite\ids diff --git a/rank.tex b/rank.tex index 82c191b..28a5430 100644 --- a/rank.tex +++ b/rank.tex @@ -208,7 +208,7 @@ array~$\alpha$ and update~$\alpha^{-1}$ accordingly. %-------------------------------------------------------------------------------- -\section{Ranking of {\secitfont k\/}-permutations} +\section{Ranking of \iftoc $k$\else{\secitfont k\/}\fi-permutations} \id{kpranksect} The technique from the previous section can be also generalized to lexicographic ranking of diff --git a/saga.tex b/saga.tex index 6fbc7fc..21331ea 100644 --- a/saga.tex +++ b/saga.tex @@ -14,4 +14,7 @@ \chapter{Bibliography} \dumpbib +\rawchapter{Table of contents} +\includetoc + \bye -- 2.39.2