aboutsummaryrefslogtreecommitdiff
path: root/scripts/tex.py
diff options
context:
space:
mode:
authorMax-001 <80035972+Max-001@users.noreply.github.com>2024-09-18 16:26:02 +0200
committerMax-001 <80035972+Max-001@users.noreply.github.com>2024-09-18 16:26:02 +0200
commitf9071704c1cb74667d9da6c1429e75bc509cb244 (patch)
treea90dba1b0624f871bf258d7107c64849f6f15117 /scripts/tex.py
parent105cab5fc6f88f7e71e71910c5f598d39fba3262 (diff)
parent6b3fa9ceaf539b1bdcddf6284326a67c127d93a4 (diff)
Merge remote-tracking branch 'origin/master' into max/research
Diffstat (limited to 'scripts/tex.py')
-rw-r--r--scripts/tex.py37
1 files changed, 33 insertions, 4 deletions
diff --git a/scripts/tex.py b/scripts/tex.py
index 2509a87..07d275a 100644
--- a/scripts/tex.py
+++ b/scripts/tex.py
@@ -9,6 +9,9 @@ def group(*args):
out += "{" + arg + "}"
return out
+def join(*things):
+ return "".join(things)
+
def string(content):
return r"\string" + content
@@ -18,11 +21,14 @@ def cmd(*args):
if len(args) == 0: args = [""]
return f"\\{name}" + group(*args)
+def pedef(*args):
+ return r"\protected@edef" + cmd(*args)
+
def csdef(*args):
return r"\def" + cmd(*args)
-def auxout(content):
- return r"\write\@auxout" + group(content)
+def auxout(*content):
+ return r"\write\@auxout" + group(join(*content))
def scmd(*args):
return string(cmd(*args))
@@ -47,6 +53,29 @@ def esc(plain):
def tabrule(*cells):
return "&".join(cells) + "\\\\"
-def label2ref(*labels):
- return ",".join(["req:" + label.replace('.', ':') for label in labels])
+def withatletter(*content):
+ return join(
+ cmd('makeatletter'),
+ *content,
+ cmd('makeatother'),
+ )
+
+def explist(*items):
+ out = []
+ for item in items:
+ if isinstance(item, str) or not hasattr(item, '__iter__'):
+ out.append(item)
+ else:
+ out += explist(*item)
+ return out
+
+def sec(level, heading):
+ level = max(min(3, level), 0)
+ section = [
+ 'section',
+ 'subsection',
+ 'subsubsection',
+ 'paragraph',
+ ][level]
+ return cmd(section, heading)