#!/usr/bin/env python3 # tenkana, a spider that jumps from the checkpoints of your TeX document. # Copyright © 2026 निरंजन (Niranjan) # # tenkana is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your # option) any later version. # # tenkana is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with tenkana. If not, see . # # tenkana was written by Claude, a large language model (LLM) made by # Anthropic. Courts are divided on whether material generated by an LLM can be # protected by copyright. Should it be found that the copyright claimant # cannot hold copyright in any part of tenkana, that part is in the public # domain. Wherever copyright does hold, tenkana is distributed under the terms # of the GNU General Public License, version 3 or (at your option) any later # version, as stated above. """Generate ch01.tex .. ch12.tex for the test book (book.tex): ~220 pages of lipsum text, theorems, align blocks, siunitx tables, pgfplots and TikZ figures, with \\label/\\cref/\\pageref cross-references.""" for c in range(1, 13): s = [f"\\chapter{{Chapter {c}}}\\label{{ch:{c}}}\n"] for sec in range(1, 7): s.append(f"\\section{{Section {c}.{sec}}}\\label{{sec:{c}-{sec}}}\n") s.append(f"\\lipsum[{sec}-{sec+3}]\n") s.append( f"\\begin{{theorem}}\\label{{thm:{c}-{sec}}} For all $x>0$, " f"$\\int_0^x e^{{-t^2}}\\,dt < \\frac{{\\sqrt\\pi}}{{2}}$ and " f"\\SI{{{c}.{sec}}}" f"{{\\kilo\\gram\\metre\\per\\second\\squared}}." f"\\end{{theorem}}\n" ) s.append( "\\begin{align}\n f(x) &= \\sum_{n=0}^{\\infty} " "\\frac{f^{(n)}(a)}{n!}(x-a)^n \\\\\n" " g(x) &= \\prod_{k=1}^{N} \\left(1+\\frac{x}{k}\\right)\n" "\\end{align}\n" ) s.append( f"See \\cref{{sec:{c}-{sec}}} and \\cref{{thm:{c}-{sec}}} " f"on page~\\pageref{{thm:{c}-{sec}}}.\n" ) if sec % 2 == 0: s.append( "\\begin{figure}[htbp]\\centering\n" "\\begin{tikzpicture}\n" "\\begin{axis}[width=8cm,height=5cm,xlabel=$x$,ylabel=$y$]\n" f"\\addplot[blue,domain=0:{c+sec},samples=80]" f"{{sin(deg(x))*exp(-x/{c+2})}};\n" f"\\addplot[red,domain=0:{c+sec},samples=80]" "{cos(deg(x))};\n" "\\end{axis}\\end{tikzpicture}\n" f"\\caption{{Plot {c}.{sec}}}\\label{{fig:{c}-{sec}}}" "\\end{figure}\n" ) else: s.append( "\\begin{figure}[htbp]\\centering\n" "\\begin{tikzpicture}[node distance=1.6cm,>=Stealth]\n" "\\node[draw,rounded corners] (a) {Input};\n" f"\\node[draw,circle,right=of a] (b) {{$f_{{{c}}}$}};\n" "\\node[draw,diamond,aspect=2,right=of b] (c) {Test};\n" "\\node[draw,right=of c] (d) {Output};\n" "\\draw[->] (a)--(b); \\draw[->] (b)--(c); " "\\draw[->,decorate,decoration=snake] (c)--(d);\n" "\\draw[->] (c.south) .. controls +(0,-1) and +(0,-1) .. " "(b.south);\n" f"\\end{{tikzpicture}}\\caption{{Diagram {c}.{sec}}}" f"\\label{{fig:{c}-{sec}}}\\end{{figure}}\n" ) s.append( "\\begin{table}[htbp]\\centering\\begin{tabular}{lSS}" "\\toprule Item & {Value} & {Error}\\\\\\midrule\n" ) for r in range(6): s.append(f"R{r} & {c*1.5+r:.3f} & {0.01*(r+1):.3f}\\\\\n") s.append("\\bottomrule\\end{tabular}\\caption{Data}\\end{table}\n") s.append(f"\\lipsum[{sec+10}-{sec+14}]\n") open(f"ch{c:02d}.tex", "w").write("".join(s)) print("wrote ch01.tex .. ch12.tex")