]> mj.ucw.cz Git - saga.git/blobdiff - macros.tex
Added mention of red and blue rules to the intro of opt.
[saga.git] / macros.tex
index 9dba90d1254a2e17775ee07d50a5d61d843b286e..5877abacfe422071815ee42efd7d0583e583438c 100644 (file)
 \newcount\chapcount
 \newcount\seccount
 \newcount\thmcount
-\chapcount=0
+\chapcount=-1
 \seccount=0
 \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
 \thmcount=0
 \edef\currentid{\the\chapcount.\the\seccount}
 \leftline{\secfont\currentid. #1}
+\nobreak
 \medskip
+\nobreak
+\writetoc{sec}{#1}
 }
 
 \def\para{\advance\thmcount by 1
 \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