10 Appendix - Manual für das Schreiben dieses Skripts

Dieses Kapitel sind ausschließlich persönliche Notizen für mich dazu, wie man "korrekt" dieses Skript schreibt, insbesondere wie man die automatische Numerierung verwendet. Es ist also natürlich nicht Stoff der Vorlesung.

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.

  1. 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 nad prev navigation links) is determined purely by the order in which they appear in table-of-contents.js.
  2. Theorem environments (theorems, lemmas, conjectures) can be created as follows:

    Sauer-Shelah lemma 10.1 Let A{0,1}n. If |A|>vol(n,r1) then there exists some set I[n] of indices with |I|r such that

    {xI | xA}={0,1}r , in other words, the set I of coordinates is shattered.
    and here is the source code:
    <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 environment div the class theorem and the title span the class nunbered-title, otherwise the automatic numbering will not work.

    The attributes id="sauer-shelah-lemma" and data-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.
  3. 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.

    Important: The page put-all-in-one-page.html does not work if you just open it by double-clicking in your file explorer. It has to be hosted by an http-server server with CORS enabled, for example
                                  http-server .  --cors
    Once this server is running, go to http://localhost:8080 in your browser.