]> mj.ucw.cz Git - saga.git/blobdiff - macros.tex
Book style.
[saga.git] / macros.tex
index 52b2835c08e15bc6ae711518d605ecac7dc68b01..b7f43851465e8b438812e34eb3d447a03afc45f5 100644 (file)
 \thmcount=0
 \def\currentid{??}
 
-\def\chapter#1{\vfill\supereject
-\advance\chapcount by 1
+\def\rawchapter#1{\vfill\supereject
+\leftline{\chapfont #1}
+\bigskip
+}
+
+\def\unchapter#1{
+\rawchapter{#1}
+\writetoc{unchap}{#1}
+}
+
+\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\problemn{\problem\labelx}
 \def\remn{\rem\labelx}
 
-\def\paran#1{\para {\sl #1:\/}\enspace}
+\def\paran#1{\para {\sl #1.\/}\enspace\kern 0pt}
 
 \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
+}
+
+\newwrite\tok
+\def\includetoc{
+\immediate\openin\tok=\jobname.tok
+\ifeof\tok
+\else
+\input \jobname.tok
+\fi
+\immediate\closein\tok
+}
+
+\def\tocchap#1#2#3{\smallskip\line{\bo #1.~~#2 \dotfill ~#3}}
+\def\tocsec#1#2#3{\line{#1.~~#2 \dotfill ~#3}}
+\def\tocunchap#1#2#3{\smallskip\line{\bo #2 \dotfill ~#3}}
+
 %%% References %%%
 
 \newwrite\ids