From befa7245516fbd2fcea5ab6485c2a2e194829b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Thu, 19 Mar 2026 15:45:29 -0600 Subject: [PATCH] fix: native latex prelude --- .../net/deertopia/doerg/native-prelude.tex | 5 ++ .../net/deertopia/doerg/preview-template.tex | 49 ++----------------- doerg/src/net/deertopia/doerg/tex/native.clj | 10 +++- 3 files changed, 17 insertions(+), 47 deletions(-) create mode 100644 doerg/resources/net/deertopia/doerg/native-prelude.tex diff --git a/doerg/resources/net/deertopia/doerg/native-prelude.tex b/doerg/resources/net/deertopia/doerg/native-prelude.tex new file mode 100644 index 0000000..dcb191c --- /dev/null +++ b/doerg/resources/net/deertopia/doerg/native-prelude.tex @@ -0,0 +1,5 @@ +% Default uses arrow glyphs from the active font, which are kinda ugly in the +% case of Plex. +\tikzcdset{ + arrow style=tikz +} diff --git a/doerg/resources/net/deertopia/doerg/preview-template.tex b/doerg/resources/net/deertopia/doerg/preview-template.tex index 930fa44..83bb101 100644 --- a/doerg/resources/net/deertopia/doerg/preview-template.tex +++ b/doerg/resources/net/deertopia/doerg/preview-template.tex @@ -7,56 +7,13 @@ \usepackage{quiver} \usepackage{tikz} \usepackage{amscd} +\usepackage{metalogo} -\newcommand{\catname}[1]{\textbf{#1}} -\newcommand{\C}[1]{\catname{#1}} - -% Specific categories -\newcommand{\Set}{\catname{Set}} -\newcommand{\Cat}{\catname{Cat}} -\newcommand{\CAT}{\catname{CAT}} -\newcommand{\Grp}{\catname{Grp}} - -% Common objects and functions -\newcommand{\Ob}{\operatorname{Ob}} -\newcommand{\op}{\text{op}} -\newcommand{\opof}[1]{{#1}^{\text{op}}} -% \id{x} is the identity morphism on x. -\newcommand{\id}[1]{1_{#1}} -% \Id{C} is the identity functor on C. -\newcommand{\Id}[1]{1_{#1}} -\newcommand{\Mor}{\operatorname{Mor}} -\newcommand{\homset}[3]{{{#1} \left[ {#2} \to {#3} \right]}} - -% Constructions of categories. -\newcommand{\FunctorCategory}[2]{\left[#1, #2\right]} -\newcommand{\Funct}[2]{\FunctorCategory{#1}{#2}} % Deprecated. -\newcommand{\ArrowCategory}[1]{{#1}^\to} - -% Semantic aliases -\newcommand{\monicto}{\rightarrowtail} -\newcommand{\epicto}{\twoheadrightarrow} -\newcommand{\naturalto}{\Rightarrow} -\newcommand{\isoto}{\cong} -\newcommand{\equivto}{\simeq} - -\newcommand{\naturaltrans}[2]{#1 \naturalto #2} % Deprecated. -\newcommand{\horizontalcompose}{\ast} - -% Optics -\newcommand{\opticname}[1]{\textbf{#1}} -\newcommand{\optic}[3]{\opticname{#1}^\prime\;#2\;#3} -\newcommand{\Optic}[5]{\opticname{#1}\;#2\;#3\;#4\;#5} - -% Default uses arrow glyphs from the active font, which are kinda ugly in the -% case of Plex. -\tikzcdset{ - arrow style=tikz -} +% {{preamble}} \begin{document} \setlength\abovedisplayskip{0pt} % Remove padding before equation environments. -%% \color[rgb]{0.000,0.000,0.004}\special{dvisvgm:currentcolor on}\setcounter{equation}{0}% % {{contents}} + \end{document} diff --git a/doerg/src/net/deertopia/doerg/tex/native.clj b/doerg/src/net/deertopia/doerg/tex/native.clj index 0243982..90832e6 100644 --- a/doerg/src/net/deertopia/doerg/tex/native.clj +++ b/doerg/src/net/deertopia/doerg/tex/native.clj @@ -107,13 +107,21 @@ (format "%09d.svg" i))] (zipmap (reverse snippets) svgs))) +(defn- read-prelude [] + (str (-> "net/deertopia/doerg/prelude.tex" io/resource slurp) + \newline + (-> "net/deertopia/doerg/native-prelude.tex" io/resource slurp))) + (defn- instantiate-preview-template [snippets] (let [contents (->> (for [s snippets] (format "\\begin{preview}\n%s\n\\end{preview}" s)) (str/join "\n"))] (-> (io/resource "net/deertopia/doerg/preview-template.tex") slurp - (str/replace-first "% {{contents}}" contents)))) + (str/replace #"% \{\{(contents|preamble)}}" + #(case (second %) + "contents" contents + "preamble" (read-prelude)))))) (defn render "Render a collection of `snippets` to SVGs in `output-dir` using a