10 Appendix - Manual für das Schreiben dieses Skripts
Parts of these lecture notes are generated automatically with javascript. This includes chapter and subchapter numbering, links to next and previous chapters, the table of content, and theorem numbering.
-
If you want to add a new chapter, you have to do two things:
add an entry to table-of-contents.js. Just
follow the format
there. Then add the linked file. Best to copy an existing file, a "chapter" or a
"subchapter" file, depending
on the new file you want to create. The ordering in which they appear (in the table of
content and in the link structure
given by the
next
nadprev
navigation links) is determined purely by the order in which they appear in table-of-contents.js. -
Theorem environments (theorems, lemmas, conjectures) can be created as follows:
Sauer-Shelah lemma 10.1 Let
. If then there exists some set of indices with such that in other words, the set of coordinates is shattered.<div class='well container theorem'> <p><span class='numbered-title' id="sauer-shelah-lemma" data-label-title="Lemma">Lemma</span> <strong>(Sauer-Shelah lemma). </strong>Let $A \subseteq \{0,1\}^n$. If $|A| \gt {\rm vol}(n,r-1)$ then there exists some set $I \subseteq [n]$ of indices with $|I| \geq r$ such that</p> \begin{align*} \{ \mathbf{x}_I \ | \ \mathbf{x} \in A\} = \{0,1\}^r \ , \end{align*} in other words, the set $I$ of coordinates is shattered. </div class='well container theorem'>
You must give the environmentdiv
the classtheorem
and the titlespan
the classnunbered-title
, otherwise the automatic numbering will not work.The attributes
id="sauer-shelah-lemma"
anddata-label-title="Lemma"
are necessarily for automatic referencing. Here is how you create a reference:This follows easily from the Sauer-Shelah lemma 9.1 just above and Theorem 2.2.1.and here is the source code:Remember that <span class="reference" data-ref="theorem-N-N^2"></span> shows that $\N$ and $\N^2$ are equipotent.
To work, the id
of a theorem (or a general environment) has to be unique
across all files of the lecture notes.
Also, since we have to correctly compute the numbering of theorems like Theorem 2.2.1,
we would have to read the file containing it. So we'd have to write code that, while loading
Chapter 9, loads all chapters
of referenced environments. Potentially, this forces the browser to load the entire
lecture notes each time
a single file is loaded. This would take too much time, so we use a precompilation step:
I wrote an html page
put-all-in-one-page.html
that loads the table of content and all chapters (which takes
quite a substantial amount of time, like 20 seconds or so) and extracts all
environments with class theorem
or exercise
that have
also class numbered-title
and numbers them. If the environment
has the attribute data-label-title
, then it adds an entry to a global
dictionary. At the end, when all has been loaded, the web page will show
this dictionary as a json object.
You should then copy this table and paste it in the beginning of the file nunmber-my-theorems.js. The point is that creating the table is expensive (must read all chapters) but using it is cheap.
http-server . --corsOnce this server is running, go to
http://localhost:8080
in your browser.